11on :
22 pull_request :
3- repository_dispatch :
4- types : [acctest-command]
3+ workflow_dispatch :
4+ inputs :
5+ test_path :
6+ description : ' Test path to be tested: e.g. integration/cli'
7+ required : false
8+ sha :
9+ description : ' The hash value of the commit.'
10+ required : true
11+ pull_request_number :
12+ description : ' The number of the PR.'
13+ required : false
514
615name : PR E2E Tests
716
817jobs :
9- # Maintainer has commented /acctest on a pull request
10- integration-fork :
18+ integration-fork-ubuntu :
1119 runs-on : ubuntu-latest
1220 if :
13- github.event_name == 'repository_dispatch' &&
14- github.event.client_payload.slash_command.sha != '' &&
15- github.event.client_payload.pull_request.head.sha == github.event.client_payload.slash_command.sha
21+ github.event_name == 'workflow_dispatch' && inputs.sha != ''
1622
1723 steps :
1824 - uses : actions-ecosystem/action-regex-match@v2
1925 id : validate-tests
2026 with :
21- text : ${{ github.event.client_payload.slash_command.tests }}
27+ text : ${{ inputs.test_path }}
2228 regex : ' [^a-z0-9-:.\/_]' # Tests validation
2329 flags : gi
2430
2531 # Check out merge commit
2632 - name : Checkout PR
2733 uses : actions/checkout@v3
2834 with :
29- ref : ${{ github.event.client_payload.slash_command.sha }}
35+ ref : ${{ inputs.sha }}
36+
37+ - name : Get the hash value of the latest commit from the PR branch
38+ uses : octokit/graphql-action@v2.x
39+ id : commit-hash
40+ if : ${{ inputs.pull_request_number != '' }}
41+ with :
42+ query : |
43+ query PRHeadCommitHash($owner: String!, $repo: String!, $pr_num: Int!) {
44+ repository(owner:$owner, name:$repo) {
45+ pullRequest(number: $pr_num) {
46+ headRef {
47+ target {
48+ ... on Commit {
49+ oid
50+ }
51+ }
52+ }
53+ }
54+ }
55+ }
56+ owner : ${{ github.event.repository.owner.login }}
57+ repo : ${{ github.event.repository.name }}
58+ pr_num : ${{ fromJSON(inputs.pull_request_number) }}
3059
3160 - name : Update system packages
3261 run : sudo apt-get update -y
@@ -47,16 +76,16 @@ jobs:
4776 env :
4877 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4978
50- - run : make INTEGRATION_TEST_PATH="${{ github.event.client_payload.slash_command.tests }}" testint
79+ - run : make INTEGRATION_TEST_PATH="${{ inputs.test_path }}" testint
5180 if : ${{ steps.validate-tests.outputs.match == '' }}
5281 env :
5382 LINODE_CLI_TOKEN : ${{ secrets.LINODE_TOKEN }}
5483
55- - uses : actions/github-script@v5
84+ - uses : actions/github-script@v6
5685 id : update-check-run
57- if : ${{ always() }}
86+ if : ${{ inputs.pull_request_number != '' && fromJson(steps.commit-hash.outputs.data).repository.pullRequest.headRef.target.oid == inputs.sha }}
5887 env :
59- number : ${{ github.event.client_payload.pull_request.number }}
88+ number : ${{ inputs.pull_request_number }}
6089 job : ${{ github.job }}
6190 conclusion : ${{ job.status }}
6291 with :
@@ -79,3 +108,92 @@ jobs:
79108 conclusion: process.env.conclusion
80109 });
81110 return result;
111+
112+ integration-fork-windows :
113+ runs-on : windows-latest
114+ if :
115+ github.event_name == 'workflow_dispatch' && inputs.sha != ''
116+
117+ steps :
118+ - uses : actions-ecosystem/action-regex-match@v2
119+ id : validate-tests
120+ with :
121+ text : ${{ inputs.test_path }}
122+ regex : ' [^a-z0-9-:.\/_]' # Tests validation
123+ flags : gi
124+
125+ # Check out merge commit
126+ - name : Checkout PR
127+ uses : actions/checkout@v3
128+ with :
129+ ref : ${{ inputs.sha }}
130+
131+ - name : Get the hash value of the latest commit from the PR branch
132+ uses : octokit/graphql-action@v2.x
133+ id : commit-hash
134+ if : ${{ inputs.pull_request_number != '' }}
135+ with :
136+ query : |
137+ query PRHeadCommitHash($owner: String!, $repo: String!, $pr_num: Int!) {
138+ repository(owner:$owner, name:$repo) {
139+ pullRequest(number: $pr_num) {
140+ headRef {
141+ target {
142+ ... on Commit {
143+ oid
144+ }
145+ }
146+ }
147+ }
148+ }
149+ }
150+ owner : ${{ github.event.repository.owner.login }}
151+ repo : ${{ github.event.repository.name }}
152+ pr_num : ${{ fromJSON(inputs.pull_request_number) }}
153+ env :
154+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
155+
156+ - name : Setup Python
157+ uses : actions/setup-python@v4
158+ with :
159+ python-version : ' 3.x'
160+
161+ - name : Install Python deps
162+ run : pip install -r requirements.txt -r requirements-dev.txt wheel boto3
163+
164+ - name : Install the CLI
165+ run : make install
166+ env :
167+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
168+
169+ - run : make INTEGRATION_TEST_PATH="${{ inputs.test_path }}" testint
170+ env :
171+ LINODE_CLI_TOKEN : ${{ secrets.LINODE_TOKEN_2 }}
172+
173+ - uses : actions/github-script@v6
174+ id : update-check-run
175+ if : ${{ inputs.pull_request_number != '' && fromJson(steps.commit-hash.outputs.data).repository.pullRequest.headRef.target.oid == inputs.sha }}
176+ env :
177+ number : ${{ github.event.client_payload.pull_request.number }}
178+ job : ${{ github.job }}
179+ conclusion : ${{ job.status }}
180+ with :
181+ github-token : ${{ secrets.GITHUB_TOKEN }}
182+ script : |
183+ const { data: pull } = await github.rest.pulls.get({
184+ ...context.repo,
185+ pull_number: process.env.number
186+ });
187+ const ref = pull.head.sha;
188+ const { data: checks } = await github.rest.checks.listForRef({
189+ ...context.repo,
190+ ref
191+ });
192+ const check = checks.check_runs.filter(c => c.name === process.env.job);
193+ const { data: result } = await github.rest.checks.update({
194+ ...context.repo,
195+ check_run_id: check[0].id,
196+ status: 'completed',
197+ conclusion: process.env.conclusion
198+ });
199+ return result;
0 commit comments