Skip to content

Commit 4085cf7

Browse files
authored
chore(ci): reduce number of parallel jobs and improve container builds (RocketChat#37466)
1 parent 901ba0c commit 4085cf7

16 files changed

Lines changed: 399 additions & 241 deletions

File tree

.github/actions/build-docker/action.yml

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
name: 'Meteor Docker'
1+
name: 'Build Docker'
22

33
inputs:
44
CR_USER:
55
required: true
66
CR_PAT:
77
required: true
8-
node-version:
9-
required: true
10-
description: 'Node version'
11-
type: string
128
deno-version:
139
required: true
1410
description: 'Deno version'
@@ -25,13 +21,10 @@ inputs:
2521
required: false
2622
description: 'Publish image'
2723
default: 'true'
28-
setup:
29-
required: false
30-
description: 'Setup node.js'
31-
default: 'true'
32-
NPM_TOKEN:
24+
setup-docker:
3325
required: false
34-
description: 'NPM token'
26+
description: 'Setup Docker'
27+
default: true
3528
type:
3629
required: false
3730
description: 'production or coverage'
@@ -49,17 +42,6 @@ runs:
4942
username: ${{ inputs.CR_USER }}
5043
password: ${{ inputs.CR_PAT }}
5144

52-
- name: Restore packages build
53-
uses: actions/download-artifact@v6
54-
with:
55-
name: packages-build
56-
path: /tmp
57-
58-
- name: Unpack packages build
59-
shell: bash
60-
run: |
61-
tar -xzf /tmp/RocketChat-packages-build.tar.gz -C .
62-
6345
- name: Restore meteor build
6446
if: inputs.service == 'rocketchat'
6547
uses: actions/download-artifact@v6
@@ -76,20 +58,17 @@ runs:
7658
rm Rocket.Chat.tar.gz
7759
7860
- name: Set up Docker
61+
if: inputs.setup-docker == true
7962
uses: docker/setup-docker-action@v4
8063
with:
8164
daemon-config: |
8265
{
83-
"debug": true,
66+
"debug": false,
8467
"features": {
8568
"containerd-snapshotter": true
8669
}
8770
}
8871
89-
- uses: docker/setup-buildx-action@v3
90-
with:
91-
buildkitd-flags: --oci-worker-gc --oci-worker-gc-keepstorage=4000
92-
9372
- name: Build Docker images
9473
shell: bash
9574
run: |
@@ -122,10 +101,12 @@ runs:
122101
echo "Contents of /tmp/meta.json:"
123102
cat /tmp/meta.json
124103
125-
mkdir -p /tmp/digests/${{ inputs.service }}${{ inputs.type == 'coverage' && '-cov' || '' }}/${{ inputs.arch }}
104+
SERVICE_SUFFIX=${{ inputs.service == 'rocketchat' && inputs.type == 'coverage' && (github.event_name == 'release' || github.ref == 'refs/heads/develop') && '-cov' || '' }}
105+
106+
mkdir -p /tmp/digests/${{ inputs.service }}${SERVICE_SUFFIX}/${{ inputs.arch }}
126107
DIGEST=$(jq -r '.["${{ inputs.service }}"].["containerimage.digest"]' "/tmp/meta.json")
127108
IMAGE_NO_TAG=$(echo "$IMAGE" | sed 's/:.*$//')
128-
echo "${IMAGE_NO_TAG}@${DIGEST}" > "/tmp/digests/${{ inputs.service }}${{ inputs.type == 'coverage' && '-cov' || '' }}/${{ inputs.arch }}/digest.txt"
109+
echo "${IMAGE_NO_TAG}@${DIGEST}" > "/tmp/digests/${{ inputs.service }}${SERVICE_SUFFIX}/${{ inputs.arch }}/digest.txt"
129110
130111
- uses: actions/upload-artifact@v4
131112
if: inputs.publish-image == 'true'

.github/actions/meteor-build/action.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ runs:
3434
id: cache-build
3535
with:
3636
path: /tmp/Rocket.Chat.tar.gz
37-
key: ${{ runner.OS }}-rc-build-${{ inputs.source-hash }}
38-
restore-keys: |
39-
${{ runner.os }}-rc-build-
37+
key: ${{ runner.os }}-${{ runner.arch }}-${{ inputs.type }}-rc-build-${{ inputs.source-hash }}
4038

4139
- name: Set Swap Space
4240
uses: pierotofy/set-swap-space@master
@@ -65,27 +63,27 @@ runs:
6563
if: steps.cache-build.outputs.cache-hit != 'true'
6664
with:
6765
path: ./node_modules/.vite
68-
key: vite-local-cache-${{ runner.OS }}-${{ hashFiles('package.json') }}
66+
key: vite-local-cache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
6967
restore-keys: |
70-
vite-local-cache-${{ runner.os }}-
68+
vite-local-cache-${{ runner.os }}-${{ runner.arch }}-
7169
7270
- name: Cache meteor local
7371
uses: actions/cache@v3
7472
if: steps.cache-build.outputs.cache-hit != 'true'
7573
with:
7674
path: ./apps/meteor/.meteor/local
77-
key: meteor-local-cache-${{ runner.OS }}-${{ hashFiles('apps/meteor/.meteor/versions') }}
75+
key: meteor-local-cache-${{ runner.os }}-${{ runner.arch }}-${{ inputs.type }}-${{ hashFiles('apps/meteor/.meteor/versions') }}
7876
restore-keys: |
79-
meteor-local-cache-${{ runner.os }}-
77+
meteor-local-cache-${{ runner.os }}-${{ runner.arch }}-${{ inputs.type }}-
8078
8179
- name: Cache meteor
8280
uses: actions/cache@v3
8381
if: steps.cache-build.outputs.cache-hit != 'true'
8482
with:
8583
path: ~/.meteor
86-
key: meteor-cache-${{ runner.OS }}-${{ hashFiles('apps/meteor/.meteor/release') }}
84+
key: meteor-cache-${{ runner.os }}-${{ runner.arch }}-${{ inputs.type }}-${{ hashFiles('apps/meteor/.meteor/release') }}
8785
restore-keys: |
88-
meteor-cache-${{ runner.os }}-
86+
meteor-cache-${{ runner.os }}-${{ runner.arch }}-${{ inputs.type }}-
8987
9088
- name: Install Meteor
9189
shell: bash

.github/actions/setup-playwright/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ runs:
1111
path: |
1212
~/.cache/ms-playwright
1313
# This is the version of Playwright that we are using, if you are willing to upgrade, you should update this.
14-
key: playwright-1.52.0
14+
key: playwright-${{ runner.os }}-${{ runner.arch }}-1.52.0
1515

1616
- name: Install Playwright
1717
shell: bash
1818
if: steps.cache-playwright.outputs.cache-hit != 'true'
1919
working-directory: .
2020
run: npx playwright install --with-deps
21-

.github/workflows/ci-test-e2e.yml

Lines changed: 27 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
transporter:
2121
type: string
2222
mongodb-version:
23-
default: "['5.0', '8.2']"
23+
default: "['8.2']"
2424
required: false
2525
type: string
2626
release:
@@ -41,6 +41,9 @@ on:
4141
type:
4242
required: true
4343
type: string
44+
coverage:
45+
required: false
46+
type: string
4447
db-watcher-disabled:
4548
default: 'true'
4649
required: false
@@ -66,12 +69,16 @@ env:
6669
TOOL_NODE_FLAGS: ${{ vars.TOOL_NODE_FLAGS }}
6770
LOWERCASE_REPOSITORY: ${{ inputs.lowercase-repo }}
6871
DOCKER_TAG: ${{ inputs.gh-docker-tag }}
69-
DOCKER_TAG_SUFFIX_ROCKETCHAT: '-cov'
7072

7173
jobs:
7274
test:
7375
runs-on: ubuntu-24.04
7476

77+
env:
78+
# if building for production on develop branch or release, add suffix for coverage images
79+
DOCKER_TAG_SUFFIX_ROCKETCHAT: ${{ inputs.coverage == matrix.mongodb-version && (github.event_name == 'release' || github.ref == 'refs/heads/develop') && '-cov' || '' }}
80+
MONGODB_VERSION: ${{ matrix.mongodb-version }}
81+
7582
strategy:
7683
fail-fast: false
7784
matrix:
@@ -105,13 +112,6 @@ jobs:
105112
username: ${{ secrets.CR_USER }}
106113
password: ${{ secrets.CR_PAT }}
107114

108-
- name: Launch MongoDB
109-
uses: supercharge/mongodb-github-action@1.12.0
110-
with:
111-
mongodb-image: mongodb/mongodb-community-server
112-
mongodb-version: ${{ matrix.mongodb-version }}-ubi8
113-
mongodb-replica-set: rs0
114-
115115
- uses: actions/checkout@v5
116116

117117
- name: Setup NodeJS
@@ -142,12 +142,9 @@ jobs:
142142
with:
143143
CR_USER: ${{ secrets.CR_USER }}
144144
CR_PAT: ${{ secrets.CR_PAT }}
145-
node-version: ${{ inputs.node-version }}
146145
# the same reason we need to rebuild the docker image at this point is the reason we dont want to publish it
147146
publish-image: false
148-
setup: false
149147
service: 'rocketchat'
150-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
151148

152149
- name: Set DEBUG_LOG_LEVEL (debug enabled)
153150
if: runner.debug == '1'
@@ -156,58 +153,34 @@ jobs:
156153
- name: Start httpbin container and wait for it to be ready
157154
if: inputs.type == 'api'
158155
run: |
159-
docker run -d -p 10000:80 --name httpbin-container kennethreitz/httpbin
160-
i=0
161-
while [ $i -lt 10 ]; do
162-
if curl -s -o /dev/null http://localhost:10000; then
163-
echo "httpbin is running"
164-
break
165-
fi
166-
i=$((i + 1))
167-
sleep 5
168-
done
169-
if [ $i -eq 10 ]; then
170-
echo "Failed to verify httpbin is running"
171-
exit 1
172-
fi
156+
docker compose -f docker-compose-ci.yml up -d httpbin
173157
174158
- name: Prepare code coverage directory
175-
if: inputs.release == 'ee'
159+
if: inputs.coverage == matrix.mongodb-version
176160
run: |
177161
mkdir -p /tmp/coverage
178162
chmod 777 /tmp/coverage
179163
180164
- name: Start containers for CE
181165
if: inputs.release == 'ce'
182-
env:
183-
MONGO_URL: 'mongodb://host.docker.internal:27017/rocketchat?replicaSet=rs0&directConnection=true'
184166
run: |
185167
# when we are testing CE, we only need to start the rocketchat container
186-
DEBUG_LOG_LEVEL=${DEBUG_LOG_LEVEL:-0} docker compose -f docker-compose-ci.yml up -d rocketchat
168+
DEBUG_LOG_LEVEL=${DEBUG_LOG_LEVEL:-0} docker compose -f docker-compose-ci.yml up -d rocketchat --wait
187169
188170
- name: Start containers for EE
189171
if: inputs.release == 'ee'
190172
env:
191-
MONGO_URL: 'mongodb://host.docker.internal:27017/rocketchat?replicaSet=rs0&directConnection=true'
192173
ENTERPRISE_LICENSE: ${{ inputs.enterprise-license }}
193174
TRANSPORTER: ${{ inputs.transporter }}
194175
COVERAGE_DIR: '/tmp/coverage'
195176
COVERAGE_REPORTER: 'lcov'
196177
DISABLE_DB_WATCHERS: ${{ inputs.db-watcher-disabled }}
197178
run: |
198-
DEBUG_LOG_LEVEL=${DEBUG_LOG_LEVEL:-0} docker compose -f docker-compose-ci.yml up -d
179+
DEBUG_LOG_LEVEL=${DEBUG_LOG_LEVEL:-0} docker compose -f docker-compose-ci.yml up -d --wait
199180
200181
- uses: ./.github/actions/setup-playwright
201182
if: inputs.type == 'ui'
202183

203-
- name: Wait for Rocket.Chat to start up
204-
uses: cygnetdigital/wait_for_response@v2.0.0
205-
with:
206-
url: 'http://localhost:3000/health'
207-
responseCode: '200'
208-
timeout: 60000
209-
interval: 1000
210-
211184
- name: Wait services to start up
212185
if: inputs.release == 'ee'
213186
run: |
@@ -226,30 +199,15 @@ jobs:
226199
if: inputs.type == 'api'
227200
working-directory: ./apps/meteor
228201
env:
229-
WEBHOOK_TEST_URL: 'http://host.docker.internal:10000'
202+
WEBHOOK_TEST_URL: 'http://httpbin'
230203
IS_EE: ${{ inputs.release == 'ee' && 'true' || '' }}
231204
COVERAGE_DIR: '/tmp/coverage'
232205
COVERAGE_REPORTER: 'lcovonly'
233206
run: |
234-
for i in $(seq 1 2); do
235-
npm run testapi && s=0 && break || s=$?
236-
237-
docker compose -f ../../docker-compose-ci.yml logs --tail=100
238-
239-
docker compose -f ../../docker-compose-ci.yml stop
207+
set -o xtrace
240208
241-
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'
209+
npm run testapi
242210
243-
NOW=$(date "+%Y-%m-%dT%H:%M:%S.000Z")
244-
245-
docker compose -f ../../docker-compose-ci.yml restart
246-
247-
until echo "$(docker compose -f ../../docker-compose-ci.yml logs rocketchat --since $NOW)" | grep -q "SERVER RUNNING"; do
248-
echo "Waiting Rocket.Chat to start up"
249-
((c++)) && ((c==10)) && exit 1
250-
sleep 10
251-
done;
252-
done;
253211
docker compose -f ../../docker-compose-ci.yml stop
254212
255213
ls -l $COVERAGE_DIR
@@ -258,7 +216,7 @@ jobs:
258216
- name: E2E Test UI (${{ matrix.shard }}/${{ inputs.total-shard }})
259217
if: inputs.type == 'ui'
260218
env:
261-
E2E_COVERAGE: ${{ inputs.release == 'ee' && 'true' || '' }}
219+
E2E_COVERAGE: ${{ inputs.coverage == matrix.mongodb-version && 'true' || '' }}
262220
IS_EE: ${{ inputs.release == 'ee' && 'true' || '' }}
263221
REPORTER_ROCKETCHAT_API_KEY: ${{ secrets.REPORTER_ROCKETCHAT_API_KEY }}
264222
REPORTER_ROCKETCHAT_URL: ${{ secrets.REPORTER_ROCKETCHAT_URL }}
@@ -289,28 +247,28 @@ jobs:
289247
include-hidden-files: true
290248

291249
- name: Show server logs if E2E test failed
292-
if: failure() && inputs.release == 'ee'
293-
run: docker compose -f docker-compose-ci.yml logs
250+
if: failure()
251+
run: docker compose -f docker-compose-ci.yml logs rocketchat authorization-service queue-worker-service ddp-streamer-service account-service presence-service stream-hub-service omnichannel-transcript-service
294252

295-
- name: Show server logs if E2E test failed
296-
if: failure() && inputs.release != 'ee'
297-
run: docker compose -f docker-compose-ci.yml logs rocketchat
253+
- name: Show mongo logs if E2E test failed
254+
if: failure()
255+
run: docker compose -f docker-compose-ci.yml logs mongo
298256

299257
- name: Extract e2e:ee:coverage
300-
if: inputs.type == 'ui' && inputs.release == 'ee'
258+
if: inputs.coverage == matrix.mongodb-version && inputs.type == 'ui'
301259
working-directory: ./apps/meteor
302260
run: yarn test:e2e:nyc
303261

304262
- uses: codecov/codecov-action@v3
305-
if: inputs.type == 'ui' && inputs.release == 'ee'
263+
if: inputs.coverage == matrix.mongodb-version && inputs.type == 'ui'
306264
with:
307265
directory: ./apps/meteor
308266
flags: e2e
309267
verbose: true
310268
token: ${{ secrets.CODECOV_TOKEN }}
311269

312270
- uses: codecov/codecov-action@v3
313-
if: inputs.type == 'api' && inputs.release == 'ee'
271+
if: inputs.coverage == matrix.mongodb-version && inputs.type == 'api'
314272
with:
315273
directory: /tmp/coverage
316274
working-directory: .
@@ -319,15 +277,15 @@ jobs:
319277
token: ${{ secrets.CODECOV_TOKEN }}
320278

321279
- name: Store e2e-api-ee-coverage
322-
if: inputs.type == 'api' && inputs.release == 'ee'
280+
if: inputs.coverage == matrix.mongodb-version && inputs.type == 'api'
323281
uses: actions/upload-artifact@v4
324282
with:
325283
name: e2e-api-ee-coverage-${{ matrix.mongodb-version }}-${{ matrix.shard }}
326284
path: /tmp/coverage
327285
include-hidden-files: true
328286

329287
- name: Store e2e-ee-coverage
330-
if: inputs.type == 'ui' && inputs.release == 'ee'
288+
if: inputs.coverage == matrix.mongodb-version && inputs.type == 'ui'
331289
uses: actions/upload-artifact@v4
332290
with:
333291
name: e2e-ee-coverage-${{ matrix.mongodb-version }}-${{ matrix.shard }}

0 commit comments

Comments
 (0)