-
-
Notifications
You must be signed in to change notification settings - Fork 202
173 lines (148 loc) Β· 5.48 KB
/
Copy pathruby.yml
File metadata and controls
173 lines (148 loc) Β· 5.48 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: CI
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
test:
name: 'Tests (Group ${{ matrix.ci_node_index }})'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ci_node_total: [6]
ci_node_index: [0, 1, 2, 3, 4, 5]
env:
# prevent unnecessary log output -- https://bundler.io/man/bundle-config.1.html
BUNDLE_IGNORE_FUNDING_REQUESTS: true
BUNDLE_IGNORE_MESSAGES: true
RAILS_ENV: test
COVERAGE: true
PARALLEL_TEST_PROCESSORS: ${{ matrix.ci_node_total }}
services:
postgres:
image: postgres:17
ports: ["5432:5432"]
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
# .ruby-version provides the Ruby version implicitly.
bundler-cache: true
- name: Resolve Playwright version from gem
id: pw-version
run: echo "version=$(bundle exec ruby -rplaywright -e 'print Playwright::COMPATIBLE_PLAYWRIGHT_VERSION')" >> $GITHUB_OUTPUT
- name: Cache npx packages
uses: actions/cache@v6
id: npx-cache
with:
path: ~/.npm
# npx downloads the playwright npm package (~30MB) fresh every time without
# this cache. The key includes the Playwright version so a bump invalidates it.
key: npx-playwright-${{ runner.os }}-${{ steps.pw-version.outputs.version }}
- name: Cache Playwright browsers
uses: actions/cache@v6
id: playwright-cache
with:
path: ~/.cache/ms-playwright
# All groups use the same key β the binary is identical across parallel runners.
# Without this, each group writes its own cache entry for the same ~150MB blob
# (6Γ storage, 6Γ uploads for no benefit).
key: playwright-${{ runner.os }}-chromium-headless-shell-${{ steps.pw-version.outputs.version }}
- name: Install Playwright Chromium Headless Shell
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx --yes playwright@${{ steps.pw-version.outputs.version }} install chromium-headless-shell
- name: Verify Playwright binary (cache restore)
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: |
# Quick validation that the cached binary is intact.
# Falls through to a full install if the expected path is missing.
ls ~/.cache/ms-playwright/chromium-headless-shell-*/chrome-linux/chrome > /dev/null 2>&1 || \
npx --yes playwright@${{ steps.pw-version.outputs.version }} install chromium-headless-shell
# Playwright install-deps is intentionally skipped: ubuntu-24.04 ships all required
# system libraries. install-deps would only add 9 font packages (CJK + X11, ~21MB)
# that are not needed for headless-shell rendering in CI. If a Playwright version
# introduces a new system library dependency, re-add:
# run: npx --yes playwright@${{ steps.pw-version.outputs.version }} install-deps chromium-headless-shell
- name: Setup test databases
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432
run: |
bundle exec rake parallel:setup
- name: Run tests in parallel
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
RAILS_ENV: test
PLAYWRIGHT_HEADLESS: true
run: |
bundle exec parallel_rspec spec/ \
-n ${{ matrix.ci_node_total }} \
--only-group ${{ matrix.ci_node_index }}
- name: Preserve coverage results
run: |
# Copy resultset immediately after tests complete to prevent deletion
cp coverage/.resultset.json coverage/resultset-${{ matrix.ci_node_index }}.json
- name: Upload coverage artifacts
uses: actions/upload-artifact@v7
with:
name: coverage-${{ matrix.ci_node_index }}
path: coverage/resultset-${{ matrix.ci_node_index }}.json
retention-days: 1
security-audit:
name: 'Security Audit'
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
- name: Run bundler-audit
run: bundle exec bundler-audit check
coverage:
name: 'Report Coverage'
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Download all coverage artifacts
uses: actions/download-artifact@v8
with:
path: coverage-results
- name: Merge coverage results
run: |
mkdir -p coverage
bundle exec ruby -e '
require "json"
require "simplecov"
resultsets = {}
Dir["coverage-results/coverage-*/resultset-*.json"].each do |file|
data = JSON.parse(File.read(file))
resultsets.merge!(data)
end
File.write("coverage/.resultset.json", JSON.generate(resultsets))
'
- name: Report to Coveralls
continue-on-error: true
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.github_token }}