Skip to content

Commit 4fa0cb6

Browse files
authored
Remove acctest command and add hash check (#473)
## 📝 Description Removing acctest command dependencies and add necessary workflow with checks ## ✔️ How to Test **What are the steps to reproduce the issue or verify the changes?** **How do I run the relevant unit/integration tests?** ## 📷 Preview **If applicable, include a screenshot or code snippet of this change. Otherwise, please remove this section.**
1 parent 959ca53 commit 4fa0cb6

File tree

1 file changed

+72
-20
lines changed

1 file changed

+72
-20
lines changed

.github/workflows/e2e-suite-pr.yml

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,61 @@
11
on:
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

615
name: PR E2E Tests
716

817
jobs:
9-
# Maintainer has commented /acctest on a pull request
1018
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 }}" TEST_CASE="${{ github.event.client_payload.slash_command.testcase }}" 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:
@@ -83,23 +112,46 @@ jobs:
83112
integration-fork-windows:
84113
runs-on: windows-latest
85114
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 != ''
89116

90117
steps:
91118
- uses: actions-ecosystem/action-regex-match@v2
92119
id: validate-tests
93120
with:
94-
text: ${{ github.event.client_payload.slash_command.tests }}
121+
text: ${{ inputs.test_path }}
95122
regex: '[^a-z0-9-:.\/_]' # Tests validation
96123
flags: gi
97124

98125
# Check out merge commit
99126
- name: Checkout PR
100127
uses: actions/checkout@v3
101128
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 }}
103155

104156
- name: Setup Python
105157
uses: actions/setup-python@v4
@@ -114,13 +166,13 @@ jobs:
114166
env:
115167
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116168

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
118170
env:
119171
LINODE_CLI_TOKEN: ${{ secrets.LINODE_TOKEN_2 }}
120172

121-
- uses: actions/github-script@v5
173+
- uses: actions/github-script@v6
122174
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 }}
124176
env:
125177
number: ${{ github.event.client_payload.pull_request.number }}
126178
job: ${{ github.job }}

0 commit comments

Comments
 (0)