Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/workflow: Update make test commands and related workflows #498

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
run: |
timestamp=$(date +'%Y%m%d%H%M')
report_filename="${timestamp}_sdk_test_report.xml"
make testint TEST_ARGS="--junitxml=${report_filename}" TEST_SUITE="${{ github.event.inputs.test_suite }}"
make test-int TEST_ARGS="--junitxml=${report_filename}" TEST_SUITE="${{ github.event.inputs.test_suite }}"
env:
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}

Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ on:
workflow_dispatch:
inputs:
use_minimal_test_account:
description: 'Use minimal test account'
description: 'Indicate whether to use a minimal test account with limited resources for testing. Defaults to "false"'
required: false
default: 'false'
sha:
description: 'The hash value of the commit'
required: false
description: 'Specify commit hash to test. This value is mandatory to ensure the tests run against a specific commit'
required: true
default: ''
python-version:
description: 'Specify Python version to use'
description: 'Specify the Python version to use for running tests. Leave empty to use the default Python version configured in the environment'
required: false
run-eol-python-version:
description: 'Run EOL python version?'
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'
required: false
default: 'false'
type: choice
Expand All @@ -28,8 +28,8 @@ on:
- dev

env:
DEFAULT_PYTHON_VERSION: "3.9"
EOL_PYTHON_VERSION: "3.8"
DEFAULT_PYTHON_VERSION: "3.10"
Copy link
Contributor Author

@ykim-akamai ykim-akamai Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump default python version to 3.10 and EOL version to 3.9

EOL_PYTHON_VERSION: "3.9"
EXIT_STATUS: 0

jobs:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
run: |
timestamp=$(date +'%Y%m%d%H%M')
report_filename="${timestamp}_sdk_test_report.xml"
make testint TEST_ARGS="--junitxml=${report_filename}"
make test-int TEST_ARGS="--junitxml=${report_filename}"
env:
LINODE_TOKEN: ${{ env.LINODE_TOKEN }}

Expand Down Expand Up @@ -159,7 +159,7 @@ jobs:
notify-slack:
runs-on: ubuntu-latest
needs: [integration-tests]
if: ${{ (success() || failure()) && github.repository == 'linode/linode_api4-python' }} # Run even if integration tests fail and only on main repository
if: ${{ (success() || failure()) }} # Run even if integration tests fail and only on main repository
steps:
- name: Notify Slack
uses: slackapi/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Run smoke tests
id: smoke_tests
run: |
make smoketest
make test-smoke
env:
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}

Expand Down
41 changes: 14 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
PYTHON ?= python3

TEST_CASE_COMMAND :=
TEST_SUITE :=
TEST_ARGS :=

LINODE_SDK_VERSION ?= "0.0.0.dev"
VERSION_MODULE_DOCSTRING ?= \"\"\"\nThe version of this linode_api4 package.\n\"\"\"\n\n
VERSION_FILE := ./linode_api4/version.py

ifdef TEST_CASE
TEST_CASE_COMMAND = -k $(TEST_CASE)
endif

ifdef TEST_SUITE
ifneq ($(TEST_SUITE),linode_client)
ifneq ($(TEST_SUITE),login_client)
TEST_COMMAND = models/$(TEST_SUITE)
else
TEST_COMMAND = login_client
endif
else
TEST_COMMAND = linode_client
endif
endif

.PHONY: clean
clean:
mkdir -p dist
Expand Down Expand Up @@ -73,14 +53,21 @@ lint: build
$(PYTHON) -m pylint linode_api4
$(PYTHON) -m twine check dist/*

.PHONY: testint
testint:
$(PYTHON) -m pytest test/integration/${TEST_COMMAND} ${TEST_CASE_COMMAND} ${TEST_ARGS}
# Integration Test Arguments
# TEST_SUITE: Optional, specify a test suite (e.g. domain), Default to run everything if not set
# TEST_CASE: Optional, specify a test case (e.g. 'test_image_replication')
# TEST_ARGS: Optional, additional arguments for pytest (e.g. '-v' for verbose mode)

TEST_COMMAND = $(if $(TEST_SUITE),$(if $(filter $(TEST_SUITE),linode_client login_client),$(TEST_SUITE),models/$(TEST_SUITE)))

.PHONY: test-int
test-int:
$(PYTHON) -m pytest test/integration/${TEST_COMMAND} $(if $(TEST_CASE),-k $(TEST_CASE)) ${TEST_ARGS}

.PHONY: testunit
testunit:
.PHONY: test-unit
test-unit:
$(PYTHON) -m pytest test/unit

.PHONY: smoketest
smoketest:
.PHONY: test-smoke
test-smoke:
$(PYTHON) -m pytest -m smoke test/integration
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,16 @@ Running the tests
^^^^^^^^^^^^^^^^^
Run the tests locally using the make command. Run the entire test suite using command below::

make testint
make test-int

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

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

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

make TEST_CASE=test_get_domain_record testint
make TEST_CASE=test_get_domain_record test-int

Documentation
-------------
Expand Down
2 changes: 1 addition & 1 deletion e2e_scripts
Loading