123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- version: 2
- aliases:
- - &defaults
- docker:
- - image: circleci/ruby:2.7-buster-node
- environment: &ruby_environment
- BUNDLE_JOBS: 3
- BUNDLE_RETRY: 3
- BUNDLE_APP_CONFIG: ./.bundle/
- BUNDLE_PATH: ./vendor/bundle/
- DB_HOST: localhost
- DB_USER: root
- RAILS_ENV: test
- ALLOW_NOPAM: true
- CONTINUOUS_INTEGRATION: true
- DISABLE_SIMPLECOV: true
- PAM_ENABLED: true
- PAM_DEFAULT_SERVICE: pam_test
- PAM_CONTROLLED_SERVICE: pam_test_controlled
- working_directory: ~/projects/mastodon/
- - &attach_workspace
- 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
- steps:
- - checkout
- - *attach_workspace
- - restore_cache:
- keys:
- - v2-node-dependencies-{{ checksum "yarn.lock" }}
- - v2-node-dependencies-
- - run:
- name: Install yarn dependencies
- command: yarn install --frozen-lockfile
- - save_cache:
- key: v2-node-dependencies-{{ checksum "yarn.lock" }}
- paths:
- - ./node_modules/
- - *persist_to_workspace
- - &install_system_dependencies
- run:
- name: Install system dependencies
- command: |
- sudo apt-get update
- sudo apt-get install -y libicu-dev libidn11-dev libprotobuf-dev protobuf-compiler
- - &install_ruby_dependencies
- steps:
- - *attach_workspace
- - *install_system_dependencies
- - run:
- name: Set Ruby version
- command: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version
- - *restore_ruby_dependencies
- - 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:
- 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:
- <<: *defaults
- steps:
- - *attach_workspace
- - *install_system_dependencies
- - run:
- name: Precompile assets
- command: ./bin/rails assets:precompile
- - persist_to_workspace:
- root: ~/projects/
- paths:
- - ./mastodon/public/assets
- - ./mastodon/public/packs-test/
- test-migrations:
- <<: *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
- steps:
- - *attach_workspace
- - *install_system_dependencies
- - run:
- name: Create database
- command: ./bin/rails db:create
- - run:
- command: ./bin/rails db:migrate VERSION=20171010025614
- name: Run migrations up to v2.0.0
- - run:
- command: ./bin/rails tests:migrations:populate_v2
- name: Populate database with test data
- - run:
- command: ./bin/rails db:migrate
- name: Run all remaining migrations
- test-two-step-migrations:
- <<: *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
- steps:
- - *attach_workspace
- - *install_system_dependencies
- - run:
- command: ./bin/rails db:create
- name: Create database
- - run:
- command: ./bin/rails db:migrate VERSION=20171010025614
- name: Run migrations up to v2.0.0
- - run:
- command: ./bin/rails tests:migrations:populate_v2
- name: Populate database with test data
- - run:
- command: ./bin/rails db:migrate
- name: Run all pre-deployment migrations
- evironment:
- SKIP_POST_DEPLOYMENT_MIGRATIONS: true
- - run:
- command: ./bin/rails db:migrate
- name: Run all post-deployment remaining 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:12-buster
- steps:
- - *attach_workspace
- - run:
- name: Run jest
- command: yarn test:jest
- workflows:
- version: 2
- build-and-test:
- jobs:
- - install
- - install-ruby2.7:
- requires:
- - install
- - install-ruby2.6:
- requires:
- - install
- - install-ruby2.7
- - install-ruby3.0:
- requires:
- - install
- - install-ruby2.7
- - build:
- requires:
- - install-ruby2.7
- - test-migrations:
- requires:
- - install-ruby2.7
- - test-two-step-migrations:
- requires:
- - install-ruby2.7
- - test-ruby2.7:
- requires:
- - install-ruby2.7
- - build
- - test-ruby2.6:
- requires:
- - install-ruby2.6
- - build
- - test-ruby3.0:
- requires:
- - install-ruby3.0
- - build
- - test-webui:
- requires:
- - install
|