Skip to content

Commit 505bd2c

Browse files
committed
ci: matrix generation job
1 parent a71435c commit 505bd2c

1 file changed

Lines changed: 46 additions & 31 deletions

File tree

.github/workflows/ci.yml

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ concurrency:
2020

2121
env:
2222
TOOL_NODE_FLAGS: ${{ vars.TOOL_NODE_FLAGS }}
23+
DOCKER_BUILD_ARCHES_JSON: '["arm64","amd64"]'
24+
DOCKER_BUILD_SERVICES_JSON: '["authorization-service","queue-worker-service","ddp-streamer-service","account-service","presence-service","omnichannel-transcript-service","rocketchat"]'
25+
DOCKER_BUILD_EXTRA_COVERAGE_JSON: '[{"arch":"amd64","service":"rocketchat","type":"coverage"},{"arch":"arm64","service":"rocketchat","type":"coverage"}]'
26+
DOCKER_BUILD_FIPS_SERVICES_JSON: '["ddp-streamer-service","presence-service"]'
2327

2428
jobs:
2529
release-versions:
@@ -262,9 +266,48 @@ jobs:
262266
source-hash: ${{ needs.release-versions.outputs.source-hash }}
263267
type: ${{ matrix.type }}
264268

269+
build-gh-docker-matrix:
270+
name: ⚙️ Build Docker Matrix
271+
needs: [build]
272+
runs-on: ubuntu-24.04-arm
273+
outputs:
274+
matrix: ${{ steps.generate.outputs.matrix }}
275+
steps:
276+
- id: generate
277+
env:
278+
DOCKER_BUILD_ARCHES_JSON: ${{ env.DOCKER_BUILD_ARCHES_JSON }}
279+
DOCKER_BUILD_SERVICES_JSON: ${{ env.DOCKER_BUILD_SERVICES_JSON }}
280+
DOCKER_BUILD_EXTRA_COVERAGE_JSON: ${{ env.DOCKER_BUILD_EXTRA_COVERAGE_JSON }}
281+
DOCKER_BUILD_FIPS_SERVICES_JSON: ${{ env.DOCKER_BUILD_FIPS_SERVICES_JSON }}
282+
run: |
283+
node <<'NODE'
284+
const fs = require('node:fs');
285+
286+
const baseType = '${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}';
287+
const arches = JSON.parse(process.env.DOCKER_BUILD_ARCHES_JSON);
288+
const services = JSON.parse(process.env.DOCKER_BUILD_SERVICES_JSON);
289+
const extraCoverageRows = JSON.parse(process.env.DOCKER_BUILD_EXTRA_COVERAGE_JSON);
290+
const fipsServices = JSON.parse(process.env.DOCKER_BUILD_FIPS_SERVICES_JSON);
291+
292+
const include = [];
293+
for (const arch of arches) {
294+
for (const service of services) {
295+
include.push({ arch, service, type: baseType });
296+
}
297+
}
298+
299+
if (baseType === 'production') {
300+
include.push(...extraCoverageRows);
301+
}
302+
303+
include.push(...fipsServices.map((service) => ({ arch: 'amd64', service, type: 'fips' })));
304+
305+
fs.appendFileSync(process.env.GITHUB_OUTPUT, `matrix=${JSON.stringify({ include })}\n`);
306+
NODE
307+
265308
build-gh-docker:
266-
name: 🚢 Build Docker (${{ matrix.service }}-${{ matrix.type }}-${{ matrix.arch }})
267-
needs: [build, release-versions]
309+
name: 🚢 Build Docker (${{ matrix.service }}-${{ matrix.arch }}-${{ matrix.type }})
310+
needs: [build, build-gh-docker-matrix, release-versions]
268311
runs-on: ubuntu-24.04${{ matrix.arch == 'arm64' && '-arm' || '' }}
269312

270313
env:
@@ -273,35 +316,7 @@ jobs:
273316

274317
strategy:
275318
fail-fast: false
276-
matrix:
277-
arch: [arm64, amd64]
278-
service: [authorization-service, queue-worker-service, ddp-streamer-service, account-service, presence-service, omnichannel-transcript-service, rocketchat]
279-
type:
280-
# if running in a PR build with coverage
281-
- ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}
282-
exclude:
283-
# avoid duplicate rocketchat coverage rows in PRs (the include rows below handle coverage)
284-
- arch: amd64
285-
service: rocketchat
286-
type: ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || '' }}
287-
- arch: arm64
288-
service: rocketchat
289-
type: ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || '' }}
290-
include:
291-
# if not, build with coverage for tests
292-
- arch: amd64
293-
service: rocketchat
294-
type: coverage
295-
- arch: arm64
296-
service: rocketchat
297-
type: coverage
298-
# build dedicated FIPS images for FIPS test lanes
299-
- arch: amd64
300-
service: ddp-streamer-service
301-
type: fips
302-
- arch: amd64
303-
service: presence-service
304-
type: fips
319+
matrix: ${{ fromJSON(needs.build-gh-docker-matrix.outputs.matrix) }}
305320

306321
steps:
307322
- uses: actions/checkout@v6

0 commit comments

Comments
 (0)