Skip to content

Commit 45db566

Browse files
authored
test/workflow: Refactor make test commands and update related workflows (#716)
1 parent a8c94e2 commit 45db566

File tree

4 files changed

+77
-42
lines changed

4 files changed

+77
-42
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
env:
7474
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7575

76-
- run: make MODULE="${{ inputs.module }}" RUN_LONG_TESTS="${{ inputs.run_long_tests }}" testint
76+
- run: make MODULE="${{ inputs.module }}" RUN_LONG_TESTS="${{ inputs.run_long_tests }}" test-int
7777
env:
7878
LINODE_CLI_TOKEN: ${{ secrets.LINODE_TOKEN_2 }}
7979

.github/workflows/e2e-suite.yml

Lines changed: 62 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@ on:
44
workflow_dispatch:
55
inputs:
66
use_minimal_test_account:
7-
description: 'Use minimal test account'
7+
description: 'Indicate whether to use a minimal test account with limited resources for testing. Defaults to "false"'
88
required: false
99
default: 'false'
10-
module:
11-
description: "The module from 'test/integration' to the target to be tested, e.g. 'cli, domains, events, etc'"
10+
test_suite:
11+
description: "Specify test suite to run from the 'tests/integration' directory. Examples: 'cli', 'domains', 'events', etc. If not provided, all suites are executed"
1212
required: false
1313
run_long_tests:
14-
description: "Select True to run long tests, e.g. database, rebuild, etc"
14+
description: "Select 'True' to include long-running tests (e.g., database provisioning, server rebuilds). Defaults to 'False'"
1515
required: false
1616
type: choice
1717
options:
1818
- "True"
1919
- "False"
2020
default: "False"
2121
sha:
22-
description: 'The hash value of the commit.'
22+
description: 'Specify commit hash to test. This value is mandatory to ensure the tests run against a specific commit'
2323
required: true
2424
default: ''
2525
pull_request_number:
26-
description: 'The number of the PR. Ensure sha value is provided'
26+
description: 'Specify pull request number associated with the commit. Optional, but recommended when providing a commit hash (sha)'
2727
required: false
2828
openapi_spec_url:
29-
description: 'URL of the OpenAPI spec to use for the tests'
29+
description: 'Specify URL of the OpenAPI specification file to use for testing. Useful for validating tests against a specific API version or custom specification'
3030
required: false
3131
default: ''
3232
python-version:
33-
description: 'Specify Python version to use'
33+
description: 'Specify the Python version to use for running tests. Leave empty to use the default Python version configured in the environment'
3434
required: false
3535
run-eol-python-version:
36-
description: 'Run EOL python version?'
36+
description: 'Indicates whether to run tests using an End-of-Life (EOL) Python version. Defaults to "false". Choose "true" to include tests for deprecated Python versions'
3737
required: false
3838
default: 'false'
3939
type: choice
@@ -124,24 +124,18 @@ jobs:
124124
run: |
125125
timestamp=$(date +'%Y%m%d%H%M')
126126
report_filename="${timestamp}_cli_test_report.xml"
127-
make testint TEST_ARGS="--junitxml=${report_filename}" MODULE="${{ inputs.module }}" RUN_LONG_TESTS="${{ inputs.run_long_tests }}"
127+
make test-int TEST_ARGS="--junitxml=${report_filename}" TEST_SUITE="${{ inputs.test_suite }}" RUN_LONG_TESTS="${{ inputs.run_long_tests }}"
128128
env:
129129
LINODE_CLI_TOKEN: ${{ env.LINODE_CLI_TOKEN }}
130130

131-
- name: Upload test results
131+
- name: Upload Test Report as Artifact
132132
if: always()
133-
run: |
134-
filename=$(ls | grep -E '^[0-9]{12}_cli_test_report\.xml$')
135-
python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/add_gha_info_to_xml.py \
136-
--branch_name "${GITHUB_REF#refs/*/}" \
137-
--gha_run_id "$GITHUB_RUN_ID" \
138-
--gha_run_number "$GITHUB_RUN_NUMBER" \
139-
--xmlfile "${filename}"
140-
sync
141-
python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/xml_to_obj.py "${filename}"
142-
env:
143-
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
144-
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
133+
uses: actions/upload-artifact@v4
134+
with:
135+
name: test-report-file
136+
if-no-files-found: ignore
137+
path: '*.xml'
138+
retention-days: 1
145139

146140
- name: Update PR Check Run
147141
uses: actions/github-script@v7
@@ -237,6 +231,51 @@ jobs:
237231
env:
238232
LINODE_CLI_TOKEN: ${{ env.LINODE_CLI_TOKEN }}
239233

234+
process-upload-report:
235+
runs-on: ubuntu-latest
236+
needs: [integration_tests]
237+
if: always() && github.repository == 'linode/linode-cli' # Run even if integration tests fail and only on main repository
238+
239+
steps:
240+
- name: Checkout code
241+
uses: actions/checkout@v4
242+
with:
243+
fetch-depth: 0
244+
submodules: 'recursive'
245+
246+
- name: Download test report
247+
uses: actions/download-artifact@v4
248+
with:
249+
name: test-report-file
250+
251+
- name: Set up Python
252+
uses: actions/setup-python@v5
253+
with:
254+
python-version: '3.x'
255+
256+
- name: Install Python dependencies
257+
run: pip3 install requests wheel boto3==1.35.99
258+
259+
- name: Set release version env
260+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
261+
262+
263+
- name: Add variables and upload test results
264+
if: always()
265+
run: |
266+
filename=$(ls | grep -E '^[0-9]{12}_cli_test_report\.xml$')
267+
python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/add_gha_info_to_xml.py \
268+
--branch_name "${GITHUB_REF#refs/*/}" \
269+
--gha_run_id "$GITHUB_RUN_ID" \
270+
--gha_run_number "$GITHUB_RUN_NUMBER" \
271+
--xmlfile "${filename}"
272+
sync
273+
python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/xml_to_obj.py "${filename}"
274+
env:
275+
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
276+
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
277+
278+
240279
notify-slack:
241280
runs-on: ubuntu-latest
242281
needs: [integration_tests]

.github/workflows/nightly-smoke-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- name: Run smoke tests
4141
id: smoke_tests
4242
run: |
43-
make smoketest
43+
make test-smoke
4444
env:
4545
LINODE_CLI_TOKEN: ${{ secrets.LINODE_TOKEN }}
4646

Makefile

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22
# Makefile for more convenient building of the Linode CLI and its baked content
33
#
44

5-
# Test-related arguments
6-
MODULE :=
7-
TEST_CASE_COMMAND :=
8-
TEST_ARGS :=
9-
10-
ifdef TEST_CASE
11-
TEST_CASE_COMMAND = -k $(TEST_CASE)
12-
endif
13-
145
SPEC_VERSION ?= latest
156
ifndef SPEC
167
override SPEC = $(shell ./resolve_spec_url ${SPEC_VERSION})
@@ -66,8 +57,8 @@ clean:
6657
rm -f data-*
6758
rm -rf dist linode_cli.egg-info build
6859

69-
.PHONY: testunit
70-
testunit:
60+
.PHONY: test-unit
61+
test-unit:
7162
@mkdir -p /tmp/linode/.config
7263
@orig_xdg_config_home=$${XDG_CONFIG_HOME:-}; \
7364
export LINODE_CLI_TEST_MODE=1 XDG_CONFIG_HOME=/tmp/linode/.config; \
@@ -76,17 +67,22 @@ testunit:
7667
export XDG_CONFIG_HOME=$$orig_xdg_config_home; \
7768
exit $$exit_code
7869

79-
.PHONY: testint
80-
testint:
81-
pytest tests/integration/${MODULE} ${TEST_CASE_COMMAND} ${TEST_ARGS}
70+
# Integration Test Arguments
71+
# TEST_SUITE: Optional, specify a test suite (e.g. domains), Default to run everything if not set
72+
# TEST_CASE: Optional, specify a test case (e.g. 'test_create_a_domain')
73+
# TEST_ARGS: Optional, additional arguments for pytest (e.g. '-v' for verbose mode)
74+
75+
.PHONY: test-int
76+
test-int:
77+
pytest tests/integration/$(TEST_SUITE) $(if $(TEST_CASE),-k $(TEST_CASE)) $(TEST_ARGS)
8278

8379
.PHONY: testall
8480
testall:
8581
pytest tests
8682

8783
# Alias for unit; integration tests should be explicit
8884
.PHONY: test
89-
test: testunit
85+
test: test-unit
9086

9187
.PHONY: black
9288
black:
@@ -103,6 +99,6 @@ autoflake:
10399
.PHONY: format
104100
format: black isort autoflake
105101

106-
@PHONEY: smoketest
107-
smoketest:
102+
@PHONEY: test-smoke
103+
test-smoke:
108104
pytest -m smoke tests/integration

0 commit comments

Comments
 (0)