From 0a66e12ec0a55c1f800024bb7f37aa3740b1b284 Mon Sep 17 00:00:00 2001 From: Jahed Ahmed Date: Fri, 3 Sep 2021 17:58:21 +0000 Subject: [PATCH] chore(ci): use parallel tests --- .circleci/config.yml | 177 +++++-------------------------------------- .circleci/tests.txt | 9 +++ 2 files changed, 26 insertions(+), 160 deletions(-) create mode 100644 .circleci/tests.txt diff --git a/.circleci/config.yml b/.circleci/config.yml index 017ea0e186a..7c8a28faf63 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: @@ -214,6 +199,7 @@ jobs: test-windows: <<: *defaults executor: win/default + parallelism: 3 steps: - run: name: Configuring Git @@ -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 @@ -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: @@ -442,19 +351,7 @@ 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 @@ -462,48 +359,9 @@ workflows: 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 @@ -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 diff --git a/.circleci/tests.txt b/.circleci/tests.txt new file mode 100644 index 00000000000..f7013491054 --- /dev/null +++ b/.circleci/tests.txt @@ -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 \ No newline at end of file