Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): use parallel tests #2232

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 17 additions & 160 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,11 @@ orbs:
gh: circleci/github-cli@1.0.4

defaults: &defaults
working_directory: ~/snyk
parameters:
node_version:
type: string
default: '14.17.5'
root_tap_tests:
type: boolean
default: false
jest_tests:
type: boolean
default: false
acceptance_tests:
type: boolean
default: false
system_tests:
type: boolean
default: false
package_tests:
type: boolean
default: false
working_directory: ~/snyk

commands:
install_project_dependencies:
Expand Down Expand Up @@ -214,6 +199,7 @@ jobs:
test-windows:
<<: *defaults
executor: win/default
parallelism: 3
steps:
- run:
name: Configuring Git
Expand All @@ -230,56 +216,18 @@ jobs:
- run:
name: Configuring Snyk CLI
command: node ./bin/snyk config set "api=$env:SNYK_API_KEY"
- when:
condition: << parameters.package_tests >>
steps:
- run:
name: Running unit tests (Packages)
command: npm run test:packages-unit -- --ci
- when:
condition: << parameters.package_tests >>
steps:
- run:
name: Running acceptance tests (Packages)
command: npm run test:packages-acceptance -- --ci
- when:
condition: << parameters.root_tap_tests >>
steps:
- run:
name: Running root tests (Tap)
command: npm run test:test
- when:
condition: << parameters.jest_tests >>
steps:
- run:
name: Running root tests (Jest)
command: npm run test:jest -- --ci
- run:
name: Running unit tests (Jest)
command: npm run test:jest-unit -- --ci
- run:
name: Running system tests (Jest)
command: npm run test:jest-system -- --ci
- run:
name: Running acceptance tests (Jest)
command: npm run test:jest-acceptance -- --ci
- when:
condition: << parameters.acceptance_tests >>
steps:
- run:
name: Running acceptance tests (Tap)
command: npm run test:acceptance
- when:
condition: << parameters.system_tests >>
steps:
- run:
name: Running system tests (Tap)
command: npm run test:system
- run:
name: Running tests
command: |
$allocated_tests="$(cat .circleci/tests.txt | ForEach-Object { $_.split(" ")[1] })"
echo "Allocated tests: ${allocated_tests}"
npx npm-run-all --npm-path npm -s -c ${allocated_tests}
test-linux:
<<: *defaults
docker:
- image: circleci/node:<< parameters.node_version >>
resource_class: large
parallelism: 3
steps:
- checkout
- install_sdks_linux
Expand All @@ -290,51 +238,12 @@ jobs:
- run:
name: Configuring Snyk CLI
command: node ./bin/snyk config set "api=${SNYK_API_KEY}"
- when:
condition: << parameters.package_tests >>
steps:
- run:
name: Running unit tests (Packages)
command: npm run test:packages-unit -- --ci
- when:
condition: << parameters.package_tests >>
steps:
- run:
name: Running acceptance tests (Packages)
command: npm run test:packages-acceptance -- --ci
- when:
condition: << parameters.root_tap_tests >>
steps:
- run:
name: Running root tests (Tap)
command: npm run test:test
- when:
condition: << parameters.jest_tests >>
steps:
- run:
name: Running root tests (Jest)
command: npm run test:jest -- --ci
- run:
name: Running unit tests (Jest)
command: npm run test:jest-unit -- --ci
- run:
name: Running system tests (Jest)
command: npm run test:jest-system -- --ci
- run:
name: Running acceptance tests (Jest)
command: npm run test:jest-acceptance -- --ci
- when:
condition: << parameters.acceptance_tests >>
steps:
- run:
name: Running acceptance tests (Tap)
command: npm run test:acceptance
- when:
condition: << parameters.system_tests >>
steps:
- run:
name: Running system tests (Tap)
command: npm run test:system
- run:
name: Running tests
command: |
allocated_tests="$(circleci tests split .circleci/tests.txt | cut -d' ' -f2)"
echo "Allocated tests: ${allocated_tests}"
npx npm-run-all --npm-path npm -s -c ${allocated_tests}
dev-release:
<<: *defaults
docker:
Expand Down Expand Up @@ -442,68 +351,17 @@ workflows:
- master

- test-windows:
name: Windows, Node v14.17.5 - Packages, Jest, System Tests
context: nodejs-install
requires:
- Build
filters:
branches:
ignore:
- master
jest_tests: true
system_tests: true
package_tests: true
- test-windows:
name: Windows, Node v14.17.5 - Acceptance Tests
name: Tests - Windows, Node v14.17.5
context: nodejs-install
requires:
- Build
filters:
branches:
ignore:
- master
acceptance_tests: true
- test-windows:
name: Windows, Node v14.17.5 - Root Tap Tests
context: nodejs-install
requires:
- Build
filters:
branches:
ignore:
- master
root_tap_tests: true

- test-linux:
name: Linux, Node v<< matrix.node_version >> - Packages, Jest, System Tests
context: nodejs-install
requires:
- Build
filters:
branches:
ignore:
- master
matrix:
parameters:
node_version: ['10.24.1', '12.22.5', '14.17.5']
jest_tests: true
system_tests: true
package_tests: true
- test-linux:
name: Linux, Node v<< matrix.node_version >> - Acceptance Tests
context: nodejs-install
requires:
- Build
filters:
branches:
ignore:
- master
matrix:
parameters:
node_version: ['10.24.1', '12.22.5', '14.17.5']
acceptance_tests: true
- test-linux:
name: Linux, Node v<< matrix.node_version >> - Root Tap Tests
name: Tests - Linux, Node v<< matrix.node_version >>
context: nodejs-install
requires:
- Build
Expand All @@ -514,7 +372,6 @@ workflows:
matrix:
parameters:
node_version: ['10.24.1', '12.22.5', '14.17.5']
root_tap_tests: true

- dev-release:
name: Development Release
Expand Down
9 changes: 9 additions & 0 deletions .circleci/tests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
01 test:packages-unit
02 test:packages-acceptance
03 test:test
11 test:jest
12 test:jest-system
13 test:acceptance
21 test:jest-unit
22 test:system
23 test:jest-acceptance