Skip to content

Commit bebf2a2

Browse files
fix conflict
2 parents c3d7a34 + 89e7b7a commit bebf2a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1156
-303
lines changed

.github/workflows/e2e-suite-pr.yml renamed to .github/workflows/e2e-suite-windows.yml

Lines changed: 1 addition & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -15,97 +15,6 @@ on:
1515
name: PR E2E Tests
1616

1717
jobs:
18-
integration-fork-ubuntu:
19-
runs-on: ubuntu-latest
20-
if:
21-
github.event_name == 'workflow_dispatch' && inputs.sha != ''
22-
23-
steps:
24-
- uses: actions-ecosystem/action-regex-match@v2
25-
id: validate-tests
26-
with:
27-
text: ${{ inputs.test_path }}
28-
regex: '[^a-z0-9-:.\/_]' # Tests validation
29-
flags: gi
30-
31-
# Check out merge commit
32-
- name: Checkout PR
33-
uses: actions/checkout@v4
34-
with:
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) }}
59-
env:
60-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61-
62-
- name: Update system packages
63-
run: sudo apt-get update -y
64-
65-
- name: Setup Python
66-
uses: actions/setup-python@v4
67-
with:
68-
python-version: '3.x'
69-
70-
- name: Install Python deps
71-
run: pip install .[dev,obj]
72-
73-
- name: Install the CLI
74-
run: make install
75-
76-
- run: make INTEGRATION_TEST_PATH="${{ inputs.test_path }}" testint
77-
if: ${{ steps.validate-tests.outputs.match == '' }}
78-
env:
79-
LINODE_CLI_TOKEN: ${{ secrets.LINODE_TOKEN }}
80-
81-
- uses: actions/github-script@v6
82-
id: update-check-run
83-
if: ${{ inputs.pull_request_number != '' && fromJson(steps.commit-hash.outputs.data).repository.pullRequest.headRef.target.oid == inputs.sha }}
84-
env:
85-
number: ${{ inputs.pull_request_number }}
86-
job: ${{ github.job }}
87-
conclusion: ${{ job.status }}
88-
with:
89-
github-token: ${{ secrets.GITHUB_TOKEN }}
90-
script: |
91-
const { data: pull } = await github.rest.pulls.get({
92-
...context.repo,
93-
pull_number: process.env.number
94-
});
95-
const ref = pull.head.sha;
96-
const { data: checks } = await github.rest.checks.listForRef({
97-
...context.repo,
98-
ref
99-
});
100-
const check = checks.check_runs.filter(c => c.name === process.env.job);
101-
const { data: result } = await github.rest.checks.update({
102-
...context.repo,
103-
check_run_id: check[0].id,
104-
status: 'completed',
105-
conclusion: process.env.conclusion
106-
});
107-
return result;
108-
10918
integration-fork-windows:
11019
runs-on: windows-latest
11120
if:
@@ -191,4 +100,4 @@ jobs:
191100
status: 'completed',
192101
conclusion: process.env.conclusion
193102
});
194-
return result;
103+
return result;

.github/workflows/e2e-suite.yml

Lines changed: 148 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,82 @@
11
name: Integration Tests
2+
23
on:
34
workflow_dispatch:
45
inputs:
56
use_minimal_test_account:
67
description: 'Use minimal test account'
78
required: false
89
default: 'false'
10+
test_path:
11+
description: "The path from 'test/integration' to the target to be tested, e.g. 'cli'"
12+
required: false
913
sha:
1014
description: 'The hash value of the commit.'
1115
required: false
1216
default: ''
17+
pull_request_number:
18+
description: 'The number of the PR. Ensure sha value is provided'
19+
required: false
1320
push:
1421
branches:
1522
- main
1623
- dev
24+
1725
jobs:
18-
integration-tests:
19-
name: Run integration tests
26+
integration_tests:
27+
name: Run integration tests on Ubuntu
2028
runs-on: ubuntu-latest
29+
if: github.event_name == 'workflow_dispatch' && inputs.sha != '' || github.event_name == 'push' || github.event_name == 'pull_request'
2130
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
2341
if: ${{ inputs.sha != '' }}
2442
uses: actions/checkout@v4
2543
with:
2644
fetch-depth: 0
2745
submodules: 'recursive'
2846
ref: ${{ inputs.sha }}
2947

30-
- name: Clone Repository without SHA
48+
- name: Checkout Repository without SHA
3149
if: ${{ inputs.sha == '' }}
3250
uses: actions/checkout@v4
3351
with:
3452
fetch-depth: 0
3553
submodules: 'recursive'
3654

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+
3780
- name: Update system packages
3881
run: sudo apt-get update -y
3982

