2020-11-23 20:45:01 +00:00
|
|
|
version: 2.1
|
|
|
|
|
2021-07-05 04:19:04 +01:00
|
|
|
orbs:
|
|
|
|
browser-tools: circleci/browser-tools@1.1.3
|
2020-11-23 20:45:01 +00:00
|
|
|
workflows:
|
|
|
|
version: 2
|
|
|
|
build_and_test:
|
2021-07-03 21:15:44 +01:00
|
|
|
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:
|
2022-04-30 22:38:37 +01:00
|
|
|
- image: cimg/ruby:3.0.3-browsers
|
2021-07-03 21:15:44 +01:00
|
|
|
node_and_ruby:
|
2020-11-23 20:45:01 +00:00
|
|
|
working_directory: ~/pinafore
|
|
|
|
docker:
|
2022-04-30 22:38:37 +01:00
|
|
|
- image: cimg/ruby:3.0.3-browsers
|
2020-11-23 20:45:01 +00:00
|
|
|
- image: circleci/postgres:12.2
|
|
|
|
environment:
|
|
|
|
POSTGRES_USER: pinafore
|
|
|
|
POSTGRES_PASSWORD: pinafore
|
|
|
|
POSTGRES_DB: pinafore_development
|
|
|
|
BROWSER: chrome:headless
|
|
|
|
- image: circleci/redis:5-alpine
|
2021-07-03 21:15:44 +01:00
|
|
|
commands:
|
2021-07-05 04:19:04 +01:00
|
|
|
install_mastodon_system_dependencies:
|
|
|
|
description: Install system dependencies that Mastodon requires
|
|
|
|
steps:
|
|
|
|
- run:
|
|
|
|
name: Install system dependencies
|
|
|
|
command: |
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install -y \
|
|
|
|
ffmpeg \
|
|
|
|
fonts-noto-color-emoji \
|
|
|
|
imagemagick \
|
|
|
|
libicu-dev \
|
|
|
|
libidn11-dev \
|
|
|
|
libprotobuf-dev \
|
|
|
|
postgresql-contrib \
|
|
|
|
protobuf-compiler
|
|
|
|
install_browsers:
|
|
|
|
description: Install browsers and tools
|
|
|
|
steps:
|
|
|
|
- browser-tools/install-chrome:
|
|
|
|
chrome-version: 91.0.4472.114
|
|
|
|
- browser-tools/install-chromedriver
|
|
|
|
- run:
|
|
|
|
name: "Check browser version"
|
|
|
|
command: |
|
|
|
|
google-chrome --version
|
|
|
|
install_node:
|
|
|
|
description: Install Node.js
|
|
|
|
steps:
|
|
|
|
- run:
|
|
|
|
name: "Install Node.js"
|
|
|
|
# via https://circleci.com/docs/2.0/circleci-images/#notes-on-pinning-images
|
|
|
|
command: |
|
2021-07-29 15:25:40 +01:00
|
|
|
curl -sSL "https://nodejs.org/dist/v12.22.3/node-v12.22.3-linux-x64.tar.xz" \
|
|
|
|
| sudo tar --strip-components=2 -xJ -C /usr/local/bin/ node-v12.22.3-linux-x64/bin/node
|
2021-07-05 04:19:04 +01:00
|
|
|
- run:
|
|
|
|
name: Check current version of node
|
|
|
|
command: node -v
|
|
|
|
|
2021-07-03 21:15:44 +01:00
|
|
|
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
|
2021-07-05 04:19:04 +01:00
|
|
|
key: yarn-v4-{{ checksum "yarn.lock" }}
|
2021-07-03 21:15:44 +01:00
|
|
|
save_yarn_cache:
|
|
|
|
description: Save yarn cache
|
|
|
|
steps:
|
|
|
|
- save_cache:
|
|
|
|
name: Save yarn cache
|
2021-07-05 04:19:04 +01:00
|
|
|
key: yarn-v4-{{ checksum "yarn.lock" }}
|
2021-07-03 21:15:44 +01:00
|
|
|
paths:
|
|
|
|
- ~/.cache/yarn
|
|
|
|
restore_yarn_cache_mastodon:
|
|
|
|
description: Restore yarn cache for Mastodon
|
|
|
|
steps:
|
|
|
|
- restore_cache:
|
|
|
|
name: Restore yarn cache for Mastodon
|
2021-07-05 04:19:04 +01:00
|
|
|
key: yarn-v4-{{ checksum "mastodon/yarn.lock" }}
|
2021-07-03 21:15:44 +01:00
|
|
|
save_yarn_cache_mastodon:
|
|
|
|
description: Save yarn cache for Mastodon
|
|
|
|
steps:
|
|
|
|
- save_cache:
|
|
|
|
name: Save yarn cache for Mastodon
|
2021-07-05 04:19:04 +01:00
|
|
|
key: yarn-v4-{{ checksum "mastodon/yarn.lock" }}
|
2021-07-03 21:15:44 +01:00
|
|
|
paths:
|
|
|
|
- ~/.cache/yarn
|
|
|
|
restore_bundler_cache:
|
|
|
|
description: Restore bundler cache
|
|
|
|
steps:
|
|
|
|
- restore_cache:
|
|
|
|
name: Restore bundler cache
|
2021-07-05 04:19:04 +01:00
|
|
|
key: bundler-v4-{{ checksum "mastodon/Gemfile.lock" }}
|
2021-07-03 21:15:44 +01:00
|
|
|
save_bundler_cache:
|
|
|
|
description: Save bundler cache
|
|
|
|
steps:
|
|
|
|
- save_cache:
|
|
|
|
name: Save bundler cache
|
2021-07-05 04:19:04 +01:00
|
|
|
key: bundler-v4-{{ checksum "mastodon/Gemfile.lock" }}
|
2021-07-03 21:15:44 +01:00
|
|
|
paths:
|
|
|
|
- mastodon/vendor/bundle
|
|
|
|
install_mastodon:
|
|
|
|
description: Install Mastodon and set up Postgres/Redis
|
2020-11-23 20:45:01 +00:00
|
|
|
steps:
|
|
|
|
- run:
|
|
|
|
name: Clone mastodon
|
|
|
|
command: yarn clone-mastodon
|
2021-07-03 21:15:44 +01:00
|
|
|
- restore_yarn_cache_mastodon
|
|
|
|
- restore_bundler_cache
|
2021-03-06 17:06:42 +00:00
|
|
|
- run:
|
|
|
|
name: Install mastodon
|
|
|
|
command: yarn install-mastodon
|
2021-07-03 21:15:44 +01:00
|
|
|
- save_yarn_cache_mastodon
|
|
|
|
- save_bundler_cache
|
2020-11-23 20:45:01 +00:00
|
|
|
- run:
|
|
|
|
name: Wait for postgres to be ready
|
|
|
|
command: |
|
|
|
|
for i in `seq 1 10`;
|
|
|
|
do
|
|
|
|
nc -z localhost 5432 && echo Success && exit 0
|
|
|
|
echo -n .
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
echo Failed waiting for postgres && exit 1
|
|
|
|
- run:
|
|
|
|
name: Wait for redis to be ready
|
|
|
|
command: |
|
|
|
|
for i in `seq 1 10`;
|
|
|
|
do
|
|
|
|
nc -z localhost 6379 && echo Success && exit 0
|
|
|
|
echo -n .
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
echo Failed waiting for redis && exit 1
|
2021-07-03 21:15:44 +01:00
|
|
|
jobs:
|
|
|
|
build_and_unit_test:
|
|
|
|
executor: node
|
|
|
|
steps:
|
|
|
|
- checkout
|
2021-07-05 04:19:04 +01:00
|
|
|
- install_node
|
2021-07-03 21:15:44 +01:00
|
|
|
- restore_yarn_cache
|
|
|
|
- run:
|
|
|
|
name: Yarn install
|
|
|
|
command: yarn install --immutable
|
|
|
|
- save_yarn_cache
|
|
|
|
- run:
|
|
|
|
name: Lint
|
|
|
|
command: yarn lint
|
2021-03-07 18:34:13 +00:00
|
|
|
- run:
|
|
|
|
name: Copy vercel.json
|
|
|
|
command: cp vercel.json vercel-old.json
|
2021-03-06 17:06:42 +00:00
|
|
|
- run:
|
|
|
|
name: Build
|
|
|
|
command: yarn build
|
2021-03-07 18:34:13 +00:00
|
|
|
- run:
|
|
|
|
name: Check vercel.json unchanged
|
|
|
|
command: |
|
|
|
|
if ! diff -q vercel-old.json vercel.json &>/dev/null; then
|
|
|
|
diff vercel-old.json vercel.json
|
|
|
|
echo "vercel.json changed, run yarn build and make sure everything looks okay"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-11-23 20:45:01 +00:00
|
|
|
- run:
|
2021-07-03 21:15:44 +01:00
|
|
|
name: Unit tests
|
|
|
|
command: yarn test-unit
|
|
|
|
- save_workspace
|
|
|
|
integration_test_readonly:
|
|
|
|
executor: node_and_ruby
|
|
|
|
steps:
|
2021-07-05 04:19:04 +01:00
|
|
|
- install_mastodon_system_dependencies
|
|
|
|
- install_browsers
|
|
|
|
- install_node
|
2021-07-03 21:15:44 +01:00
|
|
|
- load_workspace
|
|
|
|
- install_mastodon
|
|
|
|
- run:
|
|
|
|
name: Read-only integration tests
|
|
|
|
command: yarn test-in-ci-suite0
|
|
|
|
integration_test_readwrite:
|
|
|
|
executor: node_and_ruby
|
|
|
|
steps:
|
2021-07-05 04:19:04 +01:00
|
|
|
- install_mastodon_system_dependencies
|
|
|
|
- install_browsers
|
|
|
|
- install_node
|
2021-07-03 21:15:44 +01:00
|
|
|
- load_workspace
|
|
|
|
- install_mastodon
|
|
|
|
- run:
|
|
|
|
name: Read-write integration tests
|
|
|
|
command: yarn test-in-ci-suite1
|