-
Notifications
You must be signed in to change notification settings - Fork 4
198 lines (183 loc) · 5.98 KB
/
check.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
name: check
on:
push:
branches:
- master
pull_request:
env:
# This is used in ci_proxy, do not remove. It is necessary so that
# we can test against non-production data
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: ./.github/actions/node_modules
- run: npx eslint .
working-directory: react
build-and-push-common-image:
runs-on: ubuntu-22.04
outputs:
image: ${{ steps.image.outputs.image }}
permissions:
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: ./.github/actions/docker_image
with:
dockerfile: Dockerfile
token: ${{ secrets.GITHUB_TOKEN }}
id: image
build-and-push-e2e-image:
runs-on: ubuntu-22.04
outputs:
image: ${{ steps.image.outputs.image }}
permissions:
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: ./.github/actions/docker_image
with:
dockerfile: react/test/Dockerfile
token: ${{ secrets.GITHUB_TOKEN }}
id: image
lint-python:
runs-on: ubuntu-22.04
needs: build-and-push-common-image
container:
image: ${{ needs.build-and-push-common-image.outputs.image }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/python_environment
- name: Lint with pylint
run: python -m pylint --prefer-stubs=true urbanstats tests
- name: Check black
run: |
python -m isort urbanstats tests
python -m black urbanstats tests
# allow all directories. This is needed because git complains about git repositories outside the user directory
git config --global --add safe.directory '*'
# check if there are any changes
# if there are, print the diff and exit with an error
# this is needed because isort and black disagree on the formatting of some files, so we run both and check
# if there's a difference
bash -c '[ $(git status --porcelain --untracked-files=no | wc -c) -eq 0 ] || (git status; git diff; exit 1)'
test-python:
runs-on: ubuntu-22.04
needs: build-and-push-common-image
container:
image: ${{ needs.build-and-push-common-image.outputs.image }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/python_environment
- name: Test python code
run: python -m pytest tests
build-frontend:
runs-on: ubuntu-22.04
needs: build-and-push-common-image
container:
image: ${{ needs.build-and-push-common-image.outputs.image }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/python_environment
- uses: ./.github/actions/node_modules
- run: python3 create_website.py react/test/density-db --no-data --no-geo --no-juxta --mode=ci
- uses: actions/upload-artifact@v4
with:
name: frontend-build
path: react/test/density-db
list-e2e-tests:
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: echo "matrix=$(find . -name '*_test.ts' | jq -R -s -c 'gsub("\\./"; "") | gsub("\\.ts"; "") | split("\n")[:-1]')" >> $GITHUB_OUTPUT
working-directory: react/test
run-e2e-tests:
runs-on: ubuntu-22.04
needs: [build-and-push-e2e-image, build-frontend, list-e2e-tests]
container:
image: ${{ needs.build-and-push-e2e-image.outputs.image }}
strategy:
fail-fast: false
matrix:
test-file: ${{ fromJson(needs.list-e2e-tests.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/python_environment
- uses: ./.github/actions/node_modules
- uses: actions/download-artifact@v4
with:
name: frontend-build
path: react/test/density-db
- name: Run tests
run: |
npm run test:e2e -- \
--proxy=true \
--browser=chromium \
--test=test/${{ matrix.test-file }}.ts \
--parallel=1 \
--headless=true \
--compare=true \
--time-limit-seconds=300
working-directory: react
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
if: "!cancelled()"
with:
name: delta-${{ matrix.test-file }}
path: react/delta
- uses: actions/upload-artifact@v4
if: "!cancelled()"
with:
name: changed_screenshots-${{ matrix.test-file }}
path: react/changed_screenshots
merge-screenshots:
runs-on: ubuntu-22.04
needs: [run-e2e-tests]
if: "!cancelled()"
steps:
- uses: actions/upload-artifact/merge@v4
with:
name: delta
pattern: "delta-*"
continue-on-error: true
- uses: actions/upload-artifact/merge@v4
with:
name: changed_screenshots
pattern: "changed_screenshots-*"
continue-on-error: true
- uses: actions/upload-artifact/merge@v4
with:
name: combined
pattern: "{delta,changed_screenshots}"
separate-directories: true
continue-on-error: true
run-unit-tests:
runs-on: ubuntu-22.04
needs: [build-and-push-common-image, build-frontend]
container:
image: ${{ needs.build-and-push-common-image.outputs.image }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/node_modules
- uses: actions/download-artifact@v4
with:
name: frontend-build
path: react/test/density-db
- name: Run tests
run: |
npm run test:unit -- \
--proxy=true
working-directory: react
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}