From b1d1e6380681d9ef9331b447b216ccaa982b9027 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Mon, 17 Mar 2025 11:59:12 -0600 Subject: [PATCH 1/8] Update all workflows to `runs-on: ubuntu-22.04` --- .github/workflows/brakeman.yml | 2 +- .github/workflows/danger.yml | 2 +- .github/workflows/eslint.yml | 2 +- .github/workflows/mysql.yml | 2 +- .github/workflows/postgres.yml | 2 +- .github/workflows/rubocop.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/brakeman.yml b/.github/workflows/brakeman.yml index a9e037de4a..eb094243ac 100644 --- a/.github/workflows/brakeman.yml +++ b/.github/workflows/brakeman.yml @@ -8,7 +8,7 @@ on: jobs: brakeman: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index d4a5fb329a..6dc61cc6a9 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: danger: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index 6a34d2c34b..71987c0d02 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -5,7 +5,7 @@ on: [push, pull_request] jobs: eslint: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: # Checkout the repo diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml index 9ab6e6549f..0ce6367cf5 100644 --- a/.github/workflows/mysql.yml +++ b/.github/workflows/mysql.yml @@ -4,7 +4,7 @@ on: [pull_request] jobs: mysql: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 # Define environment variables for MySQL and Rails env: diff --git a/.github/workflows/postgres.yml b/.github/workflows/postgres.yml index c1ee0d8cc8..8849473ce1 100644 --- a/.github/workflows/postgres.yml +++ b/.github/workflows/postgres.yml @@ -4,7 +4,7 @@ on: [pull_request] jobs: postgresql: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 services: # Postgres installation diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index c9c0cf8812..04d9e7c780 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: rubocop: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: # Checkout the repo From 84816617643a1485263f07b37bad44b5e805d505 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Mon, 17 Mar 2025 12:06:04 -0600 Subject: [PATCH 2/8] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc8ddb1060..142260d661 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - Fixed bar chart click function in the Usage dashboard (GitHub issue #3443) - Fixed broken link for the V1 API documentation. - Fix `hidden_field_tag` Nested Attributes Format For Rails 7 Upgrade and Add Test Coverage [#3479](https://github.com/DMPRoadmap/roadmap/pull/3479) - +- Update all workflows to `runs-on: ubuntu-22.04` [#3487](https://github.com/DMPRoadmap/roadmap/pull/3487) **Note this upgrade is mainly a migration from Bootstrap 3 to Bootstrap 5.** From 627a47fbc9fdc854cae036ccf5c157e05dcce904 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Mon, 17 Mar 2025 12:45:12 -0600 Subject: [PATCH 3/8] Extract full semvers in Danger workflow - This change modifies the regex to capture the full versions for Ruby and Bundler. --- .github/workflows/danger.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 6dc61cc6a9..e9d9c62a46 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -11,8 +11,8 @@ jobs: - name: 'Determine Ruby and Bundler Versions from Gemfile.lock' run: | - echo "RUBY_VERSION=`cat ./Gemfile.lock | grep -A 1 'RUBY VERSION' | grep 'ruby' | grep -oE '[0-9]\.[0-9]'`" >> $GITHUB_ENV - echo "BUNDLER_VERSION=`cat ./Gemfile.lock | grep -A 1 'BUNDLED WITH' | grep -oE '[0-9]\.[0-9]'`" >> $GITHUB_ENV + echo "RUBY_VERSION=`cat ./Gemfile.lock | grep -A 1 'RUBY VERSION' | grep 'ruby' | grep -oE '[0-9]+\.[0-9]+\.[0-9]+'`" >> $GITHUB_ENV + echo "BUNDLER_VERSION=`cat ./Gemfile.lock | grep -A 1 'BUNDLED WITH' | grep -oE '[0-9]+\.[0-9]+\.[0-9]+'`" >> $GITHUB_ENV # Install Ruby - using the version found in the Gemfile.lock - name: 'Install Ruby' From 46389a1b2ddb7933dba2ef558533ad9645d371a1 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Mon, 17 Mar 2025 12:52:13 -0600 Subject: [PATCH 4/8] Replace deprecated `setup-ruby` action The following error was being encountered in https://github.com/DMPRoadmap/roadmap/actions/runs/13907418160/job/38913596385?pr=3487: ``` Run actions/setup-ruby@v1 ------------------------ NOTE: This action is deprecated and is no longer maintained. Please, migrate to https://github.com/ruby/setup-ruby, which is being actively maintained. ------------------------ Error: Version 3.0.4 not found ``` --- .github/workflows/danger.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index e9d9c62a46..1c9bbde5ca 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -16,7 +16,7 @@ jobs: # Install Ruby - using the version found in the Gemfile.lock - name: 'Install Ruby' - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ env.RUBY_VERSION }} From c303871e3198776eafa674e1b442574dfa154e06 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Mon, 24 Mar 2025 11:04:15 -0600 Subject: [PATCH 5/8] Update all workflows to `runs-on: ubuntu-24.04` --- .github/workflows/brakeman.yml | 2 +- .github/workflows/danger.yml | 2 +- .github/workflows/eslint.yml | 2 +- .github/workflows/mysql.yml | 2 +- .github/workflows/postgres.yml | 2 +- .github/workflows/rubocop.yml | 2 +- CHANGELOG.md | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/brakeman.yml b/.github/workflows/brakeman.yml index eb094243ac..0a64ca04c0 100644 --- a/.github/workflows/brakeman.yml +++ b/.github/workflows/brakeman.yml @@ -8,7 +8,7 @@ on: jobs: brakeman: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 1c9bbde5ca..8fbb6af429 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: danger: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index 71987c0d02..eaab3a98ec 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -5,7 +5,7 @@ on: [push, pull_request] jobs: eslint: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: # Checkout the repo diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml index 0ce6367cf5..08a335329b 100644 --- a/.github/workflows/mysql.yml +++ b/.github/workflows/mysql.yml @@ -4,7 +4,7 @@ on: [pull_request] jobs: mysql: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 # Define environment variables for MySQL and Rails env: diff --git a/.github/workflows/postgres.yml b/.github/workflows/postgres.yml index 0f0a91f4e8..1dfcaaaa16 100644 --- a/.github/workflows/postgres.yml +++ b/.github/workflows/postgres.yml @@ -4,7 +4,7 @@ on: [pull_request] jobs: postgresql: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 services: # Postgres installation diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 04d9e7c780..dc92a01f4b 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: rubocop: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: # Checkout the repo diff --git a/CHANGELOG.md b/CHANGELOG.md index af4f93b67d..ef2f56e833 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - Fixed bar chart click function in the Usage dashboard (GitHub issue #3443) - Fixed broken link for the V1 API documentation. - Fix `hidden_field_tag` Nested Attributes Format For Rails 7 Upgrade and Add Test Coverage [#3479](https://github.com/DMPRoadmap/roadmap/pull/3479) -- Update all workflows to `runs-on: ubuntu-22.04` [#3487](https://github.com/DMPRoadmap/roadmap/pull/3487) +- Update all workflows to `runs-on: ubuntu-24.04` [#3487](https://github.com/DMPRoadmap/roadmap/pull/3487) - Add pdf handling in `render_respond_to_format_with_error_message` [#3482](https://github.com/DMPRoadmap/roadmap/pull/3482) - Lower PostgreSQL GitHub Action Chrome Version to Address Breaking Changes Between Latest Chrome Version (134) and `/features` Tests [#3491](https://github.com/DMPRoadmap/roadmap/pull/3491) From 027fa4a3fb04e0f35a062c23d367772c7f2d38b0 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Mon, 24 Mar 2025 11:23:31 -0600 Subject: [PATCH 6/8] Install `imagemagick` in Postgres Workflow - `imagemagick` is not pre-installed with `ubuntu-24.04`. However, it is required to resolve the following test failures: ``` Failures: 1) OrgsController PUT /org/admin/:id/admin_update succeeds for feedback changes Failure/Error: return if logo.nil? || logo.height == 100 Dragonfly::Shell::CommandFailed: Command failed: identify -ping -format \%m\ \%w\ \%h /tmp/RackMultipart20250324-4505-2x6nam.png, exit status: 127, error: sh: 1: identify: not found # ./app/models/org.rb:357:in `resize_image' # ./app/controllers/orgs_controller.rb:81:in `admin_update' # ./spec/controllers/orgs_controller_spec.rb:60:in `block (3 levels) in
' 2) OrgsController PUT /org/admin/:id/admin_update updates the shibboleth entityID if super_admin and enabled Failure/Error: return if logo.nil? || logo.height == 100 Dragonfly::Shell::CommandFailed: Command failed: identify -ping -format \%m\ \%w\ \%h /tmp/RackMultipart20250324-4505-gp3t74.png, exit status: 127, error: sh: 1: identify: not found # ./app/models/org.rb:357:in `resize_image' # ./app/controllers/orgs_controller.rb:81:in `admin_update' # ./spec/controllers/orgs_controller_spec.rb:73:in `block (3 levels) in
' 3) OrgsController PUT /org/admin/:id/admin_update succeeds Failure/Error: return if logo.nil? || logo.height == 100 Dragonfly::Shell::CommandFailed: Command failed: identify -ping -format \%m\ \%w\ \%h /tmp/RackMultipart20250324-4505-42hnxo.png, exit status: 127, error: sh: 1: identify: not found # ./app/models/org.rb:357:in `resize_image' # ./app/controllers/orgs_controller.rb:81:in `admin_update' # ./spec/controllers/orgs_controller_spec.rb:43:in `block (3 levels) in
' ``` --- .github/workflows/postgres.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/postgres.yml b/.github/workflows/postgres.yml index 1dfcaaaa16..84f8a99661 100644 --- a/.github/workflows/postgres.yml +++ b/.github/workflows/postgres.yml @@ -52,6 +52,11 @@ jobs: run: | sudo apt-get update sudo apt-get install libpq-dev + + # Install ImageMagick (for `identify` command) + - name: 'Install ImageMagick' + run: | + sudo apt-get install -y imagemagick # Copy all of the example configs over - name: 'Setup Default Configuration' From c7b9b483e8edf6575ac33e8acec4c7d8674281fc Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Mon, 24 Mar 2025 11:56:32 -0600 Subject: [PATCH 7/8] Consolidate Capybara config - Moved the `spec/rails_helper.rb` Capybara config to `spec/support/capybara.rb` - Rather than pasting the `Capybara.register_driver :headless_chrome` code, the extra `options.add_argument` code was added to `Capybara.register_driver :selenium_chrome_headless_custom`. - Renamed `:selenium_chrome_headless_add_window_size` to `:selenium_chrome_headless_custom` --- spec/rails_helper.rb | 18 ------------------ spec/support/capybara.rb | 18 +++++++++++------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 4be8e3b936..98c265b5cf 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -80,21 +80,3 @@ config.include Devise::Test::ControllerHelpers, type: :view config.include Pundit::Matchers, type: :policy end - -Capybara.register_driver :headless_chrome do |app| - options = Selenium::WebDriver::Chrome::Options.new - options.add_argument('--headless') - options.add_argument('--no-sandbox') - options.add_argument('--disable-dev-shm-usage') - - Capybara::Selenium::Driver.new( - app, - browser: :chrome, - options: options - ) -end - -Capybara.javascript_driver = :headless_chrome -Capybara.default_driver = :headless_chrome -# Configure Capybara to wait longer for elements to appear -Capybara.default_max_wait_time = 20 diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 50f5e42547..c6e8ee618c 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -3,19 +3,23 @@ # Use Puma as the webserver for feature tests Capybara.server = :puma, { Silent: true } -# Use the fast rack_test driver for non-feature tests by default -Capybara.default_driver = :rack_test - # Create a custom driver based on Capybara's :selenium_chrome_headless driver -# This resolves a ElementClickInterceptedError when executing `click_button 'Sign in'` with DMP Assistant -Capybara.register_driver :selenium_chrome_headless_add_window_size do |app| +Capybara.register_driver :selenium_chrome_headless_custom do |app| # Get a copy of the default options for Capybara's :selenium_chrome_headless driver options = Capybara.drivers[:selenium_chrome_headless].call.options[:options].dup - options.add_argument('--window-size=1920,1080') # default window-size is only (800x600) + # Resolves ElementClickInterceptedError (default window-size is only (800x600)) + options.add_argument('--window-size=1920,1080') + options.add_argument('--no-sandbox') + options.add_argument('--disable-dev-shm-usage') # Create a new Selenium driver with the customised options Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) end +# Use the fast rack_test driver for non-feature tests by default +Capybara.default_driver = :rack_test +Capybara.javascript_driver = :selenium_chrome_headless_custom +Capybara.default_max_wait_time = 20 + RSpec.configure do |config| config.before(:each, type: :feature, js: false) do Capybara.use_default_driver @@ -23,6 +27,6 @@ # Use the Selenium headless Chrome driver for feature tests config.before(:each, type: :feature, js: true) do - Capybara.current_driver = :selenium_chrome_headless_add_window_size + Capybara.current_driver = :selenium_chrome_headless_custom end end From 41b91697d080ecc9e6d6f3db10f89f8967e73d5a Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Mon, 24 Mar 2025 13:25:01 -0600 Subject: [PATCH 8/8] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef2f56e833..0904c76f8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - Fixed bar chart click function in the Usage dashboard (GitHub issue #3443) - Fixed broken link for the V1 API documentation. - Fix `hidden_field_tag` Nested Attributes Format For Rails 7 Upgrade and Add Test Coverage [#3479](https://github.com/DMPRoadmap/roadmap/pull/3479) -- Update all workflows to `runs-on: ubuntu-24.04` [#3487](https://github.com/DMPRoadmap/roadmap/pull/3487) +- Update all workflows to `runs-on: ubuntu-24.04` and Consolidate Capybara Config [#3487](https://github.com/DMPRoadmap/roadmap/pull/3487) - Add pdf handling in `render_respond_to_format_with_error_message` [#3482](https://github.com/DMPRoadmap/roadmap/pull/3482) - Lower PostgreSQL GitHub Action Chrome Version to Address Breaking Changes Between Latest Chrome Version (134) and `/features` Tests [#3491](https://github.com/DMPRoadmap/roadmap/pull/3491)