Integration Tests #17
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Integration Tests | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
required: true | |
description: 'The environment to run the tests in' | |
type: environment | |
enabled: | |
required: false | |
description: 'Whether to run the tests' | |
type: boolean | |
default: true | |
infra: | |
required: false | |
description: An infra to use. Empty creates one. | |
type: string | |
logs: | |
required: false | |
description: 'Whether to log the tests' | |
type: boolean | |
default: false | |
workflow_call: | |
inputs: | |
environment: | |
required: true | |
description: 'The environment to run the tests in' | |
type: string | |
enabled: | |
required: false | |
description: 'Whether to run the tests' | |
type: boolean | |
default: true | |
infra: | |
required: false | |
description: An infra to use. Empty creates one. | |
type: string | |
logs: | |
required: false | |
description: 'Whether to log the tests' | |
type: boolean | |
default: false | |
jobs: | |
integration_tests: | |
name: Integration | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ inputs.environment }} | |
env: | |
DUPLO_HOST: ${{ vars.DUPLO_HOST }} | |
DUPLO_TOKEN: ${{ secrets.DUPLO_TOKEN }} | |
AWS_CONFIG_FILE: config/aws | |
AWS_DEFAULT_REGION: ${{ vars.AWS_REGION }} | |
AWS_REGION: ${{ vars.AWS_REGION }} | |
AWS_PROFILE: test | |
steps: | |
- name: Setup | |
uses: duplocloud/duploctl/.github/actions/setup@main | |
if: inputs.enabled | |
with: | |
optionals: "[build,test,aws]" | |
- name: Setup Args | |
id: pytest_args | |
if: inputs.enabled | |
env: | |
INFRA: ${{ inputs.infra }} | |
LOGS: ${{ inputs.logs }} | |
run: | | |
ARGS=( | |
"src" | |
"--junit-xml=test-results.xml" | |
"-m integration" | |
) | |
# if infra is set, add it to the args | |
if [ -n "$INFRA" ]; then | |
ARGS+=("--infra" "$INFRA") | |
fi | |
# if the logs are set, add it to the args | |
if [ "$LOGS" = "true" ]; then | |
ARGS+=("-s") | |
fi | |
echo "PYTEST_ARGS=${ARGS[*]}" >> $GITHUB_OUTPUT | |
# run the tests | |
- name: Test with pytest | |
if: inputs.enabled | |
run: pytest ${{ steps.pytest_args.outputs.PYTEST_ARGS }} | |
- name: Surface failing tests | |
if: always() && inputs.enabled | |
uses: pmeier/pytest-results-action@main | |
with: | |
path: test-results.xml | |
summary: true | |
display-options: fEX | |
fail-on-empty: true | |
- name: Cleanup | |
if: always() && inputs.enabled | |
run: | | |
mkdir -p config | |
duploctl jit update_aws_config test --admin | |
./scripts/aws_cleanup.sh |