-
Notifications
You must be signed in to change notification settings - Fork 100
266 lines (225 loc) · 8.14 KB
/
behave.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
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
name: Test Councils
on:
workflow_dispatch:
push:
paths-ignore:
- "wiki/**"
- "**/*.md"
- "uk_bin_collection_api_server/**"
branches: [ "master" ]
pull_request:
paths-ignore:
- "wiki/**"
- "**/*.md"
- "uk_bin_collection_api_server/**"
branches: [ "master" ]
schedule:
- cron: '0 0 * * *' # Nightly schedule for full test run
jobs:
setup:
name: Setup Environment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==1.8.4
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install Dependencies
run: make install-dev
- name: Lint JSON
run: jq empty uk_bin_collection/tests/input.json
- name: Get All Council Files That Have Changed
id: changed-council-files
uses: tj-actions/changed-files@v45
with:
files: |
uk_bin_collection/uk_bin_collection/councils/**.py
- name: Set Council Tests Environment Variable
id: set-council-tests
run: |
IFS=' ' read -ra FILES <<< "${{ steps.changed-council-files.outputs.all_changed_files }}"
COUNCIL_TESTS=""
for file in "${FILES[@]}"; do
FILENAME=$(basename "$file" .py)
if [ -z "$COUNCIL_TESTS" ]; then
COUNCIL_TESTS="$FILENAME"
else
COUNCIL_TESTS="$COUNCIL_TESTS or $FILENAME"
fi
done
echo "council_tests=$COUNCIL_TESTS" >> $GITHUB_OUTPUT
outputs:
council_tests: ${{ steps.set-council-tests.outputs.council_tests }}
unit-tests:
name: Run Unit Tests
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12]
poetry-version: [1.8.4]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: pipx install poetry==${{ matrix.poetry-version }}
- name: Install Dependencies
run: make install-dev
- name: Run Unit Tests
run: make unit-tests
- name: Upload Test Results to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.xml
parity-check:
name: Parity Check
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12]
poetry-version: [1.8.4]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: pipx install poetry==${{ matrix.poetry-version }}
- name: Install Dependencies
run: make install-dev
- name: Check Parity of Councils / input.json / Feature file
run: |
repo=${{ github.event.pull_request.head.repo.full_name || 'robbrad/UKBinCollectionData' }}
branch=${{ github.event.pull_request.head.ref || 'master' }}
make parity-check repo=$repo branch=$branch
integration-tests:
name: Run Integration Tests
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12]
poetry-version: [1.8.4]
services:
selenium:
image: selenium/standalone-chrome:latest
options: --shm-size=2gb --name selenium --hostname selenium
ports:
- 4444:4444
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: pipx install poetry==${{ matrix.poetry-version }}
- name: Install Dependencies
run: make install-dev
- name: Run Integration Tests
env:
HEADLESS: True
COUNCIL_TESTS: ${{ needs.setup.outputs.council_tests }}
run: make matrix=${{ matrix.python-version }} councils="${{ env.COUNCIL_TESTS }}" integration-tests
continue-on-error: true
report:
name: Generate and Upload Reports
needs: [unit-tests, parity-check, integration-tests]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12]
steps:
- uses: actions/checkout@v4
# Fetch Allure History
- name: Get Allure history - Full Report
if: github.event_name == 'schedule' || github.event_name == 'push'
uses: actions/checkout@v4
continue-on-error: true
with:
ref: gh-pages
path: gh-pages/allure-full-history
- name: Get Allure history - Partial Report
if: github.event_name != 'schedule' && github.event_name != 'push'
uses: actions/checkout@v4
continue-on-error: true
with:
ref: gh-pages
path: gh-pages/allure-partial-history
# Generate Allure Reports
- name: Allure report action for Full Run
uses: simple-elf/allure-report-action@master
if: github.event_name == 'schedule' || github.event_name == 'push'
with:
allure_results: build/${{ matrix.python-version }}/allure-results
subfolder: ${{ matrix.python-version }}
allure_history: gh-pages/allure-full-history
keep_reports: 20
- name: Allure report action for Partial Run
uses: simple-elf/allure-report-action@master
if: github.event_name != 'schedule' && github.event_name != 'push'
with:
allure_results: build/${{ matrix.python-version }}/allure-results
subfolder: ${{ matrix.python-version }}
allure_history: gh-pages/allure-partial-history
keep_reports: 20
# Archive Reports
- name: Tar full report
if: github.event_name == 'schedule' || github.event_name == 'push'
run: tar -cvf allure_full_history_${{ matrix.python-version }}.tar gh-pages/allure-full-history/${{ matrix.python-version }}
- name: Tar partial report
if: github.event_name != 'schedule' && github.event_name != 'push'
run: tar -cvf allure_partial_history_${{ matrix.python-version }}.tar gh-pages/allure-partial-history/${{ matrix.python-version }}
# Upload Report Artifacts
- name: Upload artifact for Full Report
uses: actions/upload-artifact@v4
if: github.event_name == 'schedule' || github.event_name == 'push'
with:
name: allure_full_history_${{ matrix.python-version }}
path: allure_full_history_${{ matrix.python-version }}.tar
- name: Upload artifact for Partial Report
uses: actions/upload-artifact@v4
if: github.event_name != 'schedule' && github.event_name != 'push'
with:
name: allure_partial_history_${{ matrix.python-version }}
path: allure_partial_history_${{ matrix.python-version }}.tar
deploy:
name: Deploy Reports
runs-on: ubuntu-latest
needs: report
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/download-artifact@v4
name: Download Full Artifacts
with:
name: allure_full_history_3.12
path: allure-history/tars/full
- uses: actions/download-artifact@v4
name: Download Partial Artifacts
with:
name: allure_partial_history_3.12
path: allure-history/tars/partial
- name: Untar Full Reports
run: for i in allure-history/tars/full/*.tar; do tar -xvf "$i" -C allure-history/full ;done
- name: Untar Partial Reports
run: for i in allure-history/tars/partial/*.tar; do tar -xvf "$i" -C allure-history/partial ;done
- name: Remove Tar Reports
run: rm -rf allure-history/tars
- name: Deploy Full Report
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: allure-history/full
- name: Deploy Partial Report
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: allure-history/partial