-
Notifications
You must be signed in to change notification settings - Fork 1
230 lines (210 loc) · 7.44 KB
/
tests.yml
File metadata and controls
230 lines (210 loc) · 7.44 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
---
# This file is @generated by `bin/rails generate test_strategy test_strategy_timings.csv`
# Please edit the template and regenerate, rather than edit this file.
name: Tests
on: [pull_request]
permissions:
contents: read
actions: read
jobs:
integration_test_matrix:
strategy:
fail-fast: false
matrix:
ruby-version:
- '3.3.9'
test-group:
- "[a-b]"
- "[c]"
- "[d-m]"
- "[n-z]"
name: "Ruby ${{ matrix.ruby-version }} Integration Tests (${{ matrix.test-group }})"
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_USER: rails
POSTGRES_PASSWORD: rails_password
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--name postgres
ports:
- 5432:5432
env:
DB_HOST: localhost
DB_PORT: 5432
DB_USERNAME: rails
DB_PASSWORD: rails_password
# Prep the whole stack in test-only mode:
RAILS_ENV: test
steps:
- uses: actions/checkout@v3
- name: Set timezone to Europe/London
run: sudo timedatectl set-timezone Europe/London
- name: Use bundled npm files
run: printf 'disable-self-update-check true\nyarn-offline-mirror "./vendor/npm-packages-offline-cache"\nyarn-offline-mirror-pruning false\n' > .yarnrc
- name: Set up Ruby + Bundle
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ${{ matrix.ruby-version }}
- name: Inject configuration
run: cp config/database.yml{.ci,}
- name: Prepare the database
run: bin/rails db:setup
- name: Precompile assets
# Since ruby/setup-ruby@v1 moved to Node.js v18 we need the extra options
# until we move to newer webpacker / stop using it.
# I've tried using a newer hash function in config/webpack/environment.js
# by adding the following line, but this didn't help with github actions
# # environment.config.set('output.hashFunction', 'sha256')
# https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported/73465262#73465262
run: NODE_OPTIONS=--openssl-legacy-provider bin/rails yarn:install assets:clobber assets:precompile
- name: Run tests
run: PARALLEL_WORKERS=1 bin/rails test 'test/integration/**/${{ matrix.test-group }}*_test.rb'
# A utility job upon which Branch Protection can depend,
# thus remaining agnostic of the matrix.
integration_tests:
if: ${{ always() }}
runs-on: ubuntu-latest
# name: Matrix
needs: integration_test_matrix
steps:
- name: Check build matrix status
if: ${{ needs.integration_test_matrix.result != 'success' }}
run: exit 1
remaining_test_matrix:
strategy:
fail-fast: false
matrix:
ruby-version:
- '3.3.9'
test-group:
- "[a-z]"
name: "Ruby ${{ matrix.ruby-version }} Remaining Tests (${{ matrix.test-group }})"
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_USER: rails
POSTGRES_PASSWORD: rails_password
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--name postgres
ports:
- 5432:5432
env:
DB_HOST: localhost
DB_PORT: 5432
DB_USERNAME: rails
DB_PASSWORD: rails_password
# Prep the whole stack in test-only mode:
RAILS_ENV: test
steps:
- uses: actions/checkout@v3
- name: Set timezone to Europe/London
run: sudo timedatectl set-timezone Europe/London
- name: Use bundled npm files
run: printf 'disable-self-update-check true\nyarn-offline-mirror "./vendor/npm-packages-offline-cache"\nyarn-offline-mirror-pruning false\n' > .yarnrc
- name: Set up Ruby + Bundle
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ${{ matrix.ruby-version }}
- name: Inject configuration
run: cp config/database.yml{.ci,}
- name: Prepare the database
run: bin/rails db:setup
- name: Precompile assets
# Since ruby/setup-ruby@v1 moved to Node.js v18 we need the extra options
# until we move to newer webpacker / stop using it.
# I've tried using a newer hash function in config/webpack/environment.js
# by adding the following line, but this didn't help with github actions
# # environment.config.set('output.hashFunction', 'sha256')
# https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported/73465262#73465262
run: NODE_OPTIONS=--openssl-legacy-provider bin/rails yarn:install assets:clobber assets:precompile
- name: Run tests
run: PARALLEL_WORKERS=1 bin/rails test 'test/{builders,controllers,facades,helpers,lib,mailers,models,notifiers,services,validators}/**/${{ matrix.test-group }}*_test.rb'
# A utility job upon which Branch Protection can depend,
# thus remaining agnostic of the matrix.
remaining_tests:
if: ${{ always() }}
runs-on: ubuntu-latest
# name: Matrix
needs: remaining_test_matrix
steps:
- name: Check build matrix status
if: ${{ needs.remaining_test_matrix.result != 'success' }}
run: exit 1
# notify:
# # Run only on master, but regardless of whether tests past:
# if: ${{ always() }}
# # if: ${{ always() && github.ref == 'refs/heads/master' }}
#
# needs:
# - integration_tests
# - remaining_tests
#
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/setup-node@v3
# # with:
# # node-version: '16.x'
# - id: slack-payload-generator
# env:
# COMMIT_MESSAGE: ${{ github.event.commits[0].message }}
# run: |-
# node -e "
# const passed = '${{ needs.integration_tests.result }}' === 'success' && '${{ needs.remaining_tests.result }}' === 'success'
#
# const text = process.env.COMMIT_MESSAGE
#
# let attachments = [
# {
# fallback: text,
# text: text,
# fields: [
# { title: 'Author', value: '${{ github.actor }}', short: true },
# { title: 'Revision', value: '${{ github.sha }}', short: true }
# ]
# // ts: @commit.author[:time].to_i
# }
# ]
#
# if (passed) {
# attachments.push({
# color: 'good',
# text: 'Tests passed'
# })
# } else {
# attachments.push({
# color: 'danger',
# text: 'Test(s) failed'
# })
# }
#
# let payload = {
# channel: '${{ secrets.SLACK_CHANNEL }}',
# username: 'GitHub CI',
# icon_emoji: ':robot_face:',
# attachments: attachments
# }
#
# console.log('json=' + JSON.stringify(payload))
# " >> "$GITHUB_OUTPUT"
# - uses: 8398a7/action-slack@v3
# with:
# status: custom
# fields: workflow,commit,author
# custom_payload: ${{ steps.slack-payload-generator.outputs.json }}
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}