-
Notifications
You must be signed in to change notification settings - Fork 1
250 lines (241 loc) · 8.82 KB
/
stage-2-test.yaml
File metadata and controls
250 lines (241 loc) · 8.82 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
name: "Test stage"
on:
workflow_call:
inputs:
python_version:
description: "Python version, set by the CI/CD pipeline workflow"
required: true
type: string
secrets:
SONAR_TOKEN:
description: "SonarCloud token for authentication"
required: true
jobs:
create-coverage-name:
name: "Create coverage artefact name"
runs-on: ubuntu-latest
outputs:
coverage-name: ${{ steps.create_name.outputs.artefact-name }}
steps:
- name: "Checkout code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- id: create_name
name: "Generate unique coverage artefact name"
uses: ./.github/actions/create-artefact-name
with:
prefix: coverage
test-unit:
name: "Unit tests"
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: "Checkout code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: "Setup Python project"
uses: ./.github/actions/setup-python-project
with:
python-version: ${{ inputs.python_version }}
- name: Set environment variables
run: make env-test-ci
- name: "Run unit test suite"
run: make test-unit
- name: "Upload unit test results"
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: unit-test-results
path: gateway-api/test-artefacts/
retention-days: 30
- name: "Publish unit test results to summary"
if: always()
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: gateway-api/test-artefacts/unit-tests.xml
test-contract:
name: "Contract tests"
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: "Checkout code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: "Setup Python project"
uses: ./.github/actions/setup-python-project
with:
python-version: ${{ inputs.python_version }}
- name: "Start app"
uses: ./.github/actions/start-app
with:
python-version: ${{ inputs.python_version }}
- name: Set environment variables
run: make env-test-ci
- name: "Run contract tests"
run: make test-contract
- name: "Upload contract test results"
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: contract-test-results
path: gateway-api/test-artefacts/
retention-days: 30
- name: "Publish contract test results to summary"
if: always()
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: gateway-api/test-artefacts/contract-tests.xml
test-schema:
name: "Schema validation tests"
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: "Checkout code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: "Setup Python project"
uses: ./.github/actions/setup-python-project
with:
python-version: ${{ inputs.python_version }}
- name: "Start app"
uses: ./.github/actions/start-app
with:
python-version: ${{ inputs.python_version }}
- name: Set environment variables
run: make env-test-ci
- name: "Run schema validation tests"
run: make test-schema
- name: "Upload schema test results"
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: schema-test-results
path: gateway-api/test-artefacts/
retention-days: 30
- name: "Publish schema test results to summary"
if: always()
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: gateway-api/test-artefacts/schema-tests.xml
test-integration:
name: "Integration tests"
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: "Checkout code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: "Setup Python project"
uses: ./.github/actions/setup-python-project
with:
python-version: ${{ inputs.python_version }}
- name: "Start app"
uses: ./.github/actions/start-app
with:
python-version: ${{ inputs.python_version }}
- name: Set environment variables
run: make env-test-ci
- name: "Run integration test"
run: make test-integration
- name: "Upload integration test results"
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: integration-test-results
path: gateway-api/test-artefacts/
retention-days: 30
- name: "Publish integration test results to summary"
if: always()
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: gateway-api/test-artefacts/integration-tests.xml
test-acceptance:
name: "Acceptance tests"
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: "Checkout code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: "Setup Python project"
uses: ./.github/actions/setup-python-project
with:
python-version: ${{ inputs.python_version }}
- name: "Start app"
uses: ./.github/actions/start-app
with:
python-version: ${{ inputs.python_version }}
max-seconds: 90
- name: Set environment variables
run: make env-test-ci
- name: "Run acceptance test"
run: make test-acceptance
- name: "Upload acceptance test results"
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: acceptance-test-results
path: gateway-api/test-artefacts/
retention-days: 30
- name: "Publish acceptance test results to summary"
if: always()
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: gateway-api/test-artefacts/acceptance-tests.xml
merge-test-coverage:
name: "Merge test coverage"
needs:
[
create-coverage-name,
test-unit,
test-contract,
test-schema,
test-integration,
test-acceptance,
]
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: "Checkout code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: "Setup Python project"
uses: ./.github/actions/setup-python-project
with:
python-version: ${{ inputs.python_version }}
- name: "Download all test coverage artefacts"
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: gateway-api/test-artefacts/
merge-multiple: false
- name: "Merge coverage data"
run: make test-coverage
- name: "Rename coverage XML with unique name"
run: |
cd gateway-api/test-artefacts
mv coverage-merged.xml ${{ needs.create-coverage-name.outputs.coverage-name }}.xml
- name: "Upload combined coverage report"
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ needs.create-coverage-name.outputs.coverage-name }}
path: gateway-api/test-artefacts
retention-days: 30
sonarcloud-analysis:
name: "SonarCloud Analysis"
needs: [create-coverage-name, merge-test-coverage]
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: "Checkout code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0 # Full history is needed for better analysis
- name: "Download merged coverage report"
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ needs.create-coverage-name.outputs.coverage-name }}
path: coverage-reports/
- name: "SonarCloud Scan"
uses: SonarSource/sonarqube-scan-action@299e4b793aaa83bf2aba7c9c14bedbb485688ec4
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.organization=${{ vars.SONAR_ORGANISATION_KEY }}
-Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }}
-Dsonar.python.coverage.reportPaths=coverage-reports/${{ needs.create-coverage-name.outputs.coverage-name }}.xml