-
Notifications
You must be signed in to change notification settings - Fork 13.5k
295 lines (252 loc) · 10.3 KB
/
ci-test-e2e.yml
File metadata and controls
295 lines (252 loc) · 10.3 KB
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
name: Tests E2E
on:
workflow_call:
inputs:
node-version:
required: true
type: string
deno-version:
required: true
type: string
lowercase-repo:
required: true
type: string
gh-docker-tag:
required: true
type: string
enterprise-license:
type: string
transporter:
type: string
mongodb-version:
default: "['8.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
coverage:
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 }}-amd64
jobs:
test:
runs-on: ubuntu-24.04
env:
# if building for production on develop branch or release, add suffix for coverage images
DOCKER_TAG_SUFFIX_ROCKETCHAT: ${{ inputs.coverage == matrix.mongodb-version && (github.event_name == 'release' || github.ref == 'refs/heads/develop') && '-cov' || '' }}
MONGODB_VERSION: ${{ matrix.mongodb-version }}
COVERAGE_DIR: '/tmp/coverage/${{ startsWith(inputs.type, ''api'') && ''api'' || inputs.type }}'
COVERAGE_FILE_NAME: '${{ inputs.type }}-${{ matrix.shard }}.json'
COVERAGE_REPORTER: ${{ inputs.coverage == matrix.mongodb-version && 'json' || '' }}
strategy:
fail-fast: false
matrix:
mongodb-version: ${{ fromJSON(inputs.mongodb-version) }}
shard: ${{ fromJSON(inputs.shard) }}
name: MongoDB ${{ matrix.mongodb-version }}${{ inputs.coverage == matrix.mongodb-version && ' coverage' || '' }} (${{ matrix.shard }}/${{ inputs.total-shard }})
steps:
- name: Collect Workflow Telemetry
if: inputs.type == 'perf'
uses: catchpoint/workflow-telemetry-action@v2
with:
theme: dark
job_summary: true
comment_on_pr: false
- name: Setup kernel limits
run: |
echo "500 65535" > sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
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') && github.actor != 'dependabot[bot]'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
- uses: actions/checkout@v6
- name: Setup NodeJS
uses: ./.github/actions/setup-node
with:
node-version: ${{ inputs.node-version }}
deno-version: ${{ inputs.deno-version }}
cache-modules: true
install: true
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: rharkor/caching-for-turbo@v1.8
- uses: ./.github/actions/restore-packages
# Download Docker images from build artifacts
- name: Download Docker images
uses: actions/download-artifact@v8
if: github.event.pull_request.head.repo.full_name != github.repository && github.event_name != 'release' && github.ref != 'refs/heads/develop'
with:
pattern: ${{ inputs.release == 'ce' && 'docker-image-rocketchat-amd64-coverage' || 'docker-image-*-amd64-coverage' }}
path: /tmp/docker-images
merge-multiple: true
# Load Docker images
- name: Load Docker images
if: github.event.pull_request.head.repo.full_name != github.repository && github.event_name != 'release' && github.ref != 'refs/heads/develop'
shell: bash
run: |
set -o xtrace
# Load all downloaded images
for image_file in /tmp/docker-images/*.tar; do
if [ -f "$image_file" ]; then
echo "Loading image from $image_file"
docker load -i "$image_file"
rm "$image_file"
fi
done
# List loaded images
docker images
- name: Set DEBUG_LOG_LEVEL (debug enabled)
if: runner.debug == '1'
run: echo "DEBUG_LOG_LEVEL=2" >> $GITHUB_ENV
- name: Start httpbin container and wait for it to be ready
if: inputs.type == 'api' || inputs.type == 'api-livechat'
run: |
docker compose -f docker-compose-ci.yml up -d httpbin
- name: Prepare code coverage directory
run: |
set -o xtrace
mkdir -p $COVERAGE_DIR
chmod 777 $COVERAGE_DIR
- name: Start containers for CE
if: inputs.release == 'ce'
run: |
# when we are testing CE, we only need to start the rocketchat container
DEBUG_LOG_LEVEL=${DEBUG_LOG_LEVEL:-0} docker compose -f docker-compose-ci.yml up -d rocketchat --wait
- name: Start containers for EE
if: inputs.release == 'ee'
env:
ENTERPRISE_LICENSE: ${{ inputs.enterprise-license }}
TRANSPORTER: ${{ inputs.transporter }}
run: |
DEBUG_LOG_LEVEL=${DEBUG_LOG_LEVEL:-0} docker compose -f docker-compose-ci.yml up -d --wait
- uses: ./.github/actions/setup-playwright
if: inputs.type == 'ui'
- 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://httpbin'
IS_EE: ${{ inputs.release == 'ee' && 'true' || '' }}
run: |
set -o xtrace
npm run testapi
docker compose -f ../../docker-compose-ci.yml stop
ls -la $COVERAGE_DIR
exit $s
- name: E2E Test API (Livechat)
if: inputs.type == 'api-livechat'
working-directory: ./apps/meteor
env:
WEBHOOK_TEST_URL: 'http://httpbin'
IS_EE: ${{ inputs.release == 'ee' && 'true' || '' }}
run: |
set -o xtrace
npm run testapi:livechat
docker compose -f ../../docker-compose-ci.yml stop
ls -la $COVERAGE_DIR
exit $s
- name: E2E Test UI (${{ matrix.shard }}/${{ inputs.total-shard }})
if: inputs.type == 'ui'
env:
E2E_COVERAGE: ${{ inputs.coverage == matrix.mongodb-version && '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' && secrets.REPORTER_ROCKETCHAT_URL != '' && '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 }}
E2E_SHARD: ${{ matrix.shard }}
E2E_TOTAL_SHARD: ${{ inputs.total-shard }}
working-directory: ./apps/meteor
run: |
set -o xtrace
yarn prepare
yarn test:e2e --shard="$E2E_SHARD/$E2E_TOTAL_SHARD"
- name: Merge ui coverage files
if: inputs.type == 'ui' && inputs.coverage == matrix.mongodb-version
working-directory: ./apps/meteor
run: |
npx nyc merge .nyc_output ${COVERAGE_DIR}/${COVERAGE_FILE_NAME}
ls -la $COVERAGE_DIR || true
- name: Store playwright test trace
if: inputs.type == 'ui' && always()
uses: actions/upload-artifact@v7
with:
name: playwright-test-trace-${{ inputs.release }}-${{ matrix.mongodb-version }}-${{ matrix.shard }}
path: ./apps/meteor/tests/e2e/.playwright*
include-hidden-files: true
- name: Show server logs if E2E test failed
if: failure()
run: docker compose -f docker-compose-ci.yml logs rocketchat authorization-service queue-worker-service ddp-streamer-service account-service presence-service omnichannel-transcript-service
- name: Show mongo logs if E2E test failed
if: failure()
run: docker compose -f docker-compose-ci.yml logs mongo
- name: Store coverage
if: inputs.coverage == matrix.mongodb-version
uses: actions/upload-artifact@v7
with:
name: coverage-${{ inputs.type }}-${{ matrix.shard }}
path: /tmp/coverage
include-hidden-files: true