chore: run Circle CI tests in parallel (#2059)
* chore: run Circle CI tests in parallel * fix: fix schema * fix: fix schema * chore: persist and load workspace * chore: optimize ci steps * chore: fix * chore: fix * chore: fix cache * chore: fix cache * chore: fix cache * chore: fix cache
This commit is contained in:
parent
b241ea18ac
commit
0c455c35c9
|
@ -2,15 +2,25 @@ version: 2.1
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
build:
|
|
||||||
jobs:
|
|
||||||
- build_and_test
|
|
||||||
jobs:
|
|
||||||
build_and_test:
|
build_and_test:
|
||||||
|
jobs:
|
||||||
|
- build_and_unit_test
|
||||||
|
- integration_test_readonly:
|
||||||
|
requires:
|
||||||
|
- build_and_unit_test
|
||||||
|
- integration_test_readwrite:
|
||||||
|
requires:
|
||||||
|
- build_and_unit_test
|
||||||
|
executors:
|
||||||
|
node:
|
||||||
|
working_directory: ~/pinafore
|
||||||
|
docker:
|
||||||
|
# we want Node v12, not v14
|
||||||
|
# see https://discuss.circleci.com/t/build-failed-the-engine-node-is-incompatible-with-this-module-expected-version-12-x-got-14-15-0/37921/7
|
||||||
|
- image: circleci/ruby@sha256:b018ec2a8f0bbf06880735d2801402bad316c465edb60663be83ac8f1086b805
|
||||||
|
node_and_ruby:
|
||||||
working_directory: ~/pinafore
|
working_directory: ~/pinafore
|
||||||
docker:
|
docker:
|
||||||
# see https://discuss.circleci.com/t/build-failed-the-engine-node-is-incompatible-with-this-module-expected-version-12-x-got-14-15-0/37921/7
|
|
||||||
# we want Node v12, not v14
|
|
||||||
- image: circleci/ruby@sha256:b018ec2a8f0bbf06880735d2801402bad316c465edb60663be83ac8f1086b805
|
- image: circleci/ruby@sha256:b018ec2a8f0bbf06880735d2801402bad316c465edb60663be83ac8f1086b805
|
||||||
- image: circleci/postgres:12.2
|
- image: circleci/postgres:12.2
|
||||||
environment:
|
environment:
|
||||||
|
@ -19,37 +29,79 @@ jobs:
|
||||||
POSTGRES_DB: pinafore_development
|
POSTGRES_DB: pinafore_development
|
||||||
BROWSER: chrome:headless
|
BROWSER: chrome:headless
|
||||||
- image: circleci/redis:5-alpine
|
- image: circleci/redis:5-alpine
|
||||||
|
commands:
|
||||||
|
save_workspace:
|
||||||
|
description: Persist workspace
|
||||||
|
steps:
|
||||||
|
- persist_to_workspace:
|
||||||
|
root: .
|
||||||
|
paths:
|
||||||
|
- .
|
||||||
|
load_workspace:
|
||||||
|
description: Load workspace
|
||||||
|
steps:
|
||||||
|
- attach_workspace:
|
||||||
|
at: ~/pinafore
|
||||||
|
restore_yarn_cache:
|
||||||
|
description: Restore yarn cache
|
||||||
|
steps:
|
||||||
|
- restore_cache:
|
||||||
|
name: Restore yarn cache
|
||||||
|
key: yarn-v3-{{ checksum "yarn.lock" }}
|
||||||
|
save_yarn_cache:
|
||||||
|
description: Save yarn cache
|
||||||
|
steps:
|
||||||
|
- save_cache:
|
||||||
|
name: Save yarn cache
|
||||||
|
key: yarn-v3-{{ checksum "yarn.lock" }}
|
||||||
|
paths:
|
||||||
|
- ~/.cache/yarn
|
||||||
|
restore_yarn_cache_mastodon:
|
||||||
|
description: Restore yarn cache for Mastodon
|
||||||
|
steps:
|
||||||
|
- restore_cache:
|
||||||
|
name: Restore yarn cache for Mastodon
|
||||||
|
key: yarn-v3-{{ checksum "mastodon/yarn.lock" }}
|
||||||
|
save_yarn_cache_mastodon:
|
||||||
|
description: Save yarn cache for Mastodon
|
||||||
|
steps:
|
||||||
|
- save_cache:
|
||||||
|
name: Save yarn cache for Mastodon
|
||||||
|
key: yarn-v3-{{ checksum "mastodon/yarn.lock" }}
|
||||||
|
paths:
|
||||||
|
- ~/.cache/yarn
|
||||||
|
restore_bundler_cache:
|
||||||
|
description: Restore bundler cache
|
||||||
|
steps:
|
||||||
|
- restore_cache:
|
||||||
|
name: Restore bundler cache
|
||||||
|
key: bundler-v2-{{ checksum "mastodon/Gemfile.lock" }}
|
||||||
|
save_bundler_cache:
|
||||||
|
description: Save bundler cache
|
||||||
|
steps:
|
||||||
|
- save_cache:
|
||||||
|
name: Save bundler cache
|
||||||
|
key: bundler-v2-{{ checksum "mastodon/Gemfile.lock" }}
|
||||||
|
paths:
|
||||||
|
- mastodon/vendor/bundle
|
||||||
|
install_mastodon:
|
||||||
|
description: Install Mastodon and set up Postgres/Redis
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
|
||||||
- run:
|
- run:
|
||||||
name: Install system dependencies
|
name: Install system dependencies
|
||||||
command: |
|
command: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y ffmpeg fonts-noto-color-emoji libicu-dev libidn11-dev libprotobuf-dev postgresql-contrib protobuf-compiler
|
sudo apt-get install -y ffmpeg fonts-noto-color-emoji libicu-dev libidn11-dev libprotobuf-dev postgresql-contrib protobuf-compiler
|
||||||
- run:
|
|
||||||
name: Check node version
|
|
||||||
command: node -v
|
|
||||||
- restore_cache:
|
|
||||||
name: Restore yarn cache
|
|
||||||
key: yarn-v1-{{ checksum "yarn.lock" }}
|
|
||||||
- run:
|
|
||||||
name: Yarn install
|
|
||||||
command: yarn install --immutable
|
|
||||||
- run:
|
- run:
|
||||||
name: Clone mastodon
|
name: Clone mastodon
|
||||||
command: yarn clone-mastodon
|
command: yarn clone-mastodon
|
||||||
- restore_cache:
|
- restore_yarn_cache_mastodon
|
||||||
name: Restore bundler cache
|
- restore_bundler_cache
|
||||||
key: bundler-v2-{{ checksum "mastodon/Gemfile.lock" }}
|
|
||||||
- run:
|
|
||||||
name: Lint
|
|
||||||
command: yarn lint
|
|
||||||
- run:
|
|
||||||
name: Unit tests
|
|
||||||
command: yarn test-unit
|
|
||||||
- run:
|
- run:
|
||||||
name: Install mastodon
|
name: Install mastodon
|
||||||
command: yarn install-mastodon
|
command: yarn install-mastodon
|
||||||
|
- save_yarn_cache_mastodon
|
||||||
|
- save_bundler_cache
|
||||||
- run:
|
- run:
|
||||||
name: Wait for postgres to be ready
|
name: Wait for postgres to be ready
|
||||||
command: |
|
command: |
|
||||||
|
@ -70,6 +122,19 @@ jobs:
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
echo Failed waiting for redis && exit 1
|
echo Failed waiting for redis && exit 1
|
||||||
|
jobs:
|
||||||
|
build_and_unit_test:
|
||||||
|
executor: node
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- restore_yarn_cache
|
||||||
|
- run:
|
||||||
|
name: Yarn install
|
||||||
|
command: yarn install --immutable
|
||||||
|
- save_yarn_cache
|
||||||
|
- run:
|
||||||
|
name: Lint
|
||||||
|
command: yarn lint
|
||||||
- run:
|
- run:
|
||||||
name: Copy vercel.json
|
name: Copy vercel.json
|
||||||
command: cp vercel.json vercel-old.json
|
command: cp vercel.json vercel-old.json
|
||||||
|
@ -85,15 +150,22 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
- run:
|
- run:
|
||||||
name: Integration tests
|
name: Unit tests
|
||||||
command: yarn test-in-ci
|
command: yarn test-unit
|
||||||
- save_cache:
|
- save_workspace
|
||||||
name: Save yarn cache
|
integration_test_readonly:
|
||||||
key: yarn-v1-{{ checksum "yarn.lock" }}
|
executor: node_and_ruby
|
||||||
paths:
|
steps:
|
||||||
- ~/.cache/yarn
|
- load_workspace
|
||||||
- save_cache:
|
- install_mastodon
|
||||||
name: Save bundler cache
|
- run:
|
||||||
key: bundler-v2-{{ checksum "mastodon/Gemfile.lock" }}
|
name: Read-only integration tests
|
||||||
paths:
|
command: yarn test-in-ci-suite0
|
||||||
- mastodon/vendor/bundle
|
integration_test_readwrite:
|
||||||
|
executor: node_and_ruby
|
||||||
|
steps:
|
||||||
|
- load_workspace
|
||||||
|
- install_mastodon
|
||||||
|
- run:
|
||||||
|
name: Read-write integration tests
|
||||||
|
command: yarn test-in-ci-suite1
|
||||||
|
|
|
@ -23,11 +23,14 @@
|
||||||
"test": "cross-env BROWSER=chrome:headless run-s test-browser",
|
"test": "cross-env BROWSER=chrome:headless run-s test-browser",
|
||||||
"test-browser": "run-p --race run-mastodon build-and-start test-mastodon",
|
"test-browser": "run-p --race run-mastodon build-and-start test-mastodon",
|
||||||
"test-mastodon": "run-s wait-for-mastodon-to-start wait-for-mastodon-data testcafe",
|
"test-mastodon": "run-s wait-for-mastodon-to-start wait-for-mastodon-data testcafe",
|
||||||
|
"test-mastodon-suite0": "run-s wait-for-mastodon-to-start wait-for-mastodon-data testcafe-suite0",
|
||||||
|
"test-mastodon-suite1": "run-s wait-for-mastodon-to-start wait-for-mastodon-data testcafe-suite1",
|
||||||
"testcafe": "run-s testcafe-suite0 testcafe-suite1",
|
"testcafe": "run-s testcafe-suite0 testcafe-suite1",
|
||||||
"testcafe-suite0": "cross-env-shell testcafe -c 2 $BROWSER tests/spec/0*",
|
"testcafe-suite0": "cross-env-shell testcafe -c 2 $BROWSER tests/spec/0*",
|
||||||
"testcafe-suite1": "cross-env-shell testcafe $BROWSER tests/spec/1*",
|
"testcafe-suite1": "cross-env-shell testcafe $BROWSER tests/spec/1*",
|
||||||
"test-unit": "NODE_ENV=test mocha -r esm -r bin/browser-shim.js tests/unit/",
|
"test-unit": "NODE_ENV=test mocha -r esm -r bin/browser-shim.js tests/unit/",
|
||||||
"test-in-ci": "cross-env BROWSER=chrome:headless run-p --race run-mastodon start test-mastodon",
|
"test-in-ci-suite0": "cross-env BROWSER=chrome:headless run-p --race run-mastodon start test-mastodon-suite0",
|
||||||
|
"test-in-ci-suite1": "cross-env BROWSER=chrome:headless run-p --race run-mastodon start test-mastodon-suite1",
|
||||||
"wait-for-mastodon-to-start": "node -r esm bin/wait-for-mastodon-to-start.js",
|
"wait-for-mastodon-to-start": "node -r esm bin/wait-for-mastodon-to-start.js",
|
||||||
"wait-for-mastodon-data": "node -r esm bin/wait-for-mastodon-data.js",
|
"wait-for-mastodon-data": "node -r esm bin/wait-for-mastodon-data.js",
|
||||||
"backup-mastodon-data": "./bin/backup-mastodon-data.sh",
|
"backup-mastodon-data": "./bin/backup-mastodon-data.sh",
|
||||||
|
|
Loading…
Reference in a new issue