Repository navigation
130 lines (112 loc) · 4.21 KB
/
Copy pathci.yml
File metadata and controls
130 lines (112 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Build and run tests
env:
BUNDLER_VERSION_PIN: "4.0.20"
on:
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
scan_ruby:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
bundler: ${{ env.BUNDLER_VERSION_PIN }}
- name: Check Bundler version matches lockfile
run: |
locked=$(sed -n '/^BUNDLED WITH$/{n;s/^ *//;p;}' Gemfile.lock)
echo "Gemfile.lock: $locked / CI pin: $BUNDLER_VERSION_PIN"
if [ "$locked" != "$BUNDLER_VERSION_PIN" ]; then
echo "::error file=Gemfile.lock::BUNDLED WITH is $locked but CI pins Bundler $BUNDLER_VERSION_PIN"
exit 1
fi
- name: Scan for common Rails security vulnerabilities using static analysis
run: bin/brakeman --no-pager
- name: Scan for known security vulnerabilities in gems used
run: bin/bundler-audit
build-and-test:
runs-on: ubuntu-latest
# The suite splits into 8 runtime-balanced groups; each shard runs 4 of them
# on its runner's 4 vCPUs. Group N uses database awbw_testN, so every shard
# creates all 8. Both shards read the same committed runtime log, so they
# agree on the grouping — refresh it with bin/parallel_runtime_log.
strategy:
fail-fast: false
matrix:
shard: [ "1,2,3,4", "5,6,7,8" ]
env:
PARALLEL_TEST_PROCESSORS: 8
services:
mysql:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: ''
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_DATABASE: awbw_test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=10
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
bundler: ${{ env.BUNDLER_VERSION_PIN }}
- uses: actions/setup-node@v7
with:
node-version: 22
- run: npm ci
# Precompile assets once up front. Vite's autoBuild would otherwise have
# each parallel_tests process build into the shared public/vite-test dir
# at first request, and those concurrent builds corrupt each other.
- name: Build test assets
run: bin/vite build --mode test
env:
RAILS_ENV: test
- name: Setup databases
run: |
bundle exec rake parallel:create parallel:load_schema
env:
RAILS_ENV: test
# AWS credentials
AWS_REGION: ${{ vars.AWS_REGION }}
AWS_S3_BUCKET: ${{ vars.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# SMTP settings
SMTP_SERVER: ${{ secrets.SMTP_SERVER }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SMTP_USERNAME: ${{ secrets.SMTP_USERNAME }}
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
- name: Run tests and publish results
run: bundle exec parallel_rspec spec/ -n 8 --only-group ${{ matrix.shard }} --group-by runtime --runtime-log spec/parallel_runtime_rspec.log
env:
RAILS_ENV: test
# Assets are prebuilt above; never let a test process rebuild them
# (concurrent rebuilds race on the shared output dir).
VITE_RUBY_AUTO_BUILD: "false"
# AWS credentials
AWS_REGION: ${{ vars.AWS_REGION }}
AWS_S3_BUCKET: ${{ vars.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# SMTP settings
SMTP_SERVER: ${{ secrets.SMTP_SERVER }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SMTP_USERNAME: ${{ secrets.SMTP_USERNAME }}
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
CI: "true"
- name: Publish test results
uses: actions/upload-artifact@v7
if: always()
with:
name: rspec-results-${{ strategy.job-index }}
path: tmp/rspec_results/