-
Notifications
You must be signed in to change notification settings - Fork 2
170 lines (161 loc) · 5.36 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
name: check
on: [push]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/e2e
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
- run: npm ci
working-directory: react
- run: npx eslint .
working-directory: react
build-and-push-image:
runs-on: ubuntu-22.04
outputs:
image_tag: ${{ steps.meta.outputs.tags }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: react/test/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ steps.meta.outputs.tags }}
cache-to: type=inline
build-frontend:
runs-on: ubuntu-22.04
needs: build-and-push-image
container:
image: ghcr.io/${{ needs.build-and-push-image.outputs.image_tag }}
steps:
- uses: actions/checkout@v4
- run: python3 create_website.py react/test/density-db --no-data --no-geo --no-juxta
- 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-image, build-frontend, list-e2e-tests]
container:
image: ghcr.io/${{ needs.build-and-push-image.outputs.image_tag }}
strategy:
fail-fast: false
matrix:
test-file: ${{ fromJson(needs.list-e2e-tests.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: frontend-build
path: react/test/density-db
- name: Run tests
run: |
# Start display subsystem to browser can run
Xvfb :10 -ac &
export DISPLAY=:10
fluxbox >/dev/null 2>&1 & # needed for window resizing in Testcafe
npm ci
npx ts-node test/ci_proxy.ts &
npx testcafe -e "chromium '--window-size=1400,800' --hide-scrollbars --disable-gpu" \
-s thumbnails=false \
--video videos \
test/${{ matrix.test-file }}.ts
working-directory: react
- uses: actions/upload-artifact@v4
if: "!cancelled()"
with:
name: screenshots-${{ matrix.test-file }}
path: react/screenshots
- uses: actions/upload-artifact@v4
if: "!cancelled()"
with:
name: videos-${{ matrix.test-file }}
path: react/videos
check-screenshots:
runs-on: ubuntu-22.04
needs: [build-and-push-image, list-e2e-tests, run-e2e-tests]
if: ${{ !cancelled() && needs.build-and-push-image.result == 'success' && needs.list-e2e-tests.result == 'success' }} # Should run even if e2e tests fail
container:
image: ghcr.io/${{ needs.build-and-push-image.outputs.image_tag }}
strategy:
fail-fast: false
matrix:
test-file: ${{ fromJson(needs.list-e2e-tests.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: screenshots-${{ matrix.test-file }}
path: react/screenshots
continue-on-error: true
- name: Check screenshots
run: python3 tests/check_images.py --test=${{ matrix.test-file }}
- 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, check-screenshots]
if: "!cancelled()"
steps:
- uses: actions/upload-artifact/merge@v4
with:
name: screenshots
pattern: "screenshots-*"
- 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: "{screenshots,delta,changed_screenshots}"
separate-directories: true