Skip to content

Commit

Permalink
Merge pull request #51 from felixfontein/integration-error-behavior
Browse files Browse the repository at this point in the history
This patch makes `--retry-on-error`, `--continue-on-error` and
 `--diff` toggleable via action inputs.
  • Loading branch information
webknjaz authored Mar 9, 2023
2 parents 647b408 + 40cb17b commit ef8df30
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ jobs:
- default
git-checkout-ref:
- ''
integration-continue-on-error:
- ''
integration-diff:
- ''
integration-retry-on-error:
- ''
origin-python-version:
- ''
pre-action-cmd:
Expand Down Expand Up @@ -57,6 +63,9 @@ jobs:
collection-root: .
collection-src-directory: ./.tmp-action-checkout
coverage: auto
integration-continue-on-error: true
integration-diff: true
integration-retry-on-error: true
pre-action-cmd: >-
mv -v
.internal/ansible/ansible_collections/internal/test/galaxy.yml .
Expand All @@ -65,19 +74,28 @@ jobs:
collection-root: .internal/ansible/ansible_collections/internal/test
collection-src-directory: ./.tmp-action-checkout
coverage: never
integration-continue-on-error: true
integration-diff: true
integration-retry-on-error: true
origin-python-version: auto
testing-type: sanity
- ansible-core-version: devel
collection-root: .internal/ansible/ansible_collections/internal/test
collection-src-directory: ./.tmp-action-checkout
coverage: always
integration-continue-on-error: true
integration-diff: true
integration-retry-on-error: true
origin-python-version: auto
testing-type: units
- ansible-core-version: stable-2.13
collection-root: .internal/ansible/ansible_collections/internal/test
# NOTE: A missing `collection-src-directory` input causes
# NOTE: fetching the repo from GitHub.
coverage: auto
integration-continue-on-error: false
integration-diff: true
integration-retry-on-error: true
origin-python-version: '3.9'
pull-request-change-detection: 'true'
testing-type: integration
Expand All @@ -86,6 +104,9 @@ jobs:
# NOTE: A missing `collection-src-directory` input causes
# NOTE: fetching the repo from GitHub.
coverage: auto
integration-continue-on-error: true
integration-diff: true
integration-retry-on-error: false
origin-python-version: auto
testing-type: integration
test-deps: >-
Expand All @@ -95,6 +116,9 @@ jobs:
collection-root: .internal/ansible/ansible_collections/internal/test
collection-src-directory: ./.tmp-action-checkout
coverage: auto
integration-continue-on-error: true
integration-diff: false
integration-retry-on-error: true
origin-python-version: >-
3.10
testing-type: integration
Expand Down Expand Up @@ -122,6 +146,11 @@ jobs:
coverage: ${{ matrix.coverage }}
docker-image: ${{ matrix.docker-image }}
git-checkout-ref: ${{ matrix.git-checkout-ref }}
integration-continue-on-error: >-
${{ matrix.integration-continue-on-error || 'true' }}
integration-diff: ${{ matrix.integration-diff || 'true' }}
integration-retry-on-error: >-
${{ matrix.integration-retry-on-error || 'true' }}
origin-python-version: ${{ matrix.origin-python-version }}
pre-test-cmd: ${{ matrix.pre-test-cmd }}
pull-request-change-detection: >-
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,27 @@ Committish to check out, unused if `collection-src-directory`
is set **(OPTIONAL)**


### `integration-continue-on-error`

Whether the continue with the other integration tests when an error occurs.
If set to `false`, will stop on the first error. When set to `false` and
`coverage=auto`, code coverage uploading will be disabled.
**(DEFAULT: `true`)**


### `integration-diff`

Whether to show diff output when calling actions in integration tests.
Actions can override this by specifying `diff: false` or `diff: true`.
**(DEFAULT: `true`)**


### `integration-retry-on-error`

Whether to retry the current integration test once when an error happens.
**(DEFAULT: `true`)**


### `origin-python-version`

Environment Python version. The value `auto` uses the maximum Python
Expand Down
38 changes: 37 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ inputs:
description: >-
Committish to check out, unused
if `collection-src-directory` is set
integration-continue-on-error:
description: >-
Whether the continue with the other integration tests when an error
occurs. If set to `false`, will stop on the first error. When set to
`false` and `coverage=auto`, code coverage uploading will be disabled.
default: 'true'
integration-diff:
description: >-
Whether to show diff output when calling actions in integration tests.
Actions can override this by specifying `diff: false` or `diff: true`.
default: 'true'
integration-retry-on-error:
description: >-
Whether to retry the current integration test once when an error happens.
default: 'true'
origin-python-version:
description: >-
Environment Python version. The value `auto` uses the maximum Python
Expand Down Expand Up @@ -234,6 +249,13 @@ runs:
}}')
pull_request_branch = '${{ github.event.pull_request.base.ref || '' }}'
coverage = '${{ inputs.coverage }}'
integration_continue_on_error = json.loads('${{
inputs.integration-continue-on-error
}}')
integration_diff = json.loads('${{ inputs.integration-diff }}')
integration_retry_on_error = json.loads('${{
inputs.integration-retry-on-error
}}')
# Validate GHA inputs
if coverage not in {'always', 'never', 'auto'}:
Expand All @@ -248,14 +270,28 @@ runs:
change_detection_arg = ''
if pull_request_branch and pull_request_change_detection:
if coverage == 'auto':
print(
'Disabling coverage reporting due to pull request '
'change detection being enabled.',
)
coverage_arg = ''
change_detection_arg = (
f'--changed --base-branch {pull_request_branch}'
)
# Determine integration test flags
integration_flags = []
if integration_retry_on_error:
integration_flags.append('--retry-on-error')
if integration_continue_on_error:
integration_flags.append('--continue-on-error')
if integration_diff:
integration_flags.append('--diff')
# Set computed coverage-arg and change-detection-arg
set_output('coverage-arg', coverage_arg)
set_output('change-detection-arg', change_detection_arg)
set_output('integration-flags', ' '.join(integration_flags))
shell: python

- name: Log the next step action
Expand Down Expand Up @@ -485,7 +521,7 @@ runs:
}}
${{
inputs.testing-type == 'integration'
&& '--retry-on-error --continue-on-error --diff'
&& steps.ansible-test-flags.outputs.integration-flags
|| ''
}}
${{
Expand Down

0 comments on commit ef8df30

Please sign in to comment.