Improve CircleCI config (#16861)
* Improve CircleCI config * Enable PAM only when needed * Remove Ruby 2.6master
parent
a6152c7480
commit
9cdf8ac148
@ -1,255 +1,152 @@ |
|||||||
version: 2 |
version: 2.1 |
||||||
|
|
||||||
aliases: |
orbs: |
||||||
- &defaults |
ruby: circleci/ruby@1.2.0 |
||||||
|
node: circleci/node@4.7.0 |
||||||
|
|
||||||
|
executors: |
||||||
|
default: |
||||||
|
parameters: |
||||||
|
ruby-version: |
||||||
|
type: string |
||||||
docker: |
docker: |
||||||
- image: circleci/ruby:2.7-buster-node |
- image: cimg/ruby:<< parameters.ruby-version >> |
||||||
environment: &ruby_environment |
environment: |
||||||
BUNDLE_JOBS: 3 |
BUNDLE_JOBS: 3 |
||||||
BUNDLE_RETRY: 3 |
BUNDLE_RETRY: 3 |
||||||
BUNDLE_APP_CONFIG: ./.bundle/ |
CONTINUOUS_INTEGRATION: true |
||||||
BUNDLE_PATH: ./vendor/bundle/ |
|
||||||
DB_HOST: localhost |
DB_HOST: localhost |
||||||
DB_USER: root |
DB_USER: root |
||||||
RAILS_ENV: test |
|
||||||
ALLOW_NOPAM: true |
|
||||||
CONTINUOUS_INTEGRATION: true |
|
||||||
DISABLE_SIMPLECOV: true |
DISABLE_SIMPLECOV: true |
||||||
PAM_ENABLED: true |
RAILS_ENV: test |
||||||
PAM_DEFAULT_SERVICE: pam_test |
- image: cimg/postgres:12.7 |
||||||
PAM_CONTROLLED_SERVICE: pam_test_controlled |
environment: |
||||||
working_directory: ~/projects/mastodon/ |
POSTGRES_USER: root |
||||||
|
POSTGRES_HOST_AUTH_METHOD: trust |
||||||
- &attach_workspace |
- image: circleci/redis:5-alpine |
||||||
attach_workspace: |
|
||||||
at: ~/projects/ |
|
||||||
|
|
||||||
- &persist_to_workspace |
|
||||||
persist_to_workspace: |
|
||||||
root: ~/projects/ |
|
||||||
paths: |
|
||||||
- ./mastodon/ |
|
||||||
|
|
||||||
- &restore_ruby_dependencies |
|
||||||
restore_cache: |
|
||||||
keys: |
|
||||||
- v3-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }} |
|
||||||
- v3-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}- |
|
||||||
- v3-ruby-dependencies- |
|
||||||
|
|
||||||
- &install_steps |
commands: |
||||||
|
install-system-dependencies: |
||||||
steps: |
steps: |
||||||
- checkout |
|
||||||
- *attach_workspace |
|
||||||
- restore_cache: |
|
||||||
keys: |
|
||||||
- v2-node-dependencies-{{ checksum "yarn.lock" }} |
|
||||||
- v2-node-dependencies- |
|
||||||
- run: |
- run: |
||||||
name: Install yarn dependencies |
name: Install system dependencies |
||||||
command: yarn install --frozen-lockfile |
command: | |
||||||
- save_cache: |
sudo apt-get update |
||||||
key: v2-node-dependencies-{{ checksum "yarn.lock" }} |
sudo apt-get install -y libicu-dev libidn11-dev libprotobuf-dev protobuf-compiler |
||||||
paths: |
install-ruby-dependencies: |
||||||
- ./node_modules/ |
parameters: |
||||||
- *persist_to_workspace |
ruby-version: |
||||||
|
type: string |
||||||
- &install_system_dependencies |
steps: |
||||||
run: |
- run: |
||||||
name: Install system dependencies |
command: | |
||||||
command: | |
bundle config clean 'true' |
||||||
sudo apt-get update |
bundle config frozen 'true' |
||||||
sudo apt-get install -y libicu-dev libidn11-dev libprotobuf-dev protobuf-compiler |
bundle config without 'development production' |
||||||
|
name: Set bundler settings |
||||||
- &install_ruby_dependencies |
- ruby/install-deps: |
||||||
steps: |
bundler-version: '2.2.29' |
||||||
- *attach_workspace |
key: ruby<< parameters.ruby-version >>-gems-v1 |
||||||
- *install_system_dependencies |
wait-db: |
||||||
- run: |
steps: |
||||||
name: Set Ruby version |
- run: |
||||||
command: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version |
command: dockerize -wait tcp://localhost:5432 -wait tcp://localhost:6379 -timeout 1m |
||||||
- *restore_ruby_dependencies |
name: Wait for PostgreSQL and Redis |
||||||
- run: |
|
||||||
name: Set bundler settings |
|
||||||
command: | |
|
||||||
bundle config --local clean 'true' |
|
||||||
bundle config --local deployment 'true' |
|
||||||
bundle config --local with 'pam_authentication' |
|
||||||
bundle config --local without 'development production' |
|
||||||
bundle config --local frozen 'true' |
|
||||||
bundle config --local path $BUNDLE_PATH |
|
||||||
- run: |
|
||||||
name: Install bundler dependencies |
|
||||||
command: bundle check || (bundle install && bundle clean) |
|
||||||
- save_cache: |
|
||||||
key: v3-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }} |
|
||||||
paths: |
|
||||||
- ./.bundle/ |
|
||||||
- ./vendor/bundle/ |
|
||||||
- persist_to_workspace: |
|
||||||
root: ~/projects/ |
|
||||||
paths: |
|
||||||
- ./mastodon/.bundle/ |
|
||||||
- ./mastodon/vendor/bundle/ |
|
||||||
|
|
||||||
- &test_steps |
|
||||||
parallelism: 4 |
|
||||||
steps: |
|
||||||
- *attach_workspace |
|
||||||
- *install_system_dependencies |
|
||||||
- run: |
|
||||||
name: Install FFMPEG |
|
||||||
command: sudo apt-get install -y ffmpeg |
|
||||||
- run: |
|
||||||
name: Load database schema |
|
||||||
command: ./bin/rails db:create db:schema:load db:seed |
|
||||||
- run: |
|
||||||
name: Run rspec in parallel |
|
||||||
command: | |
|
||||||
bundle exec rspec --profile 10 \ |
|
||||||
--format RspecJunitFormatter \ |
|
||||||
--out test_results/rspec.xml \ |
|
||||||
--format progress \ |
|
||||||
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) |
|
||||||
- store_test_results: |
|
||||||
path: test_results |
|
||||||
jobs: |
jobs: |
||||||
install: |
|
||||||
<<: *defaults |
|
||||||
<<: *install_steps |
|
||||||
|
|
||||||
install-ruby2.7: |
|
||||||
<<: *defaults |
|
||||||
<<: *install_ruby_dependencies |
|
||||||
|
|
||||||
install-ruby2.6: |
|
||||||
<<: *defaults |
|
||||||
docker: |
|
||||||
- image: circleci/ruby:2.6-buster-node |
|
||||||
environment: *ruby_environment |
|
||||||
<<: *install_ruby_dependencies |
|
||||||
|
|
||||||
install-ruby3.0: |
|
||||||
<<: *defaults |
|
||||||
docker: |
|
||||||
- image: circleci/ruby:3.0-buster-node |
|
||||||
environment: *ruby_environment |
|
||||||
<<: *install_ruby_dependencies |
|
||||||
|
|
||||||
build: |
build: |
||||||
<<: *defaults |
docker: |
||||||
|
- image: cimg/ruby:2.7-node |
||||||
|
environment: |
||||||
|
RAILS_ENV: test |
||||||
steps: |
steps: |
||||||
- *attach_workspace |
- checkout |
||||||
- *install_system_dependencies |
- install-system-dependencies |
||||||
|
- install-ruby-dependencies: |
||||||
|
ruby-version: '2.7' |
||||||
|
- node/install-packages: |
||||||
|
cache-version: v1 |
||||||
|
pkg-manager: yarn |
||||||
- run: |
- run: |
||||||
name: Precompile assets |
|
||||||
command: ./bin/rails assets:precompile |
command: ./bin/rails assets:precompile |
||||||
|
name: Precompile assets |
||||||
- persist_to_workspace: |
- persist_to_workspace: |
||||||
root: ~/projects/ |
|
||||||
paths: |
paths: |
||||||
- ./mastodon/public/assets |
- public/assets |
||||||
- ./mastodon/public/packs-test/ |
- public/packs-test |
||||||
|
root: . |
||||||
|
|
||||||
|
test: |
||||||
|
parameters: |
||||||
|
ruby-version: |
||||||
|
type: string |
||||||
|
executor: |
||||||
|
name: default |
||||||
|
ruby-version: << parameters.ruby-version >> |
||||||
|
environment: |
||||||
|
ALLOW_NOPAM: true |
||||||
|
PAM_ENABLED: true |
||||||
|
PAM_DEFAULT_SERVICE: pam_test |
||||||
|
PAM_CONTROLLED_SERVICE: pam_test_controlled |
||||||
|
parallelism: 4 |
||||||
|
steps: |
||||||
|
- checkout |
||||||
|
- install-system-dependencies |
||||||
|
- run: |
||||||
|
command: sudo apt-get install -y ffmpeg imagemagick libpam-dev |
||||||
|
name: Install additional system dependencies |
||||||
|
- run: |
||||||
|
command: bundle config with 'pam_authentication' |
||||||
|
name: Enable PAM authentication |
||||||
|
- install-ruby-dependencies: |
||||||
|
ruby-version: << parameters.ruby-version >> |
||||||
|
- attach_workspace: |
||||||
|
at: . |
||||||
|
- wait-db |
||||||
|
- run: |
||||||
|
command: ./bin/rails db:create db:schema:load db:seed |
||||||
|
name: Load database schema |
||||||
|
- ruby/rspec-test |
||||||
|
|
||||||
test-migrations: |
test-migrations: |
||||||
<<: *defaults |
executor: |
||||||
docker: |
name: default |
||||||
- image: circleci/ruby:2.7-buster-node |
ruby-version: '2.7' |
||||||
environment: *ruby_environment |
|
||||||
- image: circleci/postgres:12.2 |
|
||||||
environment: |
|
||||||
POSTGRES_USER: root |
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust |
|
||||||
- image: circleci/redis:5-alpine |
|
||||||
steps: |
steps: |
||||||
- *attach_workspace |
- checkout |
||||||
- *install_system_dependencies |
- install-system-dependencies |
||||||
|
- install-ruby-dependencies: |
||||||
|
ruby-version: '2.7' |
||||||
|
- wait-db |
||||||
- run: |
- run: |
||||||
name: Create database |
|
||||||
command: ./bin/rails db:create |
command: ./bin/rails db:create |
||||||
|
name: Create database |
||||||
- run: |
- run: |
||||||
name: Run migrations |
|
||||||
command: ./bin/rails db:migrate |
command: ./bin/rails db:migrate |
||||||
|
name: Run migrations |
||||||
test-ruby2.7: |
|
||||||
<<: *defaults |
|
||||||
docker: |
|
||||||
- image: circleci/ruby:2.7-buster-node |
|
||||||
environment: *ruby_environment |
|
||||||
- image: circleci/postgres:12.2 |
|
||||||
environment: |
|
||||||
POSTGRES_USER: root |
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust |
|
||||||
- image: circleci/redis:5-alpine |
|
||||||
<<: *test_steps |
|
||||||
|
|
||||||
test-ruby2.6: |
|
||||||
<<: *defaults |
|
||||||
docker: |
|
||||||
- image: circleci/ruby:2.6-buster-node |
|
||||||
environment: *ruby_environment |
|
||||||
- image: circleci/postgres:12.2 |
|
||||||
environment: |
|
||||||
POSTGRES_USER: root |
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust |
|
||||||
- image: circleci/redis:5-alpine |
|
||||||
<<: *test_steps |
|
||||||
|
|
||||||
test-ruby3.0: |
|
||||||
<<: *defaults |
|
||||||
docker: |
|
||||||
- image: circleci/ruby:3.0-buster-node |
|
||||||
environment: *ruby_environment |
|
||||||
- image: circleci/postgres:12.2 |
|
||||||
environment: |
|
||||||
POSTGRES_USER: root |
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust |
|
||||||
- image: circleci/redis:5-alpine |
|
||||||
<<: *test_steps |
|
||||||
|
|
||||||
test-webui: |
|
||||||
<<: *defaults |
|
||||||
docker: |
|
||||||
- image: circleci/node:14-buster |
|
||||||
steps: |
|
||||||
- *attach_workspace |
|
||||||
- run: |
|
||||||
name: Run jest |
|
||||||
command: yarn test:jest |
|
||||||
|
|
||||||
workflows: |
workflows: |
||||||
version: 2 |
version: 2 |
||||||
build-and-test: |
build-and-test: |
||||||
jobs: |
jobs: |
||||||
- install |
- build |
||||||
- install-ruby2.7: |
- test: |
||||||
requires: |
matrix: |
||||||
- install |
parameters: |
||||||
- install-ruby2.6: |
ruby-version: |
||||||
requires: |
- '2.7' |
||||||
- install |
- '3.0' |
||||||
- install-ruby2.7 |
name: test-ruby<< matrix.ruby-version >> |
||||||
- install-ruby3.0: |
|
||||||
requires: |
requires: |
||||||
- install |
|
||||||
- install-ruby2.7 |
|
||||||
- build: |
|
||||||
requires: |
|
||||||
- install-ruby2.7 |
|
||||||
- test-migrations: |
|
||||||
requires: |
|
||||||
- install-ruby2.7 |
|
||||||
- test-ruby2.7: |
|
||||||
requires: |
|
||||||
- install-ruby2.7 |
|
||||||
- build |
- build |
||||||
- test-ruby2.6: |
- test-migrations: |
||||||
requires: |
requires: |
||||||
- install-ruby2.6 |
|
||||||
- build |
- build |
||||||
- test-ruby3.0: |
- node/run: |
||||||
|
cache-version: v1 |
||||||
|
name: test-webui |
||||||
|
pkg-manager: yarn |
||||||
requires: |
requires: |
||||||
- install-ruby3.0 |
|
||||||
- build |
- build |
||||||
- test-webui: |
version: lts |
||||||
requires: |
yarn-run: test:jest |
||||||
- install |
|
||||||
|
Loading…
Reference in new issue