Skip to content

Commit 0e1f0a3

Browse files
authored
test/workflow: Update make test commands and related workflows (#498)
* gha test slack * gha test slack 1 * refactor make test commands and update related workflows
1 parent e2e9343 commit 0e1f0a3

File tree

6 files changed

+31
-44
lines changed

6 files changed

+31
-44
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
run: |
8181
timestamp=$(date +'%Y%m%d%H%M')
8282
report_filename="${timestamp}_sdk_test_report.xml"
83-
make testint TEST_ARGS="--junitxml=${report_filename}" TEST_SUITE="${{ github.event.inputs.test_suite }}"
83+
make test-int TEST_ARGS="--junitxml=${report_filename}" TEST_SUITE="${{ github.event.inputs.test_suite }}"
8484
env:
8585
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
8686

.github/workflows/e2e-test.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ 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'
1010
sha:
11-
description: 'The hash value of the commit'
12-
required: false
11+
description: 'Specify commit hash to test. This value is mandatory to ensure the tests run against a specific commit'
12+
required: true
1313
default: ''
1414
python-version:
15-
description: 'Specify Python version to use'
15+
description: 'Specify the Python version to use for running tests. Leave empty to use the default Python version configured in the environment'
1616
required: false
1717
run-eol-python-version:
18-
description: 'Run EOL python version?'
18+
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'
1919
required: false
2020
default: 'false'
2121
type: choice
@@ -28,8 +28,8 @@ on:
2828
- dev
2929

3030
env:
31-
DEFAULT_PYTHON_VERSION: "3.9"
32-
EOL_PYTHON_VERSION: "3.8"
31+
DEFAULT_PYTHON_VERSION: "3.10"
32+
EOL_PYTHON_VERSION: "3.9"
3333
EXIT_STATUS: 0
3434

3535
jobs:
@@ -72,7 +72,7 @@ jobs:
7272
run: |
7373
timestamp=$(date +'%Y%m%d%H%M')
7474
report_filename="${timestamp}_sdk_test_report.xml"
75-
make testint TEST_ARGS="--junitxml=${report_filename}"
75+
make test-int TEST_ARGS="--junitxml=${report_filename}"
7676
env:
7777
LINODE_TOKEN: ${{ env.LINODE_TOKEN }}
7878

@@ -159,7 +159,7 @@ jobs:
159159
notify-slack:
160160
runs-on: ubuntu-latest
161161
needs: [integration-tests]
162-
if: ${{ (success() || failure()) && github.repository == 'linode/linode_api4-python' }} # Run even if integration tests fail and only on main repository
162+
if: ${{ (success() || failure()) }} # Run even if integration tests fail and only on main repository
163163
steps:
164164
- name: Notify Slack
165165
uses: slackapi/slack-github-action@v2.0.0

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

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

Makefile

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
11
PYTHON ?= python3
22

3-
TEST_CASE_COMMAND :=
4-
TEST_SUITE :=
5-
TEST_ARGS :=
6-
73
LINODE_SDK_VERSION ?= "0.0.0.dev"
84
VERSION_MODULE_DOCSTRING ?= \"\"\"\nThe version of this linode_api4 package.\n\"\"\"\n\n
95
VERSION_FILE := ./linode_api4/version.py
106

11-
ifdef TEST_CASE
12-
TEST_CASE_COMMAND = -k $(TEST_CASE)
13-
endif
14-
15-
ifdef TEST_SUITE
16-
ifneq ($(TEST_SUITE),linode_client)
17-
ifneq ($(TEST_SUITE),login_client)
18-
TEST_COMMAND = models/$(TEST_SUITE)
19-
else
20-
TEST_COMMAND = login_client
21-
endif
22-
else
23-
TEST_COMMAND = linode_client
24-
endif
25-
endif
26-
277
.PHONY: clean
288
clean:
299
mkdir -p dist
@@ -73,14 +53,21 @@ lint: build
7353
$(PYTHON) -m pylint linode_api4
7454
$(PYTHON) -m twine check dist/*
7555

76-
.PHONY: testint
77-
testint:
78-
$(PYTHON) -m pytest test/integration/${TEST_COMMAND} ${TEST_CASE_COMMAND} ${TEST_ARGS}
56+
# Integration Test Arguments
57+
# TEST_SUITE: Optional, specify a test suite (e.g. domain), Default to run everything if not set
58+
# TEST_CASE: Optional, specify a test case (e.g. 'test_image_replication')
59+
# TEST_ARGS: Optional, additional arguments for pytest (e.g. '-v' for verbose mode)
60+
61+
TEST_COMMAND = $(if $(TEST_SUITE),$(if $(filter $(TEST_SUITE),linode_client login_client),$(TEST_SUITE),models/$(TEST_SUITE)))
62+
63+
.PHONY: test-int
64+
test-int:
65+
$(PYTHON) -m pytest test/integration/${TEST_COMMAND} $(if $(TEST_CASE),-k $(TEST_CASE)) ${TEST_ARGS}
7966

80-
.PHONY: testunit
81-
testunit:
67+
.PHONY: test-unit
68+
test-unit:
8269
$(PYTHON) -m pytest test/unit
8370

84-
.PHONY: smoketest
85-
smoketest:
71+
.PHONY: test-smoke
72+
test-smoke:
8673
$(PYTHON) -m pytest -m smoke test/integration

README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,16 @@ Running the tests
148148
^^^^^^^^^^^^^^^^^
149149
Run the tests locally using the make command. Run the entire test suite using command below::
150150

151-
make testint
151+
make test-int
152152

153153
To run a specific package/suite, use the environment variable `TEST_SUITE` using directory names in `integration/...` folder ::
154154

155-
make TEST_SUITE="account" testint // Runs tests in `integration/models/account` directory
156-
make TEST_SUITE="linode_client" testint // Runs tests in `integration/linode_client` directory
155+
make TEST_SUITE="account" test-int // Runs tests in `integration/models/account` directory
156+
make TEST_SUITE="linode_client" test-int // Runs tests in `integration/linode_client` directory
157157

158-
Lastly to run a specific test case use environment variable `TEST_CASE` with `testint` command::
158+
Lastly to run a specific test case use environment variable `TEST_CASE` with `test-int` command::
159159

160-
make TEST_CASE=test_get_domain_record testint
160+
make TEST_CASE=test_get_domain_record test-int
161161

162162
Documentation
163163
-------------

0 commit comments

Comments
 (0)