From 973da73f58559348e33ebfe21a7a3391ed59678c Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 21 Jan 2024 12:30:18 +0100 Subject: [PATCH] Allow to control which sanity tests run / do not run / are enabled This is useful when tests totally fail (skipping tests), or when sanity tests take too long and should be split up into parallel jobs (skipping and explicitly picking tests), or to enable tests that are disabled by default (like deprecation by date expiry). --- README.md | 15 +++++++++++++++ action.yml | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/README.md b/README.md index 1ed7916..ea45945 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,21 @@ The [`python-path` output value][`python-path`] of the [setup-python] action The actual value of `origin-python-version` passed to the [setup-python] action +### `sanity-tests` + +Comma-separated list of sanity tests to run. If not present, all applicable tests are run. + + +### `sanity-skip-tests` + +Comma-separated list of sanity tests to skip. + + +### `sanity-allow-disabled` + +Allow sanity tests to run which are disabled by default. + + ## Related community projects Check out the [Data-Bene/ansible-test-versions-gh-action] to explore diff --git a/action.yml b/action.yml index bda1aa5..c7b77d3 100644 --- a/action.yml +++ b/action.yml @@ -85,6 +85,15 @@ inputs: deprecationMessage: >- Replace `python-version` with `origin-python-version`. It is scheduled to be removed in version 3 of this action. + sanity-tests: + description: >- + Comma-separated list of sanity tests to run. + If not present, all applicable tests are run. + sanity-skip-tests: + description: Comma-separated list of sanity tests to skip. + sanity-allow-disabled: + description: Allow sanity tests to run which are disabled by default. + default: 'false' target: description: ansible-test TARGET target-python-version: @@ -94,6 +103,7 @@ inputs: required: true test-deps: description: Test dependencies to install along with this collection + outputs: ansible-playbook-executable: description: Path to the auto-installed `ansible-playbook` executable @@ -250,6 +260,9 @@ runs: GHA_PULL_REQUEST_BASE_REF: ${{ github.event.pull_request.base.ref || '' }} GHA_PULL_REQUEST_CHANGE_DETECTION: >- ${{ inputs.pull-request-change-detection }} + GHA_SANITY_TESTS: ${{ inputs.sanity-tests }} + GHA_SANITY_SKIP_TESTS: ${{ inputs.sanity-skip-tests }} + GHA_SANITY_ALLOW_DISABLED: ${{ inputs.sanity-allow-disabled }} GHA_TARGET: ${{ inputs.target }} GHA_TARGET_PYTHON_VERSION: ${{ inputs.target-python-version }} GHA_TESTING_TYPE: ${{ inputs.testing-type }} @@ -288,6 +301,11 @@ runs: gha_pull_request_change_detection = json.loads( os.environ['GHA_PULL_REQUEST_CHANGE_DETECTION'] ) + gha_sanity_tests = os.environ['GHA_SANITY_TESTS'] + gha_sanity_skip_tests = os.environ['GHA_SANITY_SKIP_TESTS'] + gha_sanity_allow_disabled = json.loads( + os.environ['GHA_SANITY_ALLOW_DISABLED'] + ) gha_target = os.environ['GHA_TARGET'] gha_target_python_version = os.environ['GHA_TARGET_PYTHON_VERSION'] gha_testing_type = os.environ['GHA_TESTING_TYPE'] @@ -326,6 +344,21 @@ runs: if gha_testing_type == 'sanity': command.append('--junit') + if gha_sanity_tests: + for test in gha_sanity_tests.split(','): + command.extend([ + '--test', + test.strip(), + ]) + if gha_sanity_skip_tests: + for test in gha_sanity_skip_tests.split(','): + command.extend([ + '--skip-test', + test.strip(), + ]) + if gha_sanity_allow_disabled: + command.append('--allow-disabled') + if gha_testing_type == 'integration': if gha_integration_retry_on_error: command.append('--retry-on-error')