|
1 | | -version: 2 |
| 1 | +version: 2.1 |
2 | 2 |
|
3 | | -aliases: |
4 | | - - &defaults |
| 3 | +orbs: |
| 4 | + ruby: circleci/ruby@1.4.1 |
| 5 | + node: circleci/node@5.0.1 |
| 6 | + |
| 7 | +executors: |
| 8 | + default: |
| 9 | + parameters: |
| 10 | + ruby-version: |
| 11 | + type: string |
5 | 12 | docker: |
6 | | - - image: cimg/ruby:2.7-node |
7 | | - environment: &ruby_environment |
| 13 | + - image: cimg/ruby:<< parameters.ruby-version >> |
| 14 | + environment: |
8 | 15 | BUNDLE_JOBS: 3 |
9 | 16 | BUNDLE_RETRY: 3 |
10 | | - BUNDLE_APP_CONFIG: ./.bundle/ |
11 | | - BUNDLE_PATH: ./vendor/bundle/ |
| 17 | + CONTINUOUS_INTEGRATION: true |
12 | 18 | DB_HOST: localhost |
13 | 19 | DB_USER: root |
14 | | - RAILS_ENV: test |
15 | | - ALLOW_NOPAM: true |
16 | | - CONTINUOUS_INTEGRATION: true |
17 | 20 | DISABLE_SIMPLECOV: true |
18 | | - PAM_ENABLED: true |
19 | | - PAM_DEFAULT_SERVICE: pam_test |
20 | | - PAM_CONTROLLED_SERVICE: pam_test_controlled |
21 | | - working_directory: ~/projects/mastodon/ |
22 | | - |
23 | | - - &attach_workspace |
24 | | - attach_workspace: |
25 | | - at: ~/projects/ |
26 | | - |
27 | | - - &persist_to_workspace |
28 | | - persist_to_workspace: |
29 | | - root: ~/projects/ |
30 | | - paths: |
31 | | - - ./mastodon/ |
32 | | - |
33 | | - - &restore_ruby_dependencies |
34 | | - restore_cache: |
35 | | - keys: |
36 | | - - v3-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }} |
37 | | - - v3-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}- |
38 | | - - v3-ruby-dependencies- |
| 21 | + RAILS_ENV: test |
| 22 | + - image: cimg/postgres:14.0 |
| 23 | + environment: |
| 24 | + POSTGRES_USER: root |
| 25 | + POSTGRES_HOST_AUTH_METHOD: trust |
| 26 | + - image: cimg/redis:6.2 |
39 | 27 |
|
40 | | - - &install_steps |
| 28 | +commands: |
| 29 | + install-system-dependencies: |
41 | 30 | steps: |
42 | | - - checkout |
43 | | - - *attach_workspace |
44 | | - - restore_cache: |
45 | | - keys: |
46 | | - - v2-node-dependencies-{{ checksum "yarn.lock" }} |
47 | | - - v2-node-dependencies- |
48 | 31 | - run: |
49 | | - name: Install yarn dependencies |
50 | | - command: yarn install --frozen-lockfile |
51 | | - - save_cache: |
52 | | - key: v2-node-dependencies-{{ checksum "yarn.lock" }} |
53 | | - paths: |
54 | | - - ./node_modules/ |
55 | | - - *persist_to_workspace |
56 | | - |
57 | | - - &install_system_dependencies |
58 | | - run: |
59 | | - name: Install system dependencies |
60 | | - command: | |
61 | | - sudo apt-get update |
62 | | - sudo apt-get install -y libicu-dev libidn11-dev libprotobuf-dev protobuf-compiler |
63 | | -
|
64 | | - - &install_ruby_dependencies |
65 | | - steps: |
66 | | - - *attach_workspace |
67 | | - - *install_system_dependencies |
68 | | - - run: |
69 | | - name: Set Ruby version |
70 | | - command: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version |
71 | | - - *restore_ruby_dependencies |
72 | | - - run: |
73 | | - name: Set bundler settings |
74 | | - command: | |
75 | | - bundle config --local clean 'true' |
76 | | - bundle config --local deployment 'true' |
77 | | - bundle config --local with 'pam_authentication' |
78 | | - bundle config --local without 'development production' |
79 | | - bundle config --local frozen 'true' |
80 | | - bundle config --local path $BUNDLE_PATH |
81 | | - - run: |
82 | | - name: Install bundler dependencies |
83 | | - command: bundle check || (bundle install && bundle clean) |
84 | | - - save_cache: |
85 | | - key: v3-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }} |
86 | | - paths: |
87 | | - - ./.bundle/ |
88 | | - - ./vendor/bundle/ |
89 | | - - persist_to_workspace: |
90 | | - root: ~/projects/ |
91 | | - paths: |
92 | | - - ./mastodon/.bundle/ |
93 | | - - ./mastodon/vendor/bundle/ |
| 32 | + name: Install system dependencies |
| 33 | + command: | |
| 34 | + sudo apt-get update |
| 35 | + sudo apt-get install -y libicu-dev libidn11-dev libprotobuf-dev protobuf-compiler |
| 36 | + install-ruby-dependencies: |
| 37 | + parameters: |
| 38 | + ruby-version: |
| 39 | + type: string |
| 40 | + steps: |
| 41 | + - run: |
| 42 | + command: | |
| 43 | + bundle config clean 'true' |
| 44 | + bundle config frozen 'true' |
| 45 | + bundle config without 'development production' |
| 46 | + name: Set bundler settings |
| 47 | + - ruby/install-deps: |
| 48 | + bundler-version: '2.3.8' |
| 49 | + key: ruby<< parameters.ruby-version >>-gems-v1 |
| 50 | + wait-db: |
| 51 | + steps: |
| 52 | + - run: |
| 53 | + command: dockerize -wait tcp://localhost:5432 -wait tcp://localhost:6379 -timeout 1m |
| 54 | + name: Wait for PostgreSQL and Redis |
94 | 55 |
|
95 | | - - &test_steps |
96 | | - parallelism: 4 |
97 | | - steps: |
98 | | - - *attach_workspace |
99 | | - - *install_system_dependencies |
100 | | - - run: |
101 | | - name: Install FFMPEG |
102 | | - command: sudo apt-get install -y ffmpeg |
103 | | - - run: |
104 | | - name: Load database schema |
105 | | - command: ./bin/rails db:create db:schema:load db:seed |
106 | | - - run: |
107 | | - name: Run rspec in parallel |
108 | | - command: | |
109 | | - bundle exec rspec --profile 10 \ |
110 | | - --format RspecJunitFormatter \ |
111 | | - --out test_results/rspec.xml \ |
112 | | - --format progress \ |
113 | | - $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) |
114 | | - - store_test_results: |
115 | | - path: test_results |
116 | 56 | jobs: |
117 | | - install: |
118 | | - <<: *defaults |
119 | | - <<: *install_steps |
120 | | - |
121 | | - install-ruby2.7: |
122 | | - <<: *defaults |
123 | | - <<: *install_ruby_dependencies |
124 | | - |
125 | | - install-ruby2.6: |
126 | | - <<: *defaults |
127 | | - docker: |
128 | | - - image: cimg/ruby:2.6-node |
129 | | - environment: *ruby_environment |
130 | | - <<: *install_ruby_dependencies |
131 | | - |
132 | | - install-ruby3.0: |
133 | | - <<: *defaults |
| 57 | + build: |
134 | 58 | docker: |
135 | 59 | - image: cimg/ruby:3.0-node |
136 | | - environment: *ruby_environment |
137 | | - <<: *install_ruby_dependencies |
138 | | - |
139 | | - build: |
140 | | - <<: *defaults |
| 60 | + environment: |
| 61 | + RAILS_ENV: test |
141 | 62 | steps: |
142 | | - - *attach_workspace |
143 | | - - *install_system_dependencies |
| 63 | + - checkout |
| 64 | + - install-system-dependencies |
| 65 | + - install-ruby-dependencies: |
| 66 | + ruby-version: '3.0' |
| 67 | + - node/install-packages: |
| 68 | + cache-version: v1 |
| 69 | + pkg-manager: yarn |
144 | 70 | - run: |
| 71 | + command: | |
| 72 | + export NODE_OPTIONS=--openssl-legacy-provider |
| 73 | + ./bin/rails assets:precompile |
145 | 74 | name: Precompile assets |
146 | | - command: ./bin/rails assets:precompile |
147 | 75 | - persist_to_workspace: |
148 | | - root: ~/projects/ |
149 | 76 | paths: |
150 | | - - ./mastodon/public/assets |
151 | | - - ./mastodon/public/packs-test/ |
| 77 | + - public/assets |
| 78 | + - public/packs-test |
| 79 | + root: . |
| 80 | + |
| 81 | + test: |
| 82 | + parameters: |
| 83 | + ruby-version: |
| 84 | + type: string |
| 85 | + executor: |
| 86 | + name: default |
| 87 | + ruby-version: << parameters.ruby-version >> |
| 88 | + environment: |
| 89 | + ALLOW_NOPAM: true |
| 90 | + PAM_ENABLED: true |
| 91 | + PAM_DEFAULT_SERVICE: pam_test |
| 92 | + PAM_CONTROLLED_SERVICE: pam_test_controlled |
| 93 | + parallelism: 4 |
| 94 | + steps: |
| 95 | + - checkout |
| 96 | + - install-system-dependencies |
| 97 | + - run: |
| 98 | + command: sudo apt-get install -y ffmpeg imagemagick libpam-dev |
| 99 | + name: Install additional system dependencies |
| 100 | + - run: |
| 101 | + command: bundle config with 'pam_authentication' |
| 102 | + name: Enable PAM authentication |
| 103 | + - install-ruby-dependencies: |
| 104 | + ruby-version: << parameters.ruby-version >> |
| 105 | + - attach_workspace: |
| 106 | + at: . |
| 107 | + - wait-db |
| 108 | + - run: |
| 109 | + command: ./bin/rails db:create db:schema:load db:seed |
| 110 | + name: Load database schema |
| 111 | + - ruby/rspec-test |
152 | 112 |
|
153 | 113 | test-migrations: |
154 | | - <<: *defaults |
155 | | - docker: |
156 | | - - image: cimg/ruby:2.7-node |
157 | | - environment: *ruby_environment |
158 | | - - image: cimg/postgres:12.2 |
159 | | - environment: |
160 | | - POSTGRES_USER: root |
161 | | - POSTGRES_HOST_AUTH_METHOD: trust |
162 | | - - image: cimg/redis:5-alpine |
| 114 | + executor: |
| 115 | + name: default |
| 116 | + ruby-version: '3.0' |
163 | 117 | steps: |
164 | | - - *attach_workspace |
165 | | - - *install_system_dependencies |
| 118 | + - checkout |
| 119 | + - install-system-dependencies |
| 120 | + - install-ruby-dependencies: |
| 121 | + ruby-version: '3.0' |
| 122 | + - wait-db |
166 | 123 | - run: |
167 | | - name: Create database |
168 | 124 | command: ./bin/rails db:create |
| 125 | + name: Create database |
169 | 126 | - run: |
170 | | - name: Run migrations |
171 | 127 | command: ./bin/rails db:migrate |
172 | | - |
173 | | - test-ruby2.7: |
174 | | - <<: *defaults |
175 | | - docker: |
176 | | - - image: cimg/ruby:2.7-node |
177 | | - environment: *ruby_environment |
178 | | - - image: cimg/postgres:12.2 |
179 | | - environment: |
180 | | - POSTGRES_USER: root |
181 | | - POSTGRES_HOST_AUTH_METHOD: trust |
182 | | - - image: cimg/redis:5-alpine |
183 | | - <<: *test_steps |
184 | | - |
185 | | - test-ruby2.6: |
186 | | - <<: *defaults |
187 | | - docker: |
188 | | - - image: cimg/ruby:2.6-node |
189 | | - environment: *ruby_environment |
190 | | - - image: cimg/postgres:12.2 |
191 | | - environment: |
192 | | - POSTGRES_USER: root |
193 | | - POSTGRES_HOST_AUTH_METHOD: trust |
194 | | - - image: cimg/redis:5-alpine |
195 | | - <<: *test_steps |
196 | | - |
197 | | - test-ruby3.0: |
198 | | - <<: *defaults |
199 | | - docker: |
200 | | - - image: cimg/ruby:3.0-node |
201 | | - environment: *ruby_environment |
202 | | - - image: cimg/postgres:12.2 |
203 | | - environment: |
204 | | - POSTGRES_USER: root |
205 | | - POSTGRES_HOST_AUTH_METHOD: trust |
206 | | - - image: cimg/redis:5-alpine |
207 | | - <<: *test_steps |
208 | | - |
209 | | - test-webui: |
210 | | - <<: *defaults |
211 | | - docker: |
212 | | - - image: cimg/node:14.21 |
213 | | - steps: |
214 | | - - *attach_workspace |
215 | | - - run: |
216 | | - name: Run jest |
217 | | - command: yarn test:jest |
| 128 | + name: Run all remaining migrations |
218 | 129 |
|
219 | 130 | workflows: |
220 | 131 | version: 2 |
221 | 132 | build-and-test: |
222 | 133 | jobs: |
223 | | - - install |
224 | | - - install-ruby2.7: |
225 | | - requires: |
226 | | - - install |
227 | | - - install-ruby2.6: |
| 134 | + - build |
| 135 | + - test: |
| 136 | + matrix: |
| 137 | + parameters: |
| 138 | + ruby-version: |
| 139 | + - '2.7' |
| 140 | + - '3.0' |
| 141 | + name: test-ruby<< matrix.ruby-version >> |
228 | 142 | requires: |
229 | | - - install |
230 | | - - install-ruby2.7 |
231 | | - - install-ruby3.0: |
232 | | - requires: |
233 | | - - install |
234 | | - - install-ruby2.7 |
235 | | - - build: |
236 | | - requires: |
237 | | - - install-ruby2.7 |
238 | | - - test-migrations: |
239 | | - requires: |
240 | | - - install-ruby2.7 |
241 | | - - test-ruby2.7: |
242 | | - requires: |
243 | | - - install-ruby2.7 |
244 | 143 | - build |
245 | | - - test-ruby2.6: |
| 144 | + - test-migrations: |
246 | 145 | requires: |
247 | | - - install-ruby2.6 |
248 | 146 | - build |
249 | | - - test-ruby3.0: |
| 147 | + - node/run: |
| 148 | + cache-version: v1 |
| 149 | + name: test-webui |
| 150 | + pkg-manager: yarn |
250 | 151 | requires: |
251 | | - - install-ruby3.0 |
252 | 152 | - build |
253 | | - - test-webui: |
254 | | - requires: |
255 | | - - install |
| 153 | + version: lts |
| 154 | + yarn-run: test:jest |
| 155 | + |
0 commit comments