Skip to content

Commit e73ab0d

Browse files
authored
Bump ruby to 3.2.8 (#150)
Use ruby 3.2 for deployments Run smoke tests against ruby 3.3 Add bundled rbenv and ruby 3.2.8 installation files. These should be installed automatically as part of cap deploy. For more information, run: cap -e ndr_dev_support:install_ruby To preinstall ruby and bundled gems: cap target deploy:preinstall GitHub Actions: run integration tests separately from remaining tests. (The front-end is no longer in use, so integration test failures can broadly be ignored. Recent chrome driver changes mean that the existing integration tests are very brittle, even though the front-end is still almost certainly working correctly.) Bump nokogiri to 1.18.8 (requires ruby 3.2) Bump stringio to 3.0.4 Fix brittle tests Capistrano deployments: Update subversion path to use local tunnel
1 parent 4467ff3 commit e73ab0d

21 files changed

+110
-21
lines changed

.github/workflows/future_proof.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
ruby-version:
20-
- '3.1' # Latest ruby 3.1.x
2120
- '3.2' # Latest ruby 3.2.x
21+
- '3.3' # Latest ruby 3.3.x
2222

2323
name: "Ruby ${{ matrix.ruby-version }} Smoke Tests"
2424

.github/workflows/tests.yml

Lines changed: 81 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,94 @@ permissions:
1111
actions: read
1212

1313
jobs:
14-
remaining_test_matrix:
14+
integration_test_matrix:
1515
strategy:
1616
fail-fast: false
1717
matrix:
1818
ruby-version:
19-
- '3.1.6'
19+
- '3.2.8'
2020
test-group:
2121
- "[a-b]"
2222
- "[c]"
2323
- "[d-m]"
2424
- "[n-z]"
2525

26-
name: "Ruby ${{ matrix.ruby-version }} Tests (${{ matrix.test-group }})"
26+
name: "Ruby ${{ matrix.ruby-version }} Integration Tests (${{ matrix.test-group }})"
27+
28+
runs-on: ubuntu-latest
29+
30+
services:
31+
postgres:
32+
image: postgres
33+
env:
34+
POSTGRES_USER: rails
35+
POSTGRES_PASSWORD: rails_password
36+
options: >-
37+
--health-cmd pg_isready
38+
--health-interval 10s
39+
--health-timeout 5s
40+
--health-retries 5
41+
--name postgres
42+
ports:
43+
- 5432:5432
44+
45+
env:
46+
DB_HOST: localhost
47+
DB_PORT: 5432
48+
DB_USERNAME: rails
49+
DB_PASSWORD: rails_password
50+
51+
# Prep the whole stack in test-only mode:
52+
RAILS_ENV: test
53+
54+
steps:
55+
- uses: actions/checkout@v3
56+
- name: Set timezone to Europe/London
57+
run: sudo timedatectl set-timezone Europe/London
58+
- name: Use bundled npm files
59+
run: printf 'disable-self-update-check true\nyarn-offline-mirror "./vendor/npm-packages-offline-cache"\nyarn-offline-mirror-pruning false\n' > .yarnrc
60+
- name: Set up Ruby + Bundle
61+
uses: ruby/setup-ruby@v1
62+
with:
63+
bundler-cache: true
64+
ruby-version: ${{ matrix.ruby-version }}
65+
- name: Inject configuration
66+
run: cp config/database.yml{.ci,}
67+
- name: Prepare the database
68+
run: bin/rails db:setup
69+
- name: Precompile assets
70+
# Since ruby/setup-ruby@v1 moved to Node.js v18 we need the extra options
71+
# until we move to newer webpacker / stop using it.
72+
# I've tried using a newer hash function in config/webpack/environment.js
73+
# by adding the following line, but this didn't help with github actions
74+
# # environment.config.set('output.hashFunction', 'sha256')
75+
# https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported/73465262#73465262
76+
run: NODE_OPTIONS=--openssl-legacy-provider bin/rails yarn:install assets:clobber assets:precompile
77+
- name: Run tests
78+
run: PARALLEL_WORKERS=1 bin/rails test 'test/integration/**/${{ matrix.test-group }}*_test.rb'
79+
80+
# A utility job upon which Branch Protection can depend,
81+
# thus remaining agnostic of the matrix.
82+
integration_tests:
83+
if: ${{ always() }}
84+
runs-on: ubuntu-latest
85+
# name: Matrix
86+
needs: integration_test_matrix
87+
steps:
88+
- name: Check build matrix status
89+
if: ${{ needs.integration_test_matrix.result != 'success' }}
90+
run: exit 1
91+
92+
remaining_test_matrix:
93+
strategy:
94+
fail-fast: false
95+
matrix:
96+
ruby-version:
97+
- '3.2.8'
98+
test-group:
99+
- "[a-z]"
100+
101+
name: "Ruby ${{ matrix.ruby-version }} Remaining Tests (${{ matrix.test-group }})"
27102

28103
runs-on: ubuntu-latest
29104

@@ -75,7 +150,7 @@ jobs:
75150
# https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported/73465262#73465262
76151
run: NODE_OPTIONS=--openssl-legacy-provider bin/rails yarn:install assets:clobber assets:precompile
77152
- name: Run tests
78-
run: PARALLEL_WORKERS=1 bin/rails test 'test/**/${{ matrix.test-group }}*_test.rb'
153+
run: PARALLEL_WORKERS=1 bin/rails test 'test/{builders,controllers,facades,helpers,lib,mailers,models,notifiers,services,validators}/**/${{ matrix.test-group }}*_test.rb'
79154

80155
# A utility job upon which Branch Protection can depend,
81156
# thus remaining agnostic of the matrix.
@@ -95,6 +170,7 @@ jobs:
95170
# if: ${{ always() && github.ref == 'refs/heads/master' }}
96171

97172
needs:
173+
- integration_tests
98174
- remaining_tests
99175

100176
runs-on: ubuntu-latest
@@ -108,7 +184,7 @@ jobs:
108184
COMMIT_MESSAGE: ${{ github.event.commits[0].message }}
109185
run: |-
110186
node -e "
111-
const passed = '${{ needs.integration_tests.result }}' === 'success' && '${{ needs.models_tests.result }}' === 'success' && '${{ needs.remaining_tests.result }}' === 'success'
187+
const passed = '${{ needs.integration_tests.result }}' === 'success' && '${{ needs.remaining_tests.result }}' === 'success'
112188
113189
const text = process.env.COMMIT_MESSAGE
114190

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.6
1+
3.2.8

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ gem 'concurrent-ruby', '1.3.4'
1515
# so that we can continue to use aliases in config/locales/en.yml
1616
# cf. https://stackoverflow.com/questions/71191685/visit-psych-nodes-alias-unknown-alias-default-psychbadalias
1717
gem 'psych', '4.0.4' # Exactly match the version on Ruby 3.1
18-
gem 'stringio', '3.0.1.2' # psych dependency: exactly match the version on Ruby 3.1
18+
gem 'stringio', '3.1.1' # psych dependency: exactly match the default version on Ruby 3.3
1919

2020
# Use postgresql as the database for Active Record
2121
gem 'pg', '~> 1.4.6' # All client instance have postgres version >= 9.3

Gemfile.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,14 @@ GEM
338338
net-ssh-gateway (2.0.0)
339339
net-ssh (>= 4.0.0)
340340
nio4r (2.7.4)
341-
nokogiri (1.16.8)
341+
nokogiri (1.18.8)
342342
mini_portile2 (~> 2.8.2)
343343
racc (~> 1.4)
344-
nokogiri (1.16.8-arm64-darwin)
344+
nokogiri (1.18.8-arm64-darwin)
345345
racc (~> 1.4)
346-
nokogiri (1.16.8-x86_64-darwin)
346+
nokogiri (1.18.8-x86_64-darwin)
347347
racc (~> 1.4)
348-
nokogiri (1.16.8-x86_64-linux)
348+
nokogiri (1.18.8-x86_64-linux-gnu)
349349
racc (~> 1.4)
350350
notiffany (0.1.3)
351351
nenv (~> 0.1)
@@ -515,7 +515,7 @@ GEM
515515
actionpack (>= 6.1)
516516
activesupport (>= 6.1)
517517
sprockets (>= 3.0.0)
518-
stringio (3.0.1.2)
518+
stringio (3.1.1)
519519
terminal-notifier-guard (1.7.0)
520520
test-unit (3.6.2)
521521
power_assert
@@ -617,12 +617,12 @@ DEPENDENCIES
617617
sass-rails
618618
simplecov
619619
spring
620-
stringio (= 3.0.1.2)
620+
stringio (= 3.1.1)
621621
terminal-notifier-guard
622622
turbolinks (~> 5.x)
623623
web-console
624624
webpacker
625625
will_paginate
626626

627627
BUNDLED WITH
628-
2.3.27
628+
2.4.19

config/deploy.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
set :delayed_job_command, 'bin/delayed_job'
1919
# set :delayed_job_args, '-n 1'
2020

21-
if Resolv.getaddresses('ndr-svn.phe.gov.uk').any?
21+
# look for open ports locally instead of checking the DNS
22+
if system("lsof -F n -n -P -a -i TCP@localhost:4142 -sTCP:LISTEN", out: '/dev/null')
2223
# Use private repository for some configuration files
23-
set :secondary_repo, 'https://ndr-svn.phe.gov.uk/svn/non-era/mbis'
24+
set :secondary_repo, 'https://localhost:4142/svn/non-era/mbis'
2425
# Private repository for encrypted credentials
2526
# TODO: Add support for per-deployment encrypted credentials to ndr_dev_support
2627
set :credentials_repo,
27-
'https://ndr-svn.phe.gov.uk/svn/encrypted-credentials-store/mbis_front/base'
28+
'https://localhost:4142/svn/encrypted-credentials-store/mbis_front/base'
2829
else
2930
# For off-premise deployments, configuration will be provided to the startup script
3031
# in Base64-encoded environment variables.

config/deployments.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
---
55
beta:
66
branch: 'main'
7-
ruby: 3.1.6
7+
ruby: 3.2.8
88
live:
99
branch: 'main'
10-
ruby: 3.1.6
10+
ruby: 3.2.8

test/integration/create_and_edit_project_test.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def setup
1212

1313
within('#projects-panel') do
1414
click_button 'New'
15+
assert_text /New$/
1516
click_link 'Project'
1617
end
1718

@@ -44,6 +45,7 @@ def setup
4445

4546
within('#projects-panel') do
4647
click_button 'New'
48+
assert_text /New$/
4749
click_link 'Project'
4850
end
4951

@@ -223,6 +225,7 @@ def setup
223225

224226
within('#projects-panel') do
225227
click_button 'New'
228+
assert_text /New$/
226229
click_link 'Project'
227230
end
228231

@@ -243,6 +246,7 @@ def setup
243246

244247
within('#projects-panel') do
245248
click_button 'New'
249+
assert_text /New$/
246250
click_link 'Project'
247251
end
248252

@@ -251,9 +255,9 @@ def setup
251255
select 'Another User', from: 'project_owner_grant_attributes_user_id'
252256
assert_difference('Grant.count', 1) do
253257
click_button 'Save'
258+
assert_text('Project was successfully created')
254259
end
255260
project = Project.find_by(name: 'user creating is project owner')
256-
assert page.has_content?('Project was successfully created')
257261
assert project.grants.first.roleable == ProjectRole.fetch(:owner)
258262
end
259263

@@ -264,13 +268,15 @@ def setup
264268

265269
within('#projects-panel') do
266270
click_button 'New'
271+
assert_text /New$/
267272
click_link 'Project'
268273
end
269274

270275
fill_in_project_data
271276
fill_in 'project_name', with: 'user is creating project for another user'
272277
assert_difference('Grant.count', 2) do
273278
click_button 'Save'
279+
assert_text 'Project was successfully created'
274280
end
275281
project = Project.find_by(name: 'user is creating project for another user')
276282
assert_equal 1, (project.grants.count { |g| g.roleable == owner_role })
@@ -287,13 +293,15 @@ def setup
287293

288294
within('#projects-panel') do
289295
click_button 'New'
296+
assert_text /New$/
290297
click_link 'Project'
291298
end
292299

293300
fill_in_project_data
294301
fill_in 'project_name', with: 'created for someone else in team'
295302
assert_difference('Grant.count', 2) do
296303
click_button 'Save'
304+
assert_text 'Project was successfully created'
297305
end
298306
project = Project.find_by(name: 'created for someone else in team')
299307
owner_grant_id = project.owner_grant.id
@@ -329,6 +337,7 @@ def setup
329337

330338
within('#projects-panel') do
331339
click_button 'New'
340+
assert_text /New$/
332341
click_link 'Project'
333342
end
334343
fill_in 'project_name', with: 'Dataset Project Test'
@@ -344,6 +353,7 @@ def setup
344353
new_li.find('div.remove_record').click
345354
assert_difference('ProjectDataset.count', 1) do
346355
click_button 'Save'
356+
assert_text 'Project was successfully created'
347357
end
348358
end
349359

@@ -369,6 +379,7 @@ def setup
369379
visit team_path(@team)
370380
within('#projects-panel') do
371381
click_button 'New'
382+
assert_text /New$/
372383
click_link 'EOI'
373384
end
374385

@@ -379,6 +390,7 @@ def setup
379390
visit team_path(@team)
380391
within('#projects-panel') do
381392
click_button 'New'
393+
assert_text /New$/
382394
click_link 'EOI'
383395
end
384396

-6.31 MB
Binary file not shown.
-6.47 MB
Binary file not shown.

0 commit comments

Comments
 (0)