@@ -68,6 +111,9 @@ jobs:
68111
timestamp=$(date +'%Y%m%d%H%M')
69112
report_filename="${timestamp}_cli_test_report.xml"
70113
make testint TEST_ARGS="--junitxml=${report_filename}"
114+
if: ${{ steps.validate-tests.outputs.match == '' || inputs.test_path == '' }}
115+
env:
116+
LINODE_CLI_TOKEN: ${{ env.LINODE_CLI_TOKEN }}
71117

72118
- name: Apply Calico Rules to LKE
73119
if: always()
@@ -80,13 +126,108 @@ jobs:
80126
if: always()
81127
run: |
82128
filename=$(ls | grep -E '^[0-9]{12}_cli_test_report\.xml$')
83-
python tod_scripts/add_to_xml_test_report.py \
129+
python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/add_gha_info_to_xml.py \
84130
--branch_name "${GITHUB_REF#refs/*/}" \
85131
--gha_run_id "$GITHUB_RUN_ID" \
86132
--gha_run_number "$GITHUB_RUN_NUMBER" \
87133
--xmlfile "${filename}"
88134
sync
89-
python tod_scripts/test_report_upload_script.py "${filename}"
135+
python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/xml_to_obj.py "${filename}"
90136
env:
91137
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
92-
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
138+
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
139+
140+
- name: Update PR Check Run
141+
uses: actions/github-script@v6
142+
id: update-check-run
143+
if: ${{ inputs.pull_request_number != '' && fromJson(steps.commit-hash.outputs.data).repository.pullRequest.headRef.target.oid == inputs.sha }}
144+
env:
145+
number: ${{ inputs.pull_request_number }}
146+
job: ${{ github.job }}
147+
conclusion: ${{ job.status }}
148+
with:
149+
github-token: ${{ secrets.GITHUB_TOKEN }}
150+
script: |
151+
const { data: pull } = await github.rest.pulls.get({
152+
...context.repo,
153+
pull_number: process.env.number
154+
});
155+
const ref = pull.head.sha;
156+
const { data: checks } = await github.rest.checks.listForRef({
157+
...context.repo,
158+
ref
159+
});
160+
const check = checks.check_runs.filter(c => c.name === process.env.job);
161+
const { data: result } = await github.rest.checks.update({
162+
...context.repo,
163+
check_run_id: check[0].id,
164+
status: 'completed',
165+
conclusion: process.env.conclusion
166+
});
167+
return result;
168+
169+
notify-slack:
170+
runs-on: ubuntu-latest
171+
needs: [integration_tests]
172+
if: always() && github.repository == 'linode/linode-cli' # Run even if integration tests fail and only on main repository
173+
174+
steps:
175+
- name: Notify Slack
176+
uses: slackapi/slack-github-action@v1.27.0
177+
with:
178+
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
179+
payload: |
180+
{
181+
"blocks": [
182+
{
183+
"type": "section",
184+
"text": {
185+
"type": "mrkdwn",
186+
"text": ":rocket: *${{ github.workflow }} Completed in: ${{ github.repository }}* :white_check_mark:"
187+
}
188+
},
189+
{
190+
"type": "divider"
191+
},
192+
{
193+
"type": "section",
194+
"fields": [
195+
{
196+
"type": "mrkdwn",
197+
"text": "*Build Result:*\n${{ needs.integration_tests.result == 'success' && ':large_green_circle: Build Passed' || ':red_circle: Build Failed' }}"
198+
},
199+
{
200+
"type": "mrkdwn",
201+
"text": "*Branch:*\n`${{ github.ref_name }}`"
202+
}
203+
]
204+
},
205+
{
206+
"type": "section",
207+
"fields": [
208+
{
209+
"type": "mrkdwn",
210+
"text": "*Commit Hash:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>"
211+
},
212+
{
213+
"type": "mrkdwn",
214+
"text": "*Run URL:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run Details>"
215+
}
216+
]
217+
},
218+
{
219+
"type": "divider"
220+
},
221+
{
222+
"type": "context",
223+
"elements": [
224+
{
225+
"type": "mrkdwn",
226+
"text": "Triggered by: :bust_in_silhouette: `${{ github.actor }}`"
227+
}
228+
]
229+
}
230+
]
231+
}
232+
env:
233+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

0 commit comments

Comments
 (0)