-
Notifications
You must be signed in to change notification settings - Fork 33
211 lines (208 loc) · 7.89 KB
/
ruby_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
207
208
209
210
211
name: Ruby Test
env:
TZ: Europe/London
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID || '9c624e5d90c5b319d678e06d66c7671f1661fda826436d475f9679b54be63e26' }}
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: ${{ secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC }}
KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER: ${{ secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER }}
KNAPSACK_PRO_FIXED_QUEUE_SPLIT: true
KNAPSACK_PRO_LOG_LEVEL: info
SKIP_AUTOMATIC_GEM_INSTALLATION: true # Disable the bundle install in bin/setup
########
## Warning!
## CodeCov's config in `codecov.yml` is expecting an exact number of builds to complete before it will run.
## See the config value with key `after_n_builds` in that file.
## If the number of build steps changes, it is important to update the count there to match.
########
on:
push:
pull_request:
types:
# defaults
- opened
- synchronize
- reopened
# custom
- ready_for_review # required for Github-created PRs
jobs:
rake_tests:
runs-on: ubuntu-latest
env:
RAILS_ENV: test
BUNDLE_WITHOUT: "cucumber deployment profile development"
# Services
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idservices
services:
mysql:
# Use the Mysql docker image https://hub.docker.com/_/mysql
image: mysql:8.0
ports:
- 3306 # Default port mappings
# Monitor the health of the container to mesaure when it is ready
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
env:
MYSQL_ROOT_PASSWORD: "" # Set root PW to nothing
MYSQL_ALLOW_EMPTY_PASSWORD: yes
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Setup environment
env:
DBPORT: ${{ job.services.mysql.ports[3306] }}
run: |
bin/setup
# Actually run our tests
- name: Run rake tests
env:
DBPORT: ${{ job.services.mysql.ports[3306] }}
run: bundle exec rake test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.5.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
rspec_tests:
runs-on: ubuntu-latest
env:
RAILS_ENV: test
BUNDLE_WITHOUT: "cucumber deployment profile development"
# Services
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idservices
services:
mysql:
# Use the Mysql docker image https://hub.docker.com/_/mysql
image: mysql:8.0
ports:
- 3306 # Default port mappings
# Monitor the health of the container to mesaure when it is ready
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
env:
MYSQL_ROOT_PASSWORD: "" # Set root PW to nothing
MYSQL_ALLOW_EMPTY_PASSWORD: yes
# Sets up the matrix for knapsack builds
strategy:
matrix:
ci_node_total: [3]
ci_node_index: [0, 1, 2]
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
# Establish a cache of js modules to improve performance
- name: Cache js
uses: actions/cache@v2
with:
path: |
public/assets
node_modules
key: ${{ runner.os }}-tests-${{ hashFiles('yarn.lock') }}
# If we don't find the specific cache we want, fallback to the last raketests
# cache, then finally any cache for this repo.
# Github looks for the newest cache beginning with the first entry, before
# falling back the the second if none is present.
restore-keys: |
${{ runner.os }}-tests-
${{ runner.os }}-
# Install only the gems needed for testing
# Keep an eye on https://github.com/rubygems/bundler-features/issues/59
# in case bundler add an only flag
# We also set the install path to vendor/bundle to assist with out caching
# bin/setup handles the rest of the configuration for us.
- name: Setup environment
env:
DBPORT: ${{ job.services.mysql.ports[3306] }}
run: |
bin/setup
bundle exec rake assets:precompile
# Actually run our tests
- name: Run rspec tests
env:
KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
KNAPSACK_PRO_CI_NODE_INDEX: ${{ matrix.ci_node_index }}
DBPORT: ${{ job.services.mysql.ports[3306] }}
run: bin/knapsack_pro_rspec
- name: Upload capybara artifacts
uses: actions/upload-artifact@v4.4.0
if: ${{ failure() }}
with:
name: capybara-${{ github.job }}-${{ matrix.ci_node_index }}
path: tmp/capybara/
retention-days: 5
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.5.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
cucumber_tests:
runs-on: ubuntu-latest
env:
RAILS_ENV: cucumber
BUNDLE_WITHOUT: "deployment profile development test"
# Services
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idservices
services:
mysql:
# Use the Mysql docker image https://hub.docker.com/_/mysql
image: mysql:8.0
ports:
- 3306 # Default port mappings
# Monitor the health of the container to mesaure when it is ready
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
env:
MYSQL_ROOT_PASSWORD: "" # Set root PW to nothing
MYSQL_ALLOW_EMPTY_PASSWORD: yes
# Sets up the matrix for knapsack builds
strategy:
matrix:
ci_node_total: [2]
ci_node_index: [0, 1]
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
# Establish a cache of js modules to improve performance
- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "yarn"
# Install only the gems needed for testing
# Keep an eye on https://github.com/rubygems/bundler-features/issues/59
# in case bundler add an only flag
# We also set the install path to vendor/bundle to assist with out caching
# bin/setup handles the rest of the configuration for us.
- name: Setup environment
env:
DBPORT: ${{ job.services.mysql.ports[3306] }}
run: |
bin/setup
bundle exec rake assets:precompile
# Actually run our tests
- name: Run Cucumber tests
env:
KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
KNAPSACK_PRO_CI_NODE_INDEX: ${{ matrix.ci_node_index }}
DBPORT: ${{ job.services.mysql.ports[3306] }}
run: bin/knapsack_pro_cucumber
- name: Upload capybara artifacts
uses: actions/upload-artifact@v4.4.0
if: ${{ failure() }}
with:
name: capybara-${{ github.job }}-${{ matrix.ci_node_index }}
path: tmp/capybara/
retention-days: 5
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.5.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true