Repository navigation
101 lines (97 loc) · 3.67 KB
/
Copy pathIntegrationTestRequest.yml
File metadata and controls
101 lines (97 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: "IntegrationTestRequest"
on:
workflow_call:
inputs:
trigger:
description: "Required trigger for requesting the test suite"
default: "/integrationtest"
required: false
type: string
localregistry:
description: "Add local registries hosted on GitHub. Specified by providing the url (https/ssh) to the repositories as a newline (\n) seperated list. User is responsible for setting up the necessary SSH-Keys to access the repositories if necessary."
default: ""
required: false
type: string
extra-dev-paths:
description: "Additional local package paths to develop alongside the repository root, specified as a newline-separated list."
default: ""
required: false
type: string
jobs:
get-pr-comment:
name: "Get PR Comment"
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
pkgs: ${{ steps.extract.outputs.pkgs }}
head_sha: ${{ steps.pr.outputs.head_sha }}
steps:
- name: "Extract command arguments"
id: extract
env:
COMMENT: ${{ github.event.comment.body }}
QUERY: ${{ inputs.trigger }}
run: |
if [[ "$COMMENT" != "$QUERY "* ]]; then
echo "No valid command found, exiting..."
exit 1
fi
PKG="${COMMENT#"$QUERY "}"
# Encode as a single-element JSON array for the IntegrationTest
# workflow's `pkgs` input. `jq` handles any escaping for us.
PKGS=$(jq -nc --arg pkg "$PKG" '[$pkg]')
echo "pkgs=$PKGS" >> "$GITHUB_OUTPUT"
- name: "Resolve PR head SHA"
id: pr
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.issue.number }}
run: |
HEAD_SHA=$(gh api "repos/$REPO/pulls/$PR_NUMBER" --jq '.head.sha')
echo "head_sha=$HEAD_SHA" >> "$GITHUB_OUTPUT"
run-tests:
name: "Run Tests"
needs: get-pr-comment
uses: ITensor/ITensorActions/.github/workflows/IntegrationTest.yml@main
with:
localregistry: "${{ inputs.localregistry }}"
extra-dev-paths: "${{ inputs.extra-dev-paths }}"
pkgs: ${{ needs.get-pr-comment.outputs.pkgs }}
secrets: inherit
report:
name: "Report"
needs: [get-pr-comment, run-tests]
if: ${{ always() && needs.get-pr-comment.result == 'success' }}
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
steps:
- name: "React to triggering comment"
uses: peter-evans/create-or-update-comment@v5
with:
token: ${{ secrets.INTEGRATIONTEST_PAT || github.token }}
comment-id: ${{ github.event.comment.id }}
reactions: '+1'
# When the test passed, post a check run with the same name that
# branch protection requires for IntegrationTest. This lets a
# successful `/integrationtest` clear the IntegrationTest gate on
# fork PRs whose private-only matrix would otherwise leave that
# gate failing.
- name: "Post passing IntegrationTest check"
if: ${{ needs.run-tests.result == 'success' }}
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
HEAD_SHA: ${{ needs.get-pr-comment.outputs.head_sha }}
run: |
gh api -X POST "repos/$REPO/check-runs" \
-f name="IntegrationTest" \
-f head_sha="$HEAD_SHA" \
-f status="completed" \
-f conclusion="success" \
-f "output[title]=Passed via /integrationtest" \
-f "output[summary]=Integration test passed when triggered manually."