Skip to content

Commit 716a6a0

Browse files
authored
Merge pull request #65 from MatrixAI/feature-test-load-balancing
feat: test load balancing using jest's `--shard` option
2 parents 7c721e7 + 9bba1e4 commit 716a6a0

File tree

6 files changed

+2098
-1803
lines changed

6 files changed

+2098
-1803
lines changed

.gitlab-ci.yml

Lines changed: 41 additions & 86 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,82 +137,35 @@ 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
176154
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
177155
# Runs on tag pipeline where the tag is a prerelease or release version
178156
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
179157

180-
build:macos:
158+
build:platforms:
181159
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
160+
needs:
161+
- build:build-generate
162+
inherit:
163+
variables: false
164+
trigger:
165+
include:
166+
- artifact: tmp/build-pipelines.yml
167+
job: build:build-generate
168+
strategy: depend
204169
rules:
205170
# Runs on staging commits and ignores version commits
206171
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
@@ -210,9 +175,7 @@ build:macos:
210175
build:prerelease:
211176
stage: build
212177
needs:
213-
- build:linux
214-
- build:windows
215-
- build:macos
178+
- build:platforms
216179
# Don't interrupt publishing job
217180
interruptible: false
218181
before_script:
@@ -235,9 +198,7 @@ build:prerelease:
235198
integration:builds:
236199
stage: integration
237200
needs:
238-
- build:linux
239-
- build:windows
240-
- build:macos
201+
- build:platforms
241202
script:
242203
- mkdir -p ./builds
243204
- >
@@ -434,11 +395,7 @@ integration:merge:
434395
stage: integration
435396
needs:
436397
- build:merge
437-
- job: build:linux
438-
optional: true
439-
- job: build:windows
440-
optional: true
441-
- job: build:macos
398+
- job: build:platforms
442399
optional: true
443400
- job: integration:nix
444401
optional: true
@@ -514,9 +471,7 @@ release:deployment:tag:
514471
release:distribution:
515472
stage: release
516473
needs:
517-
- build:linux
518-
- build:windows
519-
- build:macos
474+
- build:platforms
520475
- integration:builds
521476
- integration:merge
522477
- release:deployment:tag

jest.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ module.exports = {
3838
},
3939
reporters: [
4040
'default',
41-
['jest-junit', { outputDirectory: '<rootDir>/tmp/junit' }],
41+
['jest-junit', {
42+
outputDirectory: '<rootDir>/tmp/junit',
43+
classNameTemplate: '{classname}',
44+
titleTemplate: '{title}',
45+
addFileAttribute: 'true',
46+
}],
4247
],
4348
collectCoverageFrom: ['src/**/*.{ts,tsx,js,jsx}', '!src/**/*.d.ts'],
4449
coverageReporters: ['text', 'cobertura'],

0 commit comments

Comments
 (0)