-
Notifications
You must be signed in to change notification settings - Fork 3
113 lines (106 loc) · 2.89 KB
/
test_integration.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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
secrets:
GH_APP_KEY:
description: GitHub App private key
required: true
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:
install: ".[build,test,aws]"
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_KEY }}
- 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