|
1 | 1 | image: ci_app_base |
2 | | -architectures: ["arm64", "amd64"] |
| 2 | +architectures: ["amd64", "arm64"] |
3 | 3 | resource_class: large |
4 | | -source_files: rspec |
5 | | -parallelism: 2 |
| 4 | +parallelism: 12 |
| 5 | + |
| 6 | +requires: |
| 7 | + - "install_gems" |
| 8 | + - "compile_rails_assets_test" |
| 9 | + - "compile_client_webpack_test" |
| 10 | + |
| 11 | +services: ["postgres", "redis", "minio"] |
6 | 12 |
|
7 | 13 | restore_cache: |
8 | 14 | - gems |
9 | | - - npm_packages |
10 | | - - name: bootsnap |
11 | | - dependency: false |
| 15 | + - bootsnap |
12 | 16 | - rails_assets |
13 | | - |
14 | | -services: |
15 | | - - postgres |
16 | | - - redis |
17 | | - - minio |
| 17 | + - npm_packages |
18 | 18 |
|
19 | 19 | steps: |
20 | | - - setup_database |
21 | 20 | - run: |
22 | | - name: Split RSpec tests by timing |
23 | | - command: | |
24 | | - circleci tests glob "spec/**/*_spec.rb" \ |
25 | | - | circleci tests split --split-by=timings \ |
26 | | - > /tmp/split-rspec-tests |
| 21 | + name: Setup database |
| 22 | + command: bundle exec rails db:create db:schema:load --trace |
27 | 23 |
|
28 | 24 | - run: |
29 | | - name: Run RSpec |
30 | | - command: | |
31 | | - rspec \ |
32 | | - --seed << pipeline.number >> \ |
33 | | - --format RspecJunitFormatter \ |
34 | | - --out spec/results/rspec.xml \ |
35 | | - $(cat /tmp/split-rspec-tests) |
| 25 | + name: Check Shrine Version is 3.x |
| 26 | + command: bundle exec rails runner "puts Shrine.version" | grep "3\." |
| 27 | + |
| 28 | + - run: |
| 29 | + name: Remove unneeded files for test environment |
| 30 | + command: echo "Removing development files not needed for test environment" |
36 | 31 |
|
37 | 32 | - run: |
38 | | - name: Delete artifacts for successful job |
39 | | - command: rm -rf spec/artifacts log |
| 33 | + name: Run RSpec tests |
| 34 | + command: | |
| 35 | + # Run RSpec with parallel execution |
| 36 | + TESTFILES=$(bundle exec rspec --dry-run --format json | \ |
| 37 | + jq -r '.examples[].file_path' | sort | uniq | \ |
| 38 | + awk "NR % $CIRCLE_NODE_TOTAL == $CIRCLE_NODE_INDEX") |
| 39 | +
|
| 40 | + if [ -n "$TESTFILES" ]; then |
| 41 | + echo "Running RSpec tests on node $CIRCLE_NODE_INDEX of $CIRCLE_NODE_TOTAL" |
| 42 | + echo "Test files for this node:" |
| 43 | + echo "$TESTFILES" |
| 44 | +
|
| 45 | + bundle exec rspec \ |
| 46 | + --format progress \ |
| 47 | + --format RspecJunitFormatter \ |
| 48 | + --out tmp/rspec/rspec-${CIRCLE_NODE_INDEX}.xml \ |
| 49 | + $TESTFILES |
| 50 | + else |
| 51 | + echo "No test files assigned to this node" |
| 52 | + fi |
| 53 | +
|
40 | 54 | - store_test_results: |
41 | | - path: spec/results/rspec.xml |
42 | | - - store_artifacts: |
43 | | - path: spec/artifacts |
44 | | - - store_artifacts: |
45 | | - path: coverage |
| 55 | + path: tmp/rspec |
| 56 | + |
46 | 57 | - store_artifacts: |
47 | | - path: log |
| 58 | + path: tmp/rspec |
| 59 | + destination: rspec |
0 commit comments