-
-
Notifications
You must be signed in to change notification settings - Fork 201
206 lines (196 loc) · 5.97 KB
/
test.yml
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
name: Test
on:
push:
branches:
- main
pull_request:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5
env:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
steps:
- name: Checkout code
uses: actions/checkout@v4
# Dependencies
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
rubygems: latest
# Lint
- name: Run linter
run: bin/lint --nofix
development_environment:
name: Development Environment
runs-on: ubuntu-latest
timeout-minutes: 10
env:
PGHOST: localhost
PGUSER: good_job
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
DISABLE_SPRING: 1
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: good_job
POSTGRES_DB: good_job_test
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: trust
ports: [ "5432:5432" ]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
# Dependencies
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
rubygems: latest
# Validate Development Environment
- name: bin/setup
run: bin/rails db:test:prepare
- name: bin/rspec
run: bin/rspec --require ./spec/support/pre_documentation_formatter.rb --format PreDocumentationFormatter
# Archive
- name: Archive system spec screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
path: |
demo/tmp/screenshots
demo/tmp/capybara
- name: Archive Rails logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: rails_logs
path: demo/log
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
ruby: [2.6, 2.7, "3.0", 3.1, 3.2, jruby-9.3, jruby-9.4]
pg: [15]
include:
- ruby: 3.2
pg: 11
- ruby: 3.2
pg: 12
- ruby: 3.2
pg: 13
- ruby: 3.2
pg: 14
- ruby: jruby-9.4
pg: 11
- ruby: jruby-9.4
pg: 12
- ruby: jruby-9.4
pg: 13
- ruby: jruby-9.4
pg: 14
env:
PGHOST: localhost
PGUSER: good_job
RAILS_ENV: test
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
BUNDLE_WITHOUT: debug:lint:demo:production
RAILS_LOG_TO_STDOUT: false
services:
postgres:
image: postgres:${{ matrix.pg }}
env:
POSTGRES_USER: good_job
POSTGRES_DB: good_job_test
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: trust
ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: browser-actions/setup-chrome@latest
- run: chrome --version
- name: Checkout code
uses: actions/checkout@v4
- name: Update .ruby-version with matrix value
run: echo "${{ matrix.ruby }}" >| .ruby-version
- name: Set Rubygems version
id: rubygems
run: |
if [[ "${{ matrix.ruby }}" == "2.6" || "${{ matrix.ruby }}" == "2.7" || "${{ matrix.ruby }}" == "jruby-9.3" ]]; then
echo "version=3.3.27" >> $GITHUB_OUTPUT
else
echo "version=latest" >> $GITHUB_OUTPUT
fi
# Dependencies
- name: Set up generic Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: false
- name: Delete and recreate Gemfile.lock
run: |
rm Gemfile.lock && bundle lock && bundle update && cat Gemfile.lock
- name: Set up Ruby and bundle install
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
rubygems: ${{ steps.rubygems.outputs.version }}
- name: Cache Appraisal gems
uses: actions/cache@v3
with:
path: gemfiles/vendor/bundle
key: v1-bundler-${{ runner.os }}-${{ matrix.ruby }}-${{ hashFiles('Gemfile.lock', 'gemfiles/*.gemfile.lock') }}
restore-keys: |
v1-bundler-${{ runner.os }}-${{ matrix.ruby }}-
- name: Install Appraisal gems
run: bundle exec appraisal install
# Test
- name: Set up test database
run: bundle exec appraisal demo/bin/rails db:test:prepare
- name: Run Unit tests
run: |
bundle exec appraisal rspec --exclude-pattern "spec/system/**/*_spec.rb, spec/generators/**/*_spec.rb" \
--require ./spec/support/pre_documentation_formatter.rb \
--format PreDocumentationFormatter
- name: Run System tests
if: ${{ !contains(matrix.ruby, 'jruby') }}
run: |
bundle exec appraisal rspec --require ./spec/support/pre_documentation_formatter.rb \
--format PreDocumentationFormatter \
spec/system
- name: Run Generators tests
run: |
bundle exec appraisal rspec --require ./spec/support/pre_documentation_formatter.rb \
--format PreDocumentationFormatter \
spec/generators
# Archive
- name: Archive system spec screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
path: |
demo/tmp/screenshots
demo/tmp/capybara
- name: Archive Rails logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: rails_logs
path: demo/log