Skip to content

Commit 850cdef

Browse files
authored
Libappo1 80 update nokogiri to 1 19 (#413)
* Upgrade to Rails 8.1 * Move sqlite3 to dev/test section * Turn off variant processing to investigate server crash * Rubocop fix * fix config/puma to deploy to production mode * Restore QA config: Dotenv, mailer, assets, require_master_key - application.rb: add Dotenv::Rails.load so .env is loaded before app - production: require_master_key, public_file_server.enabled, SMTP mailer (default_url_options, smtp_settings, from), asset compressors (sass, Uglifier with QA options), assets.compile = true - development: mailer sendmail, from, default_url_options from ENV - deploy/qa.rb: set branch to upgrade branch for QA deploy Made-with: Cursor * update bundler audit * Remove unnecessary changes * Upgrade to nokogiri 1.19, add rails-html-sanitizer * Run bundle install * Add ruby platform to bundle lock * load schema rather than running migrations in CI * Clean up YML file for github actions * Harden specs and exporter for CI DB state Align controller, helper, and view specs with non-empty CI databases by avoiding hardcoded IDs and global record ordering, and ensure the software_records CSV exporter emits empty strings for blank serialized attributes so tests pass consistently. Made-with: Cursor * Update gitignore to include IDE files * CI: use Bundler 2.5.12 for Ruby 3.4; ignore IDE config dirs in .gitignore - Bump BUNDLED WITH to 2.5.12 to avoid Gem::Platform warnings on Ruby 3.4 - CircleCI: install 2.5.12 when lockfile has 2.5.11 - .gitignore: add .cursor, .vscode, .fleet, Sublime; fix .cursor pattern so it is honored Made-with: Cursor * Fix merge conflict * CI: force Ruby platform and reinstall gems in GitHub Actions Avoid GemNotFound for nokogiri/sqlite3/ffi on Linux by running bundle config set --local force_ruby_platform true and bundle install after setup-ruby, so the lockfile's ruby platform is used instead of restored cache from another platform. Made-with: Cursor
1 parent f0801e8 commit 850cdef

14 files changed

Lines changed: 164 additions & 147 deletions

.bundler-audit.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1 @@
1-
ignore:
2-
# rails-html-sanitizer - needs Rails 7 upgrade to fix
3-
- CVE-2024-53989
4-
- CVE-2024-53988
5-
- CVE-2024-53987
6-
- CVE-2024-53986
7-
- CVE-2024-53985
8-
9-
# Nokogiri - servers don't have compatible GLIBC. Wants
10-
# an upgrade to version 1.18.4.
11-
- GHSA-vvfq-8hwr-qm4m
12-
- GHSA-5w6v-399v-w3cc
13-
- GHSA-mrxw-mxhj-p664
14-
- GHSA-5w6v-399v-w3cc
15-
- GHSA-353f-x4gh-cqq8
16-
- GHSA-wx95-c6cv-8532
17-
1+
ignore: []

.circleci/config.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ jobs:
5353
- run:
5454
name: Configure Bundler
5555
command: |
56-
echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
56+
BUNDLER_LOCK=$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1 | tr -d " ")
57+
# Use Bundler 2.5.12+ on Ruby 3.4 to avoid Gem::Platform redefinition warnings
58+
if [ "$BUNDLER_LOCK" = "2.5.11" ]; then BUNDLER_LOCK=2.5.12; fi
59+
echo "export BUNDLER_VERSION=$BUNDLER_LOCK" >> $BASH_ENV
5760
source $BASH_ENV
58-
gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"
61+
gem install bundler -v "$BUNDLER_LOCK"
5962
6063
- run:
6164
name: Install Dependencies

.github/workflows/main.yml

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,55 @@ on: push
44

55
jobs:
66
test:
7-
# ubuntu-22.04: ruby/setup-ruby has 3.4.7; ubuntu-24.04 may not yet
87
runs-on: ubuntu-22.04
8+
99
services:
1010
selenium:
1111
image: selenium/standalone-chrome
1212
ports:
1313
- 4444:4444
1414

