-
Notifications
You must be signed in to change notification settings - Fork 38
208 lines (190 loc) · 7.64 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
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.19
- 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 -covermode=atomic -coverpkg ./... -p 1 -v -json $(go list ./... | grep -v tests-e2e) -coverprofile synccoverage.out 2>&1 | tee ./test-integration.log | gotestfmt
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]
services:
synapse:
# Custom image built from https://github.com/matrix-org/synapse/tree/v1.72.0/docker/complement with a dummy /complement/ca set
image: ghcr.io/matrix-org/synapse-service:v1.72.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.19
- 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: Run end-to-end tests
run: |
set -euo pipefail
./run-tests.sh -count=1 -v -json . 2>&1 | tee test-e2e-runner.log | gotestfmt
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:
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'
- name: Fetch layered build
run: scripts/ci/layered.sh
- 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/[email protected]
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