forked from RocketChat/Rocket.Chat
-
Notifications
You must be signed in to change notification settings - Fork 0
332 lines (294 loc) · 11.6 KB
/
ci-test-e2e.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
name: Tests E2E
on:
workflow_call:
inputs:
node-version:
required: true
type: string
lowercase-repo:
required: true
type: string
rc-dockerfile:
required: true
type: string
rc-docker-tag:
required: true
type: string
rc-dockerfile-alpine:
required: true
type: string
rc-docker-tag-alpine:
required: true
type: string
gh-docker-tag:
required: true
type: string
enterprise-license:
type: string
transporter:
type: string
mongodb-version:
default: "['4.4', '6.0']"
required: false
type: string
release:
required: true
type: string
shard:
default: '[1]'
required: false
type: string
total-shard:
default: 1
required: false
type: number
retries:
default: 0
required: false
type: number
type:
required: true
type: string
db-watcher-disabled:
default: 'false'
required: false
type: string
secrets:
CR_USER:
required: true
CR_PAT:
required: true
QASE_API_TOKEN:
required: false
REPORTER_ROCKETCHAT_URL:
required: false
REPORTER_ROCKETCHAT_API_KEY:
required: false
CODECOV_TOKEN:
required: false
REPORTER_JIRA_ROCKETCHAT_API_KEY:
required: false
env:
MONGO_URL: mongodb://localhost:27017/rocketchat?replicaSet=rs0&directConnection=true
TOOL_NODE_FLAGS: ${{ vars.TOOL_NODE_FLAGS }}
LOWERCASE_REPOSITORY: ${{ inputs.lowercase-repo }}
DOCKER_TAG: ${{ inputs.gh-docker-tag }}
jobs:
test:
runs-on: ubuntu-20.04
env:
RC_DOCKERFILE: ${{ matrix.mongodb-version == '6.0' && inputs.rc-dockerfile-alpine || inputs.rc-dockerfile }}
RC_DOCKER_TAG: ${{ matrix.mongodb-version == '6.0' && inputs.rc-docker-tag-alpine || inputs.rc-docker-tag }}
strategy:
fail-fast: false
matrix:
mongodb-version: ${{ fromJSON(inputs.mongodb-version) }}
shard: ${{ fromJSON(inputs.shard) }}
name: MongoDB ${{ matrix.mongodb-version }}${{ inputs.db-watcher-disabled == 'true' && ' [no watchers]' || '' }} (${{ matrix.shard }}/${{ inputs.total-shard }})${{ matrix.mongodb-version == '6.0' && ' - Alpine' || '' }}
steps:
- name: Collect Workflow Telemetry
uses: catchpoint/workflow-telemetry-action@v2
with:
theme: dark
job_summary: true
comment_on_pr: false
- name: Setup kernel limits
run: |
sudo sysctl -w net.ipv4.ip_local_port_range="500 65535"
sudo sysctl -w net.ipv4.tcp_mem="383865 511820 2303190"
echo fs.file-max=20000500 | sudo tee -a /etc/sysctl.conf
echo fs.nr_open=20000500 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
- name: Login to GitHub Container Registry
if: (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop')
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
- name: Launch MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-replica-set: rs0
- uses: actions/checkout@v4
- name: Setup NodeJS
uses: ./.github/actions/setup-node
with:
node-version: ${{ inputs.node-version }}
cache-modules: true
install: true
- uses: rharkor/[email protected]
- run: yarn build
# if we are testing a PR from a fork, we need to build the docker image at this point
- uses: ./.github/actions/build-docker
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
with:
CR_USER: ${{ secrets.CR_USER }}
CR_PAT: ${{ secrets.CR_PAT }}
node-version: ${{ inputs.node-version }}
# we already called the turbo cache at this point, so it should be false
turbo-cache: false
# the same reason we need to rebuild the docker image at this point is the reason we dont want to publish it
publish-image: false
setup: false
- name: Start httpbin container and wait for it to be ready
if: inputs.type == 'api'
run: |
docker run -d -p 10000:80 --name httpbin-container kennethreitz/httpbin
i=0
while [ $i -lt 10 ]; do
if curl -s -o /dev/null http://localhost:10000; then
echo "httpbin is running"
break
fi
i=$((i + 1))
sleep 5
done
if [ $i -eq 10 ]; then
echo "Failed to verify httpbin is running"
exit 1
fi
- name: Prepare code coverage directory
if: inputs.release == 'ee'
run: |
mkdir -p /tmp/coverage
chmod 777 /tmp/coverage
- name: Start containers for CE
if: inputs.release == 'ce'
env:
MONGO_URL: 'mongodb://host.docker.internal:27017/rocketchat?replicaSet=rs0&directConnection=true'
run: |
# when we are testing CE, we only need to start the rocketchat container
docker compose -f docker-compose-ci.yml up -d rocketchat
- name: Start containers for EE
if: inputs.release == 'ee'
env:
MONGO_URL: 'mongodb://host.docker.internal:27017/rocketchat?replicaSet=rs0&directConnection=true'
ENTERPRISE_LICENSE: ${{ inputs.enterprise-license }}
TRANSPORTER: ${{ inputs.transporter }}
COVERAGE_DIR: '/tmp/coverage'
COVERAGE_REPORTER: 'lcov'
DISABLE_DB_WATCHERS: ${{ inputs.db-watcher-disabled }}
run: |
docker compose -f docker-compose-ci.yml up -d
- name: Cache Playwright binaries
if: inputs.type == 'ui'
uses: actions/cache@v3
id: cache-playwright
with:
path: |
~/.cache/ms-playwright
# This is the version of Playwright that we are using, if you are willing to upgrade, you should update this.
key: playwright-1.40.1
- name: Install Playwright
if: inputs.type == 'ui' && steps.cache-playwright.outputs.cache-hit != 'true'
working-directory: ./apps/meteor
run: npx playwright install --with-deps
- name: Wait for Rocket.Chat to start up
uses: cygnetdigital/[email protected]
with:
url: 'http://localhost:3000/health'
responseCode: '200'
timeout: 60000
interval: 1000
- name: Wait services to start up
if: inputs.release == 'ee'
run: |
docker ps
until echo "$(docker compose -f docker-compose-ci.yml logs ddp-streamer-service)" | grep -q "NetworkBroker started successfully"; do
echo "Waiting 'ddp-streamer' to start up"
((c++)) && ((c==10)) && docker compose -f docker-compose-ci.yml logs ddp-streamer-service && exit 1
sleep 10
done;
- name: Remove unused Docker images
run: docker system prune -af
- name: E2E Test API
if: inputs.type == 'api'
working-directory: ./apps/meteor
env:
WEBHOOK_TEST_URL: 'http://host.docker.internal:10000'
IS_EE: ${{ inputs.release == 'ee' && 'true' || '' }}
COVERAGE_DIR: '/tmp/coverage'
COVERAGE_REPORTER: 'lcovonly'
run: |
for i in $(seq 1 2); do
npm run testapi && s=0 && break || s=$?
docker compose -f ../../docker-compose-ci.yml logs --tail=100
docker compose -f ../../docker-compose-ci.yml stop
docker exec mongodb bash -c 'if command -v mongosh ; then mongosh --eval "use rocketchat" --eval "db.dropDatabase()" rocketchat; else mongo rocketchat --eval "db.dropDatabase()"; fi'
NOW=$(date "+%Y-%m-%dT%H:%M:%S.000Z")
docker compose -f ../../docker-compose-ci.yml restart
until echo "$(docker compose -f ../../docker-compose-ci.yml logs rocketchat --since $NOW)" | grep -q "SERVER RUNNING"; do
echo "Waiting Rocket.Chat to start up"
((c++)) && ((c==10)) && exit 1
sleep 10
done;
done;
docker compose -f ../../docker-compose-ci.yml stop
ls -l $COVERAGE_DIR
exit $s
- name: E2E Test UI (${{ matrix.shard }}/${{ inputs.total-shard }})
if: inputs.type == 'ui'
env:
E2E_COVERAGE: ${{ inputs.release == 'ee' && 'true' || '' }}
IS_EE: ${{ inputs.release == 'ee' && 'true' || '' }}
REPORTER_ROCKETCHAT_API_KEY: ${{ secrets.REPORTER_ROCKETCHAT_API_KEY }}
REPORTER_ROCKETCHAT_URL: ${{ secrets.REPORTER_ROCKETCHAT_URL }}
REPORTER_JIRA_ROCKETCHAT_API_KEY: ${{ secrets.REPORTER_JIRA_ROCKETCHAT_API_KEY }}
REPORTER_ROCKETCHAT_REPORT: ${{ github.event.pull_request.draft != 'true' && 'true' || '' }}
REPORTER_ROCKETCHAT_RUN: ${{ github.run_number }}
REPORTER_ROCKETCHAT_BRANCH: ${{ github.ref }}
REPORTER_ROCKETCHAT_DRAFT: ${{ github.event.pull_request.draft }}
REPORTER_ROCKETCHAT_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
REPORTER_ROCKETCHAT_AUTHOR: ${{ github.event.pull_request.user.login }}
REPORTER_ROCKETCHAT_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
REPORTER_ROCKETCHAT_PR: ${{ github.event.pull_request.number }}
QASE_API_TOKEN: ${{ secrets.QASE_API_TOKEN }}
QASE_REPORT: ${{ github.ref == 'refs/heads/develop' && 'true' || '' }}
CI: true
PLAYWRIGHT_RETRIES: ${{ inputs.retries }}
working-directory: ./apps/meteor
run: |
yarn prepare
yarn test:e2e --shard=${{ matrix.shard }}/${{ inputs.total-shard }}
- name: Store playwright test trace
if: inputs.type == 'ui' && always()
uses: actions/upload-artifact@v4
with:
name: playwright-test-trace-${{ matrix.mongodb-version }}-${{ matrix.shard }}
path: ./apps/meteor/tests/e2e/.playwright*
- name: Show server logs if E2E test failed
if: failure()
run: docker compose -f docker-compose-ci.yml logs rocketchat
- name: Extract e2e:ee:coverage
if: inputs.type == 'ui' && inputs.release == 'ee'
working-directory: ./apps/meteor
run: yarn test:e2e:nyc
- uses: codecov/codecov-action@v3
if: inputs.type == 'ui' && inputs.release == 'ee'
with:
directory: ./apps/meteor
flags: e2e
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
- uses: codecov/codecov-action@v3
if: inputs.type == 'api' && inputs.release == 'ee'
with:
directory: /tmp/coverage
working-directory: .
flags: e2e-api
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Store e2e-api-ee-coverage
if: inputs.type == 'api' && inputs.release == 'ee'
uses: actions/upload-artifact@v4
with:
name: e2e-api-ee-coverage-${{ matrix.mongodb-version }}-${{ matrix.shard }}
path: /tmp/coverage
- name: Store e2e-ee-coverage
if: inputs.type == 'ui' && inputs.release == 'ee'
uses: actions/upload-artifact@v4
with:
name: e2e-ee-coverage-${{ matrix.mongodb-version }}-${{ matrix.shard }}
path: ./apps/meteor/coverage*