1
1
name : Integration Tests
2
+
2
3
on :
3
4
workflow_dispatch :
4
5
inputs :
5
6
use_minimal_test_account :
6
7
description : ' Use minimal test account'
7
8
required : false
8
9
default : ' false'
10
+ test_path :
11
+ description : " The path from 'test/integration' to the target to be tested, e.g. 'cli'"
12
+ required : false
9
13
sha :
10
14
description : ' The hash value of the commit.'
11
15
required : false
12
16
default : ' '
17
+ pull_request_number :
18
+ description : ' The number of the PR. Ensure sha value is provided'
19
+ required : false
13
20
push :
14
21
branches :
15
22
- main
16
23
- dev
24
+
17
25
jobs :
18
26
integration-tests :
19
- name : Run integration tests
27
+ name : Run integration tests on Ubuntu
20
28
runs-on : ubuntu-latest
29
+ if : github.event_name == 'workflow_dispatch' && inputs.sha != '' || github.event_name == 'push' || github.event_name == 'pull_request'
21
30
steps :
22
- - name : Clone Repository with SHA
31
+ - name : Validate Test Path
32
+ uses : actions-ecosystem/action-regex-match@v2
33
+ id : validate-tests
34
+ if : ${{ inputs.test_path != '' }}
35
+ with :
36
+ text : ${{ inputs.test_path }}
37
+ regex : ' [^a-z0-9-:.\/_]' # Tests validation
38
+ flags : gi
39
+
40
+ - name : Checkout Repository with SHA
23
41
if : ${{ inputs.sha != '' }}
24
42
uses : actions/checkout@v4
25
43
with :
26
44
fetch-depth : 0
27
45
submodules : ' recursive'
28
46
ref : ${{ inputs.sha }}
29
47
30
- - name : Clone Repository without SHA
48
+ - name : Checkout Repository without SHA
31
49
if : ${{ inputs.sha == '' }}
32
50
uses : actions/checkout@v4
33
51
with :
34
52
fetch-depth : 0
35
53
submodules : ' recursive'
36
54
55
+ - name : Get the hash value of the latest commit from the PR branch
56
+ uses : octokit/graphql-action@v2.x
57
+ id : commit-hash
58
+ if : ${{ inputs.pull_request_number != '' }}
59
+ with :
60
+ query : |
61
+ query PRHeadCommitHash($owner: String!, $repo: String!, $pr_num: Int!) {
62
+ repository(owner:$owner, name:$repo) {
63
+ pullRequest(number: $pr_num) {
64
+ headRef {
65
+ target {
66
+ ... on Commit {
67
+ oid
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+ owner : ${{ github.event.repository.owner.login }}
75
+ repo : ${{ github.event.repository.name }}
76
+ pr_num : ${{ fromJSON(inputs.pull_request_number) }}
77
+ env :
78
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
79
+
37
80
- name : Update system packages
38
81
run : sudo apt-get update -y
39
82
70
113
timestamp=$(date +'%Y%m%d%H%M')
71
114
report_filename="${timestamp}_cli_test_report.xml"
72
115
make testint TEST_ARGS="--junitxml=${report_filename}"
116
+ if : ${{ steps.validate-tests.outputs.match == '' || inputs.test_path == '' }}
117
+ env :
118
+ LINODE_CLI_TOKEN : ${{ env.LINODE_CLI_TOKEN }}
73
119
74
120
- name : Apply Calico Rules to LKE
75
121
if : always()
@@ -91,4 +137,33 @@ jobs:
91
137
python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/xml_to_obj.py "${filename}"
92
138
env :
93
139
LINODE_CLI_OBJ_ACCESS_KEY : ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
94
- LINODE_CLI_OBJ_SECRET_KEY : ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
140
+ LINODE_CLI_OBJ_SECRET_KEY : ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
141
+
142
+ - name : Update PR Check Run
143
+ uses : actions/github-script@v6
144
+ id : update-check-run
145
+ if : ${{ inputs.pull_request_number != '' && fromJson(steps.commit-hash.outputs.data).repository.pullRequest.headRef.target.oid == inputs.sha }}
146
+ env :
147
+ number : ${{ inputs.pull_request_number }}
148
+ job : ${{ github.job }}
149
+ conclusion : ${{ job.status }}
150
+ with :
151
+ github-token : ${{ secrets.GITHUB_TOKEN }}
152
+ script : |
153
+ const { data: pull } = await github.rest.pulls.get({
154
+ ...context.repo,
155
+ pull_number: process.env.number
156
+ });
157
+ const ref = pull.head.sha;
158
+ const { data: checks } = await github.rest.checks.listForRef({
159
+ ...context.repo,
160
+ ref
161
+ });
162
+ const check = checks.check_runs.filter(c => c.name === process.env.job);
163
+ const { data: result } = await github.rest.checks.update({
164
+ ...context.repo,
165
+ check_run_id: check[0].id,
166
+ status: 'completed',
167
+ conclusion: process.env.conclusion
168
+ });
169
+ return result;
0 commit comments