-
Notifications
You must be signed in to change notification settings - Fork 14
286 lines (259 loc) · 11.2 KB
/
rails_tests.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
name: Rails Tests
on:
# NOTE: runs on both PRs and pulls. This would normally cause redundant jobs to run but there are conditions on github.event_name in the matrix to avoid this. In particular, we want the system tests to run only on PR so we can use the base_ref to infer the appropriate release branch name in the hmis FE repo (see issue #6566)
push:
branches:
- '*'
- '**/*'
pull_request:
branches:
- '*'
- '**/*'
concurrency:
group: ${{ github.ref }}-tests
cancel-in-progress: true
jobs:
determine_matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo 'matrix={"test_group":[{"id":"system_tests","system_tests":"true"}]}' >> $GITHUB_OUTPUT
else
echo 'matrix={"test_group":[{"id":"ci_bucket_1","tag":"ci_bucket:bucket-1"},{"id":"ci_bucket_2","tag":"ci_bucket:bucket-2"},{"id":"ci_bucket_3","tag":"ci_bucket:bucket-3"},{"id":"ci_bucket_4","tag":"ci_bucket:bucket-4"},{"id":"ci_bucket_default","tag":"~ci_bucket","logging_tests":true,"okta_tests":true}]}' >> $GITHUB_OUTPUT
fi
# Label of the container job
tests:
needs: determine_matrix
strategy:
fail-fast: false
matrix: ${{fromJson(needs.determine_matrix.outputs.matrix)}}
# Containers must run in Linux based operating systems
runs-on: ubuntu-20.04
# Docker Hub image that the job executes in
# $RUBY_VERSION
container: ruby:3.1.6-alpine3.20
# Service containers to run with job
services:
postgres:
image: postgis/postgis:16-3.4-alpine
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_PASS: postgres
POSTGRES_MULTIPLE_EXTENSIONS: postgis,hstore
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:alpine
ports:
- 6379:6379
hmis-warehouse-sftp:
image: ghcr.io/greenriver/openpath-sftp:1.0
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
ports:
- '2222:22'
minio:
image: ghcr.io/greenriver/openpath-minio:1.0
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
env:
MINIO_ACCESS_KEY: local_access_key
MINIO_SECRET_KEY: local_secret_key
ports:
- '9000:9000'
chrome:
image: browserless/chrome:1-chrome-stable
ports:
- 3333:3333
env:
TZ: "America/New_York"
PORT: 3333
CONNECTION_TIMEOUT: 600000
env:
CLIENT: test
DATABASE_ADAPTER: postgresql
DATABASE_APP_DB_TEST: warehouse_app_test
DATABASE_DB_TEST: warehouse_test
DATABASE_APP_DB: warehouse_app_test
DATABASE_HOST: postgres
DATABASE_PASS: postgres
DATABASE_USER: postgres
DATABASE_WAREHOUSE_DB_TEST: warehouse_test
DEFAULT_FROM: [email protected]
DISABLE_SPRING: 1
ENCRYPTION_KEY: strongEncryptionstrongEncryptionstrongEncryption
FQDN: openpath.host
HEALTH_DATABASE_ADAPTER: postgresql
HEALTH_DATABASE_DB_TEST: health_test
HEALTH_DATABASE_HOST: postgres
HEALTH_DATABASE_PASS: postgres
HEALTH_DATABASE_USER: postgres
HEALTH_FROM: [email protected]
HOSTNAME: openpath.host
MINIO_ENDPOINT: http://minio:9000
USE_MINIO_ENDPOINT: true
PORT: 80
RAILS_ENV: test
REPORTING_DATABASE_ADAPTER: postgresql
REPORTING_DATABASE_DB_TEST: reporting_test
REPORTING_DATABASE_HOST: postgres
REPORTING_DATABASE_PASS: postgres
REPORTING_DATABASE_USER: postgres
WAREHOUSE_DATABASE_ADAPTER: postgis
WAREHOUSE_DATABASE_DB_TEST: warehouse_test
WAREHOUSE_DATABASE_HOST: postgres
WAREHOUSE_DATABASE_PASS: postgres
WAREHOUSE_DATABASE_USER: postgres
WAREHOUSE_DATABASE_DB: warehouse_test
HEALTH_DATABASE_DB: health_test
REPORTING_DATABASE_DB: reporting_test
# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
PUPPETEER_EXECUTABLE_PATH: /usr/bin/chromium-browser
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 'Container Setup'
id: container-setup
uses: ./.github/workflows/container_setup
- name: 'App setup'
run: |
cp config/secrets.yml.sample config/secrets.yml
mkdir app/assets/stylesheets/theme/styles
touch app/assets/stylesheets/theme/styles/_variables.scss
cp .rspec.sample .rspec
cp config/database.yml.ci config/database.yml
- name: Prepare test db
run: |
pg_isready -h postgres -U postgres
bin/db_prep
echo "Setting up .pgpass"
echo "postgres:*:*:postgres:postgres" > ~/.pgpass
chmod 600 ~/.pgpass
- name: Precompile assets
run: bundle exec rails assets:precompile
# fetch some closed source files
- name: 'Fetch testkit source files'
uses: keithweaver/[email protected]
with:
command: cp
source: ${{ secrets.AWS_S3_ACTION_BUCKET }}${{ vars.AWS_S3_ACTIONS_SOURCE_PATH_FY_2024 }}
destination: ./drivers/datalab_testkit/spec/fixtures/inputs/
aws_access_key_id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
aws_region: us-east-1
flags: --recursive
# fetch pre-processed FY2024 data set; note that we need to update this whenever the test kit source
# data changes. To update:
# 1. Remove the fixtures from `drivers/datalab_testkit/spec/fixpoints/`
# 2. Replace the source and result files in `drivers/datalab_testkit/spec/fixtures` and on S3
# 3. Re-run the tests rspec drivers/hud_apr/spec/models/fy2024/datalab_2_0_spec.rb
# 4. Update the fixpoint in S3 from the newly generated file
- name: 'Fetch testkit fixpoint files'
uses: keithweaver/[email protected]
with:
command: cp
source: ${{ secrets.AWS_S3_ACTION_BUCKET }}${{ vars.AWS_S3_ACTIONS_FIXPOINT_PATH_FY_2024 }}
destination: ./drivers/datalab_testkit/spec/fixpoints/
aws_access_key_id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
aws_region: us-east-1
flags: --recursive
- name: 'Fetch result files'
uses: keithweaver/[email protected]
with:
command: cp
source: ${{ secrets.AWS_S3_ACTION_BUCKET }}${{ vars.AWS_S3_ACTIONS_RESULTS_PATH_FY_2024 }}
destination: ./drivers/datalab_testkit/spec/fixtures/results/
aws_access_key_id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
aws_region: us-east-1
flags: --recursive
- name: 'Fetch 2022 -> 2024 source files'
uses: keithweaver/[email protected]
with:
command: cp
source: ${{ secrets.AWS_S3_ACTION_BUCKET }}${{ vars.AWS_S3_ACTIONS_SOURCE_PATH_FY_2024 }}/merged/source
destination: ./drivers/hud_twenty_twenty_two_to_twenty_twenty_four/spec/fixtures/in/
aws_access_key_id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
aws_region: us-east-1
flags: --recursive
# Regenerate the graphql schema and fail if it has changed
- name: 'Check HMIS GraphQL schema'
if: matrix.test_group.system_tests
run: |
bundle exec rake driver:hmis:dump_graphql_schema
- name: Run tests
if: matrix.test_group.tag
env:
AWS_ACCESS_KEY_ID: local_access_key
AWS_SECRET_ACCESS_KEY: local_secret_key
GROVER_NO_SANDBOX: true
CHROMIUM_PATH: /usr/bin/chromium-browser
MAX_FAILURES: 60
LOG_LEVEL: INFO
run: |
bundle exec rails ci:update_spec_tags[.github/rspec_buckets.json]
# capture rspec profiling information
# mkdir -p tmp/rspec_profiles
# bundle exec rspec --format json --out "tmp/rspec_profiles/rspec_results.json" --profile 100000 --fail-fast=$MAX_FAILURES --color --pattern "spec/**/*_spec.rb,drivers/*/spec/**/*_spec.rb" --tag ${{ matrix.test_group.tag }} --tag ~type:system
bundle exec rspec --fail-fast=$MAX_FAILURES --color --pattern "spec/**/*_spec.rb,drivers/*/spec/**/*_spec.rb" --tag ${{ matrix.test_group.tag }} --tag ~type:system
- name: Run okta tests
if: matrix.test_group.okta_tests
env:
AWS_ACCESS_KEY_ID: local_access_key
AWS_SECRET_ACCESS_KEY: local_secret_key
GROVER_NO_SANDBOX: true
CHROMIUM_PATH: /usr/bin/chromium-browser
MAX_FAILURES: 60
LOG_LEVEL: INFO
run: |
OKTA_DOMAIN=localhost OKTA_CLIENT_ID=x OKTA_CLIENT_SECRET=x bundle exec rspec --fail-fast=$MAX_FAILURES --color -fd spec/requests/omniauth_spec.rb spec/requests/sessions_controller_spec.rb # these tests need okta enabled
- name: Run logging tests
if: matrix.test_group.logging_tests
env:
AWS_ACCESS_KEY_ID: local_access_key
AWS_SECRET_ACCESS_KEY: local_secret_key
LOG_LEVEL: INFO
run: |
TEST_DEVELOPMENT_LOGGING_CONFIG=true RAILS_LOG_TO_STDOUT=true LOGRAGE=true bundle exec rspec --color --format p spec/models/logging_spec.rb
TEST_DEVELOPMENT_LOGGING_CONFIG=true RAILS_LOG_TO_STDOUT=true LOGRAGE=false bundle exec rspec --color --format p spec/models/logging_spec.rb
TEST_DEVELOPMENT_LOGGING_CONFIG=true RAILS_LOG_TO_STDOUT=false LOGRAGE=true bundle exec rspec --color --format p spec/models/logging_spec.rb
TEST_DEVELOPMENT_LOGGING_CONFIG=true RAILS_LOG_TO_STDOUT=false LOGRAGE=false bundle exec rspec --color --format p spec/models/logging_spec.rb
TEST_STAGING_LOGGING_CONFIG=true bundle exec rspec --color --format p spec/models/logging_spec.rb
- name: Build front end and run tests
if: matrix.test_group.system_tests
env:
AWS_ACCESS_KEY_ID: local_access_key
AWS_SECRET_ACCESS_KEY: local_secret_key
MAX_FAILURES: 60
LOG_LEVEL: INFO
RUN_SYSTEM_TESTS: true
BRANCH_NAME: "${{ github.head_ref || github.ref_name }}:${{ github.base_ref || 'stable' }}:stable"
CHROME_URL: http://chrome:3333
run:
bash ./bin/run_hmis_system_tests.sh
- name: Archive artifacts
if: always()
uses: actions/upload-artifact@v4
with:
if-no-files-found: ignore
name: artifacts-${{ matrix.test_group.id}}
path: |
tmp/rspec_profiles/
tmp/capybara/screenshots/
var/deprecations/*.yml