-
Notifications
You must be signed in to change notification settings - Fork 38
358 lines (321 loc) · 13.5 KB
/
tests.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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
name: Tests
on:
push:
branches: ["main"]
pull_request:
permissions:
packages: read
# Note: from https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
# > If you specify the access for any of these scopes, all of those that are not specified are set to none.
jobs:
check-signoff:
if: "github.event_name == 'pull_request'"
uses: "matrix-org/backend-meta/.github/workflows/sign-off.yml@v2"
integration:
runs-on: ubuntu-latest
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:13-alpine
# Provide the password for postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: syncv3
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: Build
run: go build ./cmd/syncv3
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
# Note: constrained to `packages:read` only at the top of the file
token: ${{ secrets.GITHUB_TOKEN }}
- name: Test
run: |
set -euo pipefail
go test -count=1 -race -covermode=atomic -coverpkg ./... -p 1 -v -json $(go list ./... | grep -v tests-e2e) -coverprofile synccoverage.out 2>&1 | tee ./test-integration.log | gotestfmt -hide all
shell: bash
env:
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: syncv3
SYNCV3_DEBUG: "1"
SYNCV3_SECRET: itsasecret
- name: Coverage
run: go tool cover -func=synccoverage.out
- name: Check /client works
run: ./tests-e2e/client-check.sh
env:
SYNCV3_DB: user=postgres dbname=syncv3 sslmode=disable password=postgres host=localhost
SYNCV3_SERVER: https://matrix-client.matrix.org
SYNCV3_SECRET: itsasecret
- name: Upload test log
uses: actions/upload-artifact@v3
if: always()
with:
name: Integration test logs
path: ./test-integration.log
if-no-files-found: error
end_to_end:
runs-on: ubuntu-latest
strategy:
matrix:
# test with unlimited + 1 + 2 max db conns. If we end up double transacting in the tests anywhere, conn=1 tests will fail.
max_db_conns: [0,1,2]
# If the server fails to start, we'll wait for GHA to cancel the job after 6 hours.
# Ensure we fail sooner than that to avoid clogging up GHA runners.
timeout-minutes: 30
services:
synapse:
# Custom image built from https://github.com/matrix-org/synapse/tree/v1.94.0/docker/complement with a dummy /complement/ca set
image: ghcr.io/matrix-org/synapse-service:v1.94.0
env:
SYNAPSE_COMPLEMENT_DATABASE: sqlite
SERVER_NAME: synapse
ports:
- 8008:8008
# Set health checks to wait until synapse has started
options: >-
--health-interval 10s
--health-timeout 5s
--health-retries 5
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:13-alpine
# Provide the password for postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: syncv3
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: Build
run: go build ./cmd/syncv3
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
# Note: constrained to `packages:read` only at the top of the file
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install libolm
run: sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev
- name: Run end-to-end tests
run: |
set -euo pipefail
./run-tests.sh -count=1 -v -json . 2>&1 | tee test-e2e-runner.log | gotestfmt -hide all
working-directory: tests-e2e
shell: bash
env:
SYNCV3_DB: user=postgres dbname=syncv3 sslmode=disable password=postgres host=localhost
SYNCV3_SERVER: http://localhost:8008
SYNCV3_SECRET: itsasecret
SYNCV3_MAX_DB_CONN: ${{ matrix.max_db_conns }}
E2E_TEST_SERVER_STDOUT: test-e2e-server.log
- name: Upload test log
uses: actions/upload-artifact@v3
if: always()
with:
name: E2E test logs
path: |
./tests-e2e/test-e2e-runner.log
./tests-e2e/test-e2e-server.log
if-no-files-found: error
element_web:
# Cypress seems consistently unable to connect to its browser:
#
# Still waiting to connect to Chrome, retrying in 1 second (attempt 18/62)
# read ECONNRESET
# Error: read ECONNRESET
# at TCP.onStreamRead (node:internal/stream_base_commons:217:20)
#
# Disable this job for now---it's not useful at present.
if: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: "Build docker image"
env:
DOCKER_BUILDKIT: 1
run: docker build -f Dockerfile -t ghcr.io/matrix-org/sliding-sync:ci .
- uses: actions/checkout@v3
with:
repository: matrix-org/matrix-react-sdk
ref: "v3.71.0" # later versions break the SS E2E tests which need to be fixed :(
- uses: actions/setup-node@v3
with:
cache: 'yarn'
# we need this so we can use a tag instead of a branch name for JS_SDK_GITHUB_BASE_REF
# we also skip a flakey test
- name: Patch script
run: |
sed -i 's/git fetch --depth 1 origin $JS_SDK_GITHUB_BASE_REF/git fetch --depth 1 origin $JS_SDK_GITHUB_BASE_REF --tags/' scripts/ci/layered.sh
sed -i 's/it("should send unsubscribe_rooms for every room switch"/xit("should send unsubscribe_rooms for every room switch"/' cypress/e2e/sliding-sync/sliding-sync.ts
- name: Fetch layered build
run: scripts/ci/layered.sh
env:
JS_SDK_GITHUB_BASE_REF: "v25.0.0-rc.1"
- name: Copy config
run: cp element.io/develop/config.json config.json
working-directory: ./element-web
- name: Build
env:
CI_PACKAGE: true
run: yarn build
working-directory: ./element-web
- name: "Run cypress tests"
uses: cypress-io/github-action@v5.5.1
with:
browser: chrome
start: npx serve -p 8080 ./element-web/webapp
wait-on: 'http://localhost:8080'
spec: cypress/e2e/sliding-sync/*.ts
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
TMPDIR: ${{ runner.temp }}
CYPRESS_SLIDING_SYNC_PROXY_TAG: 'ci'
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-captures
path: |
cypress/screenshots
cypress/videos
upgrade-test:
runs-on: ubuntu-latest
env:
PREV_VERSION: "v0.99.4"
# If the server fails to start, we'll wait for GHA to cancel the job after 6 hours.
# Ensure we fail sooner than that to avoid clogging up GHA runners.
timeout-minutes: 30
# Service containers to run with `container-job`
services:
synapse:
# Custom image built from https://github.com/matrix-org/synapse/tree/v1.94.0/docker/complement with a dummy /complement/ca set
image: ghcr.io/matrix-org/synapse-service:v1.94.0
env:
SYNAPSE_COMPLEMENT_DATABASE: sqlite
SERVER_NAME: synapse
ports:
- 8008:8008
# Set health checks to wait until synapse has started
options: >-
--health-interval 10s
--health-timeout 5s
--health-retries 5
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:13-alpine
# Provide the password for postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: syncv3
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
# E2E tests with ${{env.PREV_VERSION}}
- uses: actions/checkout@v3
with:
ref: ${{env.PREV_VERSION}}
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
# Note: constrained to `packages:read` only at the top of the file
token: ${{ secrets.GITHUB_TOKEN }}
- name: Build ${{env.PREV_VERSION}}
run: go build ./cmd/syncv3
- name: Install libolm
run: sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev
- name: Run end-to-end tests
run: |
set -euo pipefail
./run-tests.sh -count=1 -v -json . 2>&1 | tee test-e2e-runner-${{env.PREV_VERSION}}.log | gotestfmt -hide all
working-directory: tests-e2e
shell: bash
env:
SYNCV3_DB: user=postgres dbname=syncv3 sslmode=disable password=postgres host=localhost
SYNCV3_SERVER: http://localhost:8008
SYNCV3_SECRET: itsasecret
SYNCV3_MAX_DB_CONN: ${{ matrix.max_db_conns }}
E2E_TEST_SERVER_STDOUT: test-e2e-server-${{env.PREV_VERSION}}.log
- name: Upload test log ${{env.PREV_VERSION}}
uses: actions/upload-artifact@v3
if: failure()
with:
name: E2E test logs upgrade ${{env.PREV_VERSION}}
path: |
./tests-e2e/test-e2e-runner-${{env.PREV_VERSION}}.log
./tests-e2e/test-e2e-server-${{env.PREV_VERSION}}.log
if-no-files-found: error
# E2E tests with current commit
- uses: actions/checkout@v3
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
# Note: constrained to `packages:read` only at the top of the file
token: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: go build ./cmd/syncv3
- name: Run end-to-end tests
run: |
set -euo pipefail
./run-tests.sh -count=1 -v -json . 2>&1 | tee test-e2e-runner.log | gotestfmt -hide all
working-directory: tests-e2e
shell: bash
env:
SYNCV3_DB: user=postgres dbname=syncv3 sslmode=disable password=postgres host=localhost
SYNCV3_SERVER: http://localhost:8008
SYNCV3_SECRET: itsasecret
SYNCV3_MAX_DB_CONN: ${{ matrix.max_db_conns }}
E2E_TEST_SERVER_STDOUT: test-e2e-server.log
- name: Upload test log
uses: actions/upload-artifact@v3
if: failure()
with:
name: E2E test logs upgrade
path: |
./tests-e2e/test-e2e-runner.log
./tests-e2e/test-e2e-server.log
if-no-files-found: error