Skip to content

Commit

Permalink
Allow to control which sanity tests run / do not run / are enabled
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
felixfontein committed Mar 30, 2024
1 parent f7f5020 commit 973da73
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 973da73

Please sign in to comment.