1
1
on :
2
2
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
5
14
6
15
name : PR E2E Tests
7
16
8
17
jobs :
9
- # Maintainer has commented /acctest on a pull request
10
18
integration-fork-ubuntu :
11
19
runs-on : ubuntu-latest
12
20
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 != ''
16
22
17
23
steps :
18
24
- uses : actions-ecosystem/action-regex-match@v2
19
25
id : validate-tests
20
26
with :
21
- text : ${{ github.event.client_payload.slash_command.tests }}
27
+ text : ${{ inputs.test_path }}
22
28
regex : ' [^a-z0-9-:.\/_]' # Tests validation
23
29
flags : gi
24
30
25
31
# Check out merge commit
26
32
- name : Checkout PR
27
33
uses : actions/checkout@v3
28
34
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) }}
30
59
31
60
- name : Update system packages
32
61
run : sudo apt-get update -y
@@ -47,16 +76,16 @@ jobs:
47
76
env :
48
77
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
49
78
50
- - run : make INTEGRATION_TEST_PATH="${{ github.event.client_payload.slash_command.tests }}" TEST_CASE="${{ github.event.client_payload.slash_command.testcase }}" testint
79
+ - run : make INTEGRATION_TEST_PATH="${{ inputs.test_path }}" testint
51
80
if : ${{ steps.validate-tests.outputs.match == '' }}
52
81
env :
53
82
LINODE_CLI_TOKEN : ${{ secrets.LINODE_TOKEN }}
54
83
55
- - uses : actions/github-script@v5
84
+ - uses : actions/github-script@v6
56
85
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 }}
58
87
env :
59
- number : ${{ github.event.client_payload.pull_request.number }}
88
+ number : ${{ inputs.pull_request_number }}
60
89
job : ${{ github.job }}
61
90
conclusion : ${{ job.status }}
62
91
with :
@@ -83,23 +112,46 @@ jobs:
83
112
integration-fork-windows :
84
113
runs-on : windows-latest
85
114
if :
86
- github.event_name == 'repository_dispatch' &&
87
- github.event.client_payload.slash_command.sha != '' &&
88
- github.event.client_payload.pull_request.head.sha == github.event.client_payload.slash_command.sha
115
+ github.event_name == 'workflow_dispatch' && inputs.sha != ''
89
116
90
117
steps :
91
118
- uses : actions-ecosystem/action-regex-match@v2
92
119
id : validate-tests
93
120
with :
94
- text : ${{ github.event.client_payload.slash_command.tests }}
121
+ text : ${{ inputs.test_path }}
95
122
regex : ' [^a-z0-9-:.\/_]' # Tests validation
96
123
flags : gi
97
124
98
125
# Check out merge commit
99
126
- name : Checkout PR
100
127
uses : actions/checkout@v3
101
128
with :
102
- ref : ${{ github.event.client_payload.slash_command.sha }}
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 }}
103
155
104
156
- name : Setup Python
105
157
uses : actions/setup-python@v4
@@ -114,13 +166,13 @@ jobs:
114
166
env :
115
167
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
116
168
117
- - run : make INTEGRATION_TEST_PATH="${{ github.event.client_payload.slash_command.tests }}" TEST_CASE="${{ github.event.client_payload.slash_command.testcase }}" testint
169
+ - run : make INTEGRATION_TEST_PATH="${{ inputs.test_path }}" testint
118
170
env :
119
171
LINODE_CLI_TOKEN : ${{ secrets.LINODE_TOKEN_2 }}
120
172
121
- - uses : actions/github-script@v5
173
+ - uses : actions/github-script@v6
122
174
id : update-check-run
123
- if : ${{ always() }}
175
+ if : ${{ inputs.pull_request_number != '' && fromJson(steps.commit-hash.outputs.data).repository.pullRequest.headRef.target.oid == inputs.sha }}
124
176
env :
125
177
number : ${{ github.event.client_payload.pull_request.number }}
126
178
job : ${{ github.job }}
0 commit comments