Skip to content

Commit d6b3a64

Browse files
committed
feat: using Jest's shard option for test load balancing
We can use jest's `shard` option to implement test load balancing. This required updating to jest v28, as sharding was introduced in this version. For now the shard count is chosen manually and is statically set, however, this may be optimised in the future. Test load balancing is now utilised for both `test` and `build` (platform) pipelines.
1 parent 7c721e7 commit d6b3a64

File tree

6 files changed

+2116
-1800
lines changed

6 files changed

+2116
-1800
lines changed

.gitlab-ci.yml

Lines changed: 49 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,36 @@ check:nix-dry:
7272
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
7373
when: manual
7474

75-
check:test:
75+
check:test-generate:
7676
stage: check
77-
needs: []
7877
script:
78+
- mkdir -p ./tmp
7979
- >
8080
nix-shell --run '
81-
npm run build --verbose;
82-
npm test -- --ci --coverage;
81+
./scripts/test-pipelines.sh > ./tmp/test-pipelines.yml
8382
'
8483
artifacts:
8584
when: always
86-
reports:
87-
junit:
88-
- ./tmp/junit/junit.xml
89-
coverage_report:
90-
coverage_format: cobertura
91-
path: ./tmp/coverage/cobertura-coverage.xml
92-
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
85+
paths:
86+
- ./tmp/test-pipelines.yml
87+
rules:
88+
# Runs on staging commits and ignores version commits
89+
- if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
90+
# Manually run on commits other than master and staging and ignore version commits
91+
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
92+
when: manual
93+
94+
check:test:
95+
stage: check
96+
needs:
97+
- check:test-generate
98+
inherit:
99+
variables: false
100+
trigger:
101+
include:
102+
- artifact: tmp/test-pipelines.yml
103+
job: check:test-generate
104+
strategy: depend
93105
rules:
94106
# Runs on staging commits and ignores version commits
95107
- if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
@@ -125,94 +137,47 @@ build:merge:
125137
# Runs on tag pipeline where the tag is a prerelease or release version
126138
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
127139

128-
build:linux:
140+
build:build-generate:
129141
stage: build
130-
needs: []
131142
script:
143+
- mkdir -p ./tmp
132144
- >
133145
nix-shell --run '
134-
npm run build --verbose;
135-
npm test -- --ci --coverage;
146+
./scripts/build-pipelines.sh > ./tmp/build-pipelines.yml
136147
'
137148
artifacts:
138149
when: always
139-
reports:
140-
junit:
141-
- ./tmp/junit/junit.xml
142-
coverage_report:
143-
coverage_format: cobertura
144-
path: ./tmp/coverage/cobertura-coverage.xml
145150
paths:
146-
# Only the build:linux preserves the dist
147-
- ./dist
148-
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
149-
rules:
150-
# Runs on staging commits and ignores version commits
151-
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
152-
# Runs on tag pipeline where the tag is a prerelease or release version
153-
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
154-
155-
build:windows:
156-
stage: build
157-
needs: []
158-
tags:
159-
- windows
160-
before_script:
161-
- choco install nodejs --version=16.14.2 -y
162-
- refreshenv
163-
script:
164-
- npm config set msvs_version 2019
165-
- npm install --ignore-scripts
166-
- $env:Path = "$(npm bin);" + $env:Path
167-
- npm run build --verbose
168-
- npm test -- --ci
169-
artifacts:
170-
when: always
171-
reports:
172-
junit:
173-
- ./tmp/junit/junit.xml
151+
- ./tmp/build-pipelines.yml
174152
rules:
175153
# Runs on staging commits and ignores version commits
176-
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
177-
# Runs on tag pipeline where the tag is a prerelease or release version
178-
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
154+
- if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
155+
# Manually run on commits other than master and staging and ignore version commits
156+
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
157+
when: manual
179158

180-
build:macos:
159+
build:platforms:
181160
stage: build
182-
needs: []
183-
tags:
184-
- shared-macos-amd64
185-
image: macos-11-xcode-12
186-
variables:
187-
HOMEBREW_NO_INSTALL_UPGRADE: "true"
188-
HOMEBREW_NO_INSTALL_CLEANUP: "true"
189-
before_script:
190-
- eval "$(brew shellenv)"
191-
- brew install node@16
192-
- brew link --overwrite node@16
193-
- hash -r
194-
script:
195-
- npm install --ignore-scripts
196-
- export PATH="$(npm bin):$PATH"
197-
- npm run build --verbose
198-
- npm test -- --ci
199-
artifacts:
200-
when: always
201-
reports:
202-
junit:
203-
- ./tmp/junit/junit.xml
161+
needs:
162+
- build:build-generate
163+
inherit:
164+
variables: false
165+
trigger:
166+
include:
167+
- artifact: tmp/build-pipelines.yml
168+
job: build:build-generate
169+
strategy: depend
204170
rules:
205171
# Runs on staging commits and ignores version commits
206-
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
207-
# Runs on tag pipeline where the tag is a prerelease or release version
208-
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
172+
- if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
173+
# Manually run on commits other than master and staging and ignore version commits
174+
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
175+
when: manual
209176

210177
build:prerelease:
211178
stage: build
212179
needs:
213-
- build:linux
214-
- build:windows
215-
- build:macos
180+
- build:platforms
216181
# Don't interrupt publishing job
217182
interruptible: false
218183
before_script:
@@ -235,9 +200,7 @@ build:prerelease:
235200
integration:builds:
236201
stage: integration
237202
needs:
238-
- build:linux
239-
- build:windows
240-
- build:macos
203+
- build:platforms
241204
script:
242205
- mkdir -p ./builds
243206
- >
@@ -434,11 +397,7 @@ integration:merge:
434397
stage: integration
435398
needs:
436399
- build:merge
437-
- job: build:linux
438-
optional: true
439-
- job: build:windows
440-
optional: true
441-
- job: build:macos
400+
- job: build:platforms
442401
optional: true
443402
- job: integration:nix
444403
optional: true
@@ -514,9 +473,7 @@ release:deployment:tag:
514473
release:distribution:
515474
stage: release
516475
needs:
517-
- build:linux
518-
- build:windows
519-
- build:macos
476+
- build:platforms
520477
- integration:builds
521478
- integration:merge
522479
- release:deployment:tag

0 commit comments

Comments
 (0)