From d828aded5954af52502df57825585f45671e98ae Mon Sep 17 00:00:00 2001 From: ykim-1 Date: Mon, 13 Jan 2025 08:45:28 -0800 Subject: [PATCH 1/3] gha test slack --- e2e_scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e_scripts b/e2e_scripts index 6b71cb72e..0f2ff0169 160000 --- a/e2e_scripts +++ b/e2e_scripts @@ -1 +1 @@ -Subproject commit 6b71cb72eb20a18ace82f9e73a0f99fe1141d625 +Subproject commit 0f2ff016956090c6fff046f4479e7efe8d0086e5 From af237f2487fbd51c6e6e8bdf297dfac5e94ff57f Mon Sep 17 00:00:00 2001 From: ykim-1 Date: Mon, 13 Jan 2025 11:13:43 -0800 Subject: [PATCH 2/3] gha test slack 1 --- .github/workflows/e2e-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 51eda09bf..6bc55639f 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -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/slack-github-action@v2.0.0 From 59f6ccb50d9f2c2d5eb2a8f3fb27b8f1ac1a9bc3 Mon Sep 17 00:00:00 2001 From: ykim-1 Date: Mon, 20 Jan 2025 12:00:02 -0800 Subject: [PATCH 3/3] refactor make test commands and update related workflows --- .github/workflows/e2e-test-pr.yml | 2 +- .github/workflows/e2e-test.yml | 16 ++++----- .github/workflows/nightly-smoke-tests.yml | 2 +- Makefile | 41 ++++++++--------------- README.rst | 10 +++--- 5 files changed, 29 insertions(+), 42 deletions(-) diff --git a/.github/workflows/e2e-test-pr.yml b/.github/workflows/e2e-test-pr.yml index 5e81a7829..2e9908433 100644 --- a/.github/workflows/e2e-test-pr.yml +++ b/.github/workflows/e2e-test-pr.yml @@ -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 }} diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 6bc55639f..4a2360d50 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -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 @@ -28,8 +28,8 @@ on: - dev env: - DEFAULT_PYTHON_VERSION: "3.9" - EOL_PYTHON_VERSION: "3.8" + DEFAULT_PYTHON_VERSION: "3.10" + EOL_PYTHON_VERSION: "3.9" EXIT_STATUS: 0 jobs: @@ -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 }} diff --git a/.github/workflows/nightly-smoke-tests.yml b/.github/workflows/nightly-smoke-tests.yml index 244df9afd..fc48ee010 100644 --- a/.github/workflows/nightly-smoke-tests.yml +++ b/.github/workflows/nightly-smoke-tests.yml @@ -39,7 +39,7 @@ jobs: - name: Run smoke tests id: smoke_tests run: | - make smoketest + make test-smoke env: LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }} diff --git a/Makefile b/Makefile index 03a527169..4bfb1c348 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 \ No newline at end of file diff --git a/README.rst b/README.rst index 1e6b310f4..5615bb488 100644 --- a/README.rst +++ b/README.rst @@ -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 -------------