config.yml 5.59 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
version: 2

aliases:
  - &defaults
    docker:
      - image: circleci/ruby:2.5.1-stretch-node
        environment: &ruby_environment
          BUNDLE_APP_CONFIG: ./.bundle/
          DB_HOST: localhost
          DB_USER: root
11 12
          RAILS_ENV: test
          PARALLEL_TEST_PROCESSORS: 4
13
          ALLOW_NOPAM: true
14
          CONTINUOUS_INTEGRATION: true
15
          DISABLE_SIMPLECOV: true
16 17
          PAM_ENABLED: true
          PAM_DEFAULT_SERVICE: pam_test
18
          PAM_CONTROLLED_SERVICE: pam_test_controlled
19 20 21 22 23 24 25 26 27 28 29 30
    working_directory: ~/projects/mastodon/

  - &attach_workspace
    attach_workspace:
      at: ~/projects/

  - &persist_to_workspace
    persist_to_workspace:
      root: ~/projects/
      paths:
        - ./mastodon/

31 32 33 34 35
  - &restore_ruby_dependencies
    restore_cache:
      keys:
        - v2-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
        - v2-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-
36
        - v2-ruby-dependencies-
37

38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
  - &install_steps
    steps:
      - checkout
      - *attach_workspace

      - restore_cache:
          keys:
            - v1-node-dependencies-{{ checksum "yarn.lock" }}
            - v1-node-dependencies-
      - run: yarn install --frozen-lockfile
      - save_cache:
          key: v1-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: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version
69
        - *restore_ruby_dependencies
70
        - run: bundle install --clean --jobs 16 --path ./vendor/bundle/ --retry 3 --with pam_authentication --without development production && bundle clean
71
        - save_cache:
72
            key: v2-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
73
            paths:
74
              - ./.bundle/
75
              - ./vendor/bundle/
76 77 78 79 80
        - persist_to_workspace:
            root: ~/projects/
            paths:
                - ./mastodon/.bundle/
                - ./mastodon/vendor/bundle/
81 82 83 84 85 86 87 88 89 90 91 92 93

  - &test_steps
      steps:
        - *attach_workspace

        - *install_system_dependencies
        - run: sudo apt-get install -y ffmpeg

        - run:
            name: Prepare Tests
            command: ./bin/rails parallel:create parallel:load_schema parallel:prepare
        - run:
            name: Run Tests
94
            command: ./bin/retry bundle exec parallel_test ./spec/ --group-by filesize --type rspec
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111

jobs:
  install:
    <<: *defaults
    <<: *install_steps

  install-ruby2.5:
    <<: *defaults
    <<: *install_ruby_dependencies

  install-ruby2.4:
    <<: *defaults
    docker:
      - image: circleci/ruby:2.4.4-stretch-node
        environment: *ruby_environment
    <<: *install_ruby_dependencies

112 113 114 115 116 117 118
  install-ruby2.3:
    <<: *defaults
    docker:
      - image: circleci/ruby:2.3.7-stretch-node
        environment: *ruby_environment
    <<: *install_ruby_dependencies

119 120 121 122 123 124
  build:
    <<: *defaults
    steps:
      - *attach_workspace
      - *install_system_dependencies
      - run: ./bin/rails assets:precompile
125 126
      - persist_to_workspace:
          root: ~/projects/
127
          paths:
128 129
              - ./mastodon/public/assets
              - ./mastodon/public/packs-test/
130

131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
  test-ruby2.5:
    <<: *defaults
    docker:
      - image: circleci/ruby:2.5.1-stretch-node
        environment: *ruby_environment
      - image: circleci/postgres:10.3-alpine
        environment:
          POSTGRES_USER: root
      - image: circleci/redis:4.0.9-alpine
    <<: *test_steps

  test-ruby2.4:
    <<: *defaults
    docker:
      - image: circleci/ruby:2.4.4-stretch-node
        environment: *ruby_environment
      - image: circleci/postgres:10.3-alpine
        environment:
          POSTGRES_USER: root
      - image: circleci/redis:4.0.9-alpine
    <<: *test_steps

153 154 155 156 157 158 159 160 161 162 163
  test-ruby2.3:
    <<: *defaults
    docker:
      - image: circleci/ruby:2.3.7-stretch-node
        environment: *ruby_environment
      - image: circleci/postgres:10.3-alpine
        environment:
          POSTGRES_USER: root
      - image: circleci/redis:4.0.9-alpine
    <<: *test_steps

164 165 166 167 168 169
  test-webui:
    <<: *defaults
    docker:
      - image: circleci/node:8.11.1-stretch
    steps:
      - *attach_workspace
170
      - run: ./bin/retry yarn test:jest
171 172 173 174 175 176 177

  check-i18n:
    <<: *defaults
    steps:
      - *attach_workspace
      - run: bundle exec i18n-tasks check-normalized
      - run: bundle exec i18n-tasks unused
178
      - run: bundle exec i18n-tasks missing -t plural
179
      - run: bundle exec i18n-tasks check-consistent-interpolations
180 181 182 183 184 185 186 187 188 189

workflows:
  version: 2
  build-and-test:
    jobs:
      - install
      - install-ruby2.5:
          requires:
            - install
      - install-ruby2.4:
190 191
          requires:
            - install
192
            - install-ruby2.5
193 194 195
      - install-ruby2.3:
          requires:
            - install
196
            - install-ruby2.5
197
      - build:
198 199 200 201 202
          requires:
            - install-ruby2.5
      - test-ruby2.5:
          requires:
            - install-ruby2.5
203
            - build
204 205 206
      - test-ruby2.4:
          requires:
            - install-ruby2.4
207
            - build
208 209 210 211
      - test-ruby2.3:
          requires:
            - install-ruby2.3
            - build
212 213 214 215 216 217
      - test-webui:
          requires:
            - install
      - check-i18n:
          requires:
            - install-ruby2.5