Skip to content

Commit

Permalink
Merge pull request #65 from MatrixAI/feature-test-load-balancing
Browse files Browse the repository at this point in the history
feat: test load balancing using jest's `--shard` option
  • Loading branch information
emmacasolin authored Jun 29, 2022
2 parents 7c721e7 + 9bba1e4 commit 716a6a0
Show file tree
Hide file tree
Showing 6 changed files with 2,098 additions and 1,803 deletions.
127 changes: 41 additions & 86 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,36 @@ check:nix-dry:
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
when: manual

check:test:
check:test-generate:
stage: check
needs: []
script:
- mkdir -p ./tmp
- >
nix-shell --run '
npm run build --verbose;
npm test -- --ci --coverage;
./scripts/test-pipelines.sh > ./tmp/test-pipelines.yml
'
artifacts:
when: always
reports:
junit:
- ./tmp/junit/junit.xml
coverage_report:
coverage_format: cobertura
path: ./tmp/coverage/cobertura-coverage.xml
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
paths:
- ./tmp/test-pipelines.yml
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Manually run on commits other than master and staging and ignore version commits
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
when: manual

check:test:
stage: check
needs:
- check:test-generate
inherit:
variables: false
trigger:
include:
- artifact: tmp/test-pipelines.yml
job: check:test-generate
strategy: depend
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
Expand Down Expand Up @@ -125,82 +137,35 @@ build:merge:
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/

build:linux:
build:build-generate:
stage: build
needs: []
script:
- mkdir -p ./tmp
- >
nix-shell --run '
npm run build --verbose;
npm test -- --ci --coverage;
./scripts/build-pipelines.sh > ./tmp/build-pipelines.yml
'
artifacts:
when: always
reports:
junit:
- ./tmp/junit/junit.xml
coverage_report:
coverage_format: cobertura
path: ./tmp/coverage/cobertura-coverage.xml
paths:
# Only the build:linux preserves the dist
- ./dist
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/

build:windows:
stage: build
needs: []
tags:
- windows
before_script:
- choco install nodejs --version=16.14.2 -y
- refreshenv
script:
- npm config set msvs_version 2019
- npm install --ignore-scripts
- $env:Path = "$(npm bin);" + $env:Path
- npm run build --verbose
- npm test -- --ci
artifacts:
when: always
reports:
junit:
- ./tmp/junit/junit.xml
- ./tmp/build-pipelines.yml
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/

build:macos:
build:platforms:
stage: build
needs: []
tags:
- shared-macos-amd64
image: macos-11-xcode-12
variables:
HOMEBREW_NO_INSTALL_UPGRADE: "true"
HOMEBREW_NO_INSTALL_CLEANUP: "true"
before_script:
- eval "$(brew shellenv)"
- brew install node@16
- brew link --overwrite node@16
- hash -r
script:
- npm install --ignore-scripts
- export PATH="$(npm bin):$PATH"
- npm run build --verbose
- npm test -- --ci
artifacts:
when: always
reports:
junit:
- ./tmp/junit/junit.xml
needs:
- build:build-generate
inherit:
variables: false
trigger:
include:
- artifact: tmp/build-pipelines.yml
job: build:build-generate
strategy: depend
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
Expand All @@ -210,9 +175,7 @@ build:macos:
build:prerelease:
stage: build
needs:
- build:linux
- build:windows
- build:macos
- build:platforms
# Don't interrupt publishing job
interruptible: false
before_script:
Expand All @@ -235,9 +198,7 @@ build:prerelease:
integration:builds:
stage: integration
needs:
- build:linux
- build:windows
- build:macos
- build:platforms
script:
- mkdir -p ./builds
- >
Expand Down Expand Up @@ -434,11 +395,7 @@ integration:merge:
stage: integration
needs:
- build:merge
- job: build:linux
optional: true
- job: build:windows
optional: true
- job: build:macos
- job: build:platforms
optional: true
- job: integration:nix
optional: true
Expand Down Expand Up @@ -514,9 +471,7 @@ release:deployment:tag:
release:distribution:
stage: release
needs:
- build:linux
- build:windows
- build:macos
- build:platforms
- integration:builds
- integration:merge
- release:deployment:tag
Expand Down
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ module.exports = {
},
reporters: [
'default',
['jest-junit', { outputDirectory: '<rootDir>/tmp/junit' }],
['jest-junit', {
outputDirectory: '<rootDir>/tmp/junit',
classNameTemplate: '{classname}',
titleTemplate: '{title}',
addFileAttribute: 'true',
}],
],
collectCoverageFrom: ['src/**/*.{ts,tsx,js,jsx}', '!src/**/*.d.ts'],
coverageReporters: ['text', 'cobertura'],
Expand Down
Loading

0 comments on commit 716a6a0

Please sign in to comment.