1515
steps:
16-
- uses: actions/checkout@v4
17-
18-
- name: Set up Ruby
19-
# Use @v1 so latest action gets new Ruby versions (e.g. 3.4.7)
20-
uses: ruby/setup-ruby@v1
21-
with:
22-
ruby-version: '3.4.7'
23-
bundler-cache: true
24-
25-
- name: Install dependencies
26-
run: |
27-
sudo apt-get update
28-
sudo apt-get install -y xvfb libnss3-dev
29-
gem install bundler
30-
bundle install
31-
32-
- name: Run rubocop
33-
run: |
34-
bundle exec rubocop
35-
36-
- name: Run tests
37-
env:
38-
DISPLAY: :99.0
39-
run: |
40-
Xvfb :99 -ac &
41-
bundle exec rspec
42-
43-
- name: Coveralls
44-
uses: coverallsapp/[email protected]
45-
46-
- name: Brakeman linter
47-
run: bundle exec brakeman --no-exit-on-warn --no-exit-on-error
48-
49-
- name: 'Run Bundler Audit'
50-
run: bundle exec bundler-audit
51-
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up Ruby
19+
uses: ruby/setup-ruby@v1
20+
with:
21+
ruby-version: '3.4.7'
22+
bundler-cache: true
23+
24+
- name: Force Ruby platform and install gems
25+
run: |
26+
bundle config set --local force_ruby_platform true
27+
bundle install
28+
env:
29+
BUNDLE_FORCE_RUBY_PLATFORM: "1"
30+
31+
- name: Install system dependencies
32+
run: |
33+
sudo apt-get update
34+
sudo apt-get install -y xvfb libnss3-dev
35+
# If you build Nokogiri with system libs, add:
36+
# sudo apt-get install -y build-essential libxml2-dev libxslt1-dev
37+
38+
- name: Run rubocop
39+
run: bundle exec rubocop
40+
41+
- name: Prepare DB
42+
run: bundle exec rails db:prepare RAILS_ENV=test
43+
44+
- name: Run tests
45+
env:
46+
DISPLAY: :99.0
47+
run: |
48+
Xvfb :99 -ac &
49+
bundle exec rspec
50+
51+
- name: Coveralls
52+
uses: coverallsapp/[email protected]
53+
54+
- name: Brakeman linter
55+
run: bundle exec brakeman --no-exit-on-warn --no-exit-on-error
56+
57+
- name: Run Bundler Audit
58+
run: bundle exec bundler-audit

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,13 @@ yarn.lock
5151
# Ignore all CSV files generated by export feature
5252
/public/*.csv
5353

54-
#Ignore Rubymine files
54+
# Ignore IDE/editor local configuration
5555
.idea/
56+
.vscode/
57+
.fleet/
58+
.cursor
59+
*.sublime-project
60+
*.sublime-workspace
5661

5762
# Ignore .env.production and .env.production.local
5863
.env.production

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ gem 'net-pop', '~> 0.1.2'
2323
gem 'net-protocol', '>= 0'
2424

2525
# Use nokogiri for java
26-
gem 'nokogiri', '1.16.7'
26+
gem 'nokogiri', '~> 1.19'
2727

2828
# Bundler Audit Update
2929
gem 'json', '>= 2.10.2'
@@ -47,6 +47,8 @@ gem 'turbolinks', '~> 5'
4747
gem 'jbuilder', '~> 2.5'
4848
# Use rails-controller-testing for testing a controller
4949
gem 'rails-controller-testing'
50+
# Use Active Storage variant
51+
gem 'rails-html-sanitizer', '~> 1.7'
5052
# Use rubocop for static code analysis
5153
gem 'rubocop'
5254
# bundler audit

Gemfile.lock

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ GEM
7777
uri (>= 0.13.1)
7878
addressable (2.8.9)
7979
public_suffix (>= 2.0.2, < 8.0)
80-
airbrussh (1.6.0)
80+
airbrussh (1.6.1)
8181
sshkit (>= 1.6.1, != 1.7.0)
8282
ast (2.4.3)
8383
base64 (0.3.0)
@@ -156,6 +156,7 @@ GEM
156156
factory_bot_rails (6.5.1)
157157
factory_bot (~> 6.5)
158158
railties (>= 6.1.0)
159+
ffi (1.17.3)
159160
ffi (1.17.3-aarch64-linux-gnu)
160161
ffi (1.17.3-arm-linux-gnu)
161162
ffi (1.17.3-arm64-darwin)
@@ -235,9 +236,19 @@ GEM
235236
net-protocol
236237
net-ssh (7.3.0)
237238
nio4r (2.7.5)
238-
nokogiri (1.16.7)
239+
nokogiri (1.19.1)
239240
mini_portile2 (~> 2.8.2)
240241
racc (~> 1.4)
242+
nokogiri (1.19.1-aarch64-linux-gnu)
243+
racc (~> 1.4)
244+
nokogiri (1.19.1-arm-linux-gnu)
245+
racc (~> 1.4)
246+
nokogiri (1.19.1-arm64-darwin)
247+
racc (~> 1.4)
248+
nokogiri (1.19.1-x86_64-darwin)
249+
racc (~> 1.4)
250+
nokogiri (1.19.1-x86_64-linux-gnu)
251+
racc (~> 1.4)
241252
orm_adapter (0.5.0)
242253
ostruct (0.6.3)
243254
parallel (1.27.0)
@@ -288,9 +299,9 @@ GEM
288299
activesupport (>= 5.0.0)
289300
minitest
290301
nokogiri (>= 1.6)
291-
rails-html-sanitizer (1.6.0)
292-
loofah (~> 2.21)
293-
nokogiri (~> 1.14)
302+
rails-html-sanitizer (1.7.0)
303+
loofah (~> 2.25)
304+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
294305
railties (8.1.2)
295306
actionpack (= 8.1.2)
296307
activesupport (= 8.1.2)
@@ -339,7 +350,7 @@ GEM
339350
rspec-support (3.13.7)
340351
rspec_junit_formatter (0.6.0)
341352
rspec-core (>= 2, < 4, != 2.12.0)
342-
rubocop (1.85.0)
353+
rubocop (1.85.1)
343354
json (~> 2.3)
344355
language_server-protocol (~> 3.17.0.2)
345356
lint_roller (~> 1.1.0)
@@ -407,6 +418,8 @@ GEM
407418
actionpack (>= 6.1)
408419
activesupport (>= 6.1)
409420
sprockets (>= 3.0.0)
421+
sqlite3 (2.9.1)
422+
mini_portile2 (~> 2.8.0)
410423
sqlite3 (2.9.1-aarch64-linux-gnu)
411424
sqlite3 (2.9.1-arm-linux-gnu)
412425
sqlite3 (2.9.1-arm64-darwin)
@@ -456,7 +469,8 @@ GEM
456469
PLATFORMS
457470
aarch64-linux
458471
arm-linux
459-
arm64-darwin
472+
arm64-darwin-25
473+
ruby
460474
x86-linux
461475
x86_64-darwin
462476
x86_64-linux
@@ -495,12 +509,13 @@ DEPENDENCIES
495509
net-imap (>= 0.5.7)
496510
net-pop (~> 0.1.2)
497511
net-protocol
498-
nokogiri (= 1.16.7)
512+
nokogiri (~> 1.19)
499513
petergate
500514
puma (>= 6.4.3)
501515
rack (~> 2.2.20)
502516
rails (~> 8.1.0)
503517
rails-controller-testing
518+
rails-html-sanitizer (~> 1.7)
504519
rb-readline
505520
recaptcha
506521
rexml (>= 3.3.9)
@@ -525,4 +540,4 @@ RUBY VERSION
525540
ruby 3.4.7p58
526541

527542
BUNDLED WITH
528-
2.5.11
543+
2.5.12

config/deploy.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
task :init_qp do
2727
on roles(:all) do
2828
execute 'gem install --user-install bundler'
29-
execute "bundle config path 'vendor/bundle' --local"
29+
execute "cd #{fetch(:release_path)} && bundle config path 'vendor/bundle' --local"
30+
execute "cd #{fetch(:release_path)} && bundle config set force_ruby_platform true --local"
3031
execute "mkdir -p #{fetch(:deploy_to)}/static"
3132
execute "cp #{fetch(:deploy_to)}/static/.env.production #{fetch(:release_path)}/ || true"
3233
end

exports/software_records.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def software_records
6262
private
6363

6464
def clean_and_format(attribute)
65+
return '' if attribute.blank?
66+
6567
formatted_attribute = attribute.to_s.gsub('---', '').gsub("\n", '-')
6668
parts = formatted_attribute.split('- ').reject { |part| part == '-' }
6769
parts.map { |part| part.gsub('-', '').strip }.join(', ')

spec/controllers/change_requests_controller_spec.rb

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
title: 'Test Env.',
2727
description: 'test env.'
2828
)
29+
end
30+
31+
let!(:software_record) do
2932
SoftwareRecord.create!(
3033
title: 'A Good Software',
3134
description: 'A Good description about the software',
@@ -47,7 +50,7 @@
4750
{
4851
change_title: 'A Good Software',
4952
change_description: 'A Good description about the software',
50-
software_record_id: 1,
53+
software_record_id: software_record.id,
5154
application_pages: 10,
5255
number_roles: 3,
5356
authentication_needed: true,
@@ -103,19 +106,6 @@ def sign_in_user(manager)
103106

104107
it 'assigns @software_name' do
105108
change_request = ChangeRequest.create! valid_attributes
106-
software_record = SoftwareRecord.create!(
107-
title: 'A Good Software',
108-
description: 'A Good description about the software',
109-
status_id: Status.first.id,
110-
software_type_id: SoftwareType.first.id,
111-
vendor_record_id: VendorRecord.first.id,
112-
hosting_environment_id: HostingEnvironment.first.id,
113-
created_by: 'Test Manager',
114-
developers: %w[Tester Random],
115-
tech_leads: ['Lead 1'],
116-
product_owners: %w[Owner1 Owner2],
117-
admin_users: %w[Admin1 Admin2]
118-
)
119109
get :show, params: { id: change_request.id }
120110
expect(assigns(:software_name)).to eq(software_record.title)
121111
end

spec/controllers/software_records_controller_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def sign_in_user(admin)
223223
software_record1 = SoftwareRecord.create! valid_attributes
224224
software_record2 = SoftwareRecord.create! valid_attributes
225225
get :list_road_map
226-
expect(assigns(:software_records)).to match_array([software_record1, software_record2])
226+
expect(assigns(:software_records)).to include(software_record1, software_record2)
227227
expect(response.body).not_to match('\b(Decommissioned.Software)\b')
228228
end
229229
end
@@ -526,7 +526,7 @@ def sign_in_user(admin)
526526

527527
it 'also destroys the change request associated with the software_record' do
528528
software_record = SoftwareRecord.create! valid_attributes
529-
ChangeRequest.create! change_attributes
529+
ChangeRequest.create!(change_attributes.merge(software_record_id: software_record.id))
530530
expect do
531531
delete :destroy, params: { id: software_record.to_param }, session: valid_session
532532
end.to change(ChangeRequest, :count).by(-1)

0 commit comments

Comments
 (0)