From 23a81a0480d1fea5d5d072ff678336e6ddb65132 Mon Sep 17 00:00:00 2001 From: Brian Shand Date: Tue, 23 Sep 2025 11:14:48 +0100 Subject: [PATCH 1/4] Capistrano: deploy:preinstall should fix up installed gem permissions --- CHANGELOG.md | 3 ++- lib/ndr_dev_support/capistrano/ndr_model.rb | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a20014e..1747b79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## [Unreleased] -*no unreleased changes* +### Fixed +* Capistrano: deploy:preinstall should fix up installed gem permissions ## 7.3.3 / 2025-07-31 ### Fixed diff --git a/lib/ndr_dev_support/capistrano/ndr_model.rb b/lib/ndr_dev_support/capistrano/ndr_model.rb index b229a01..41a642c 100644 --- a/lib/ndr_dev_support/capistrano/ndr_model.rb +++ b/lib/ndr_dev_support/capistrano/ndr_model.rb @@ -164,8 +164,12 @@ # already there: run "rm -rf #{File.join(release_path, path)} && ln -s #{File.join(shared_path, path)} #{File.join(release_path, path)}" end + end + + after 'deploy:finalize_update', 'ndr_dev_support:filesystem_tweaks' - # Make the shared/bundle/ directory writeable by deployers: + desc 'Make the shared/bundle/ directory writeable by deployers' + task :bundle_permissions do # We already set group permissions correctly in the bundle directory, but some gem installs # ignore these permissions, so we need to fix them up. # Set deployer group for everything created by this user @@ -178,7 +182,8 @@ '-not -perm -0064 -print0 |xargs -r0 chmod g+rw,o+r' end - after 'deploy:finalize_update', 'ndr_dev_support:filesystem_tweaks' + # Ensure we have fixed the bundle permissions before potentially aborting + before 'ndr_dev_support:check_preinstall', 'ndr_dev_support:bundle_permissions' end end From bbfb66cf102d6adcf3e953987de1a56eda73894b Mon Sep 17 00:00:00 2001 From: Brian Shand Date: Tue, 23 Sep 2025 11:30:46 +0100 Subject: [PATCH 2/4] Capistrano: Cleanup bundled gems for old ruby versions Deletes shared bundle files that no longer match any installed releases. --- CHANGELOG.md | 3 +++ .../capistrano/install_ruby.rb | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1747b79..4ad8e55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ### Fixed * Capistrano: deploy:preinstall should fix up installed gem permissions +### Added +* Capistrano: cleanup bundled gems for old ruby versions. + ## 7.3.3 / 2025-07-31 ### Fixed * Update rubocop version dependency diff --git a/lib/ndr_dev_support/capistrano/install_ruby.rb b/lib/ndr_dev_support/capistrano/install_ruby.rb index 87ab17b..c7f6abb 100644 --- a/lib/ndr_dev_support/capistrano/install_ruby.rb +++ b/lib/ndr_dev_support/capistrano/install_ruby.rb @@ -97,7 +97,29 @@ fi SHELL end + + desc <<~DESC + Cleanup bundled gems for old ruby versions. + + Deletes shared bundle files that no longer match any installed releases. + + This interacts reasonably with deploy:preinstall: + When deploy:preinstall installs new .rbenv and new shared bundled gems, this + will not delete them. If an older ruby version is then deployed, this removes + the new version's installed bundle, but leaves the .rbenv installation. + DESC + task :cleanup_unused_bundles do + # For ruby X.Y.Z, bundled gems are in .../shared/bundle/ruby/X.Y.0 + # Generates e.g. + # find_options="-not ( -name DUMMY -or -name 3.1.0 -or -name 3.2.0 )" + # and then removes e.g. shared/bundle/ruby/3.0.0 + run "find_options=\"-not ( -name DUMMY `grep -ho '^[0-9]*[.][0-9]*' " \ + "#{releases_path}/*/.ruby-version | sed -e 's/.*/-or -name &.0/'` ) \"; " \ + "find #{File.join(shared_path, 'bundle/ruby/*')} -maxdepth 0 $find_options " \ + "-exec echo rm -rf '{}' ';' -exec rm -rf '{}' ';'" + end end before 'bundle:install', 'ndr_dev_support:install_ruby' + after 'deploy:finalize_update', 'ndr_dev_support:cleanup_unused_bundles' end From 478ad19ee4ddbefe9026a297eee122395c5499c7 Mon Sep 17 00:00:00 2001 From: Brian Shand Date: Tue, 23 Sep 2025 11:37:56 +0100 Subject: [PATCH 3/4] Support Ruby 3.4 --- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 1 + CHANGELOG.md | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 521af05..4380a00 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.3 + ruby-version: 3.4 - name: Install dependencies run: bundle install - name: Run RuboCop against BASE..HEAD changes diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ab6dc19..3a8bf0d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,6 +10,7 @@ jobs: - '3.1' - '3.2' - '3.3' + - '3.4' gemfile: - gemfiles/Gemfile.rails70 - gemfiles/Gemfile.rails71 diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ad8e55..77129a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## [Unreleased] ### Fixed * Capistrano: deploy:preinstall should fix up installed gem permissions +* Support Ruby 3.4 ### Added * Capistrano: cleanup bundled gems for old ruby versions. From acbd5253fe6156445c9987b90aacfdad49b81cf1 Mon Sep 17 00:00:00 2001 From: Brian Shand Date: Tue, 23 Sep 2025 12:00:30 +0100 Subject: [PATCH 4/4] Fixup GitHub actions tests --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3a8bf0d..0c0cee0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,7 @@ on: [push] jobs: test: strategy: + fail-fast: false matrix: ruby-version: - '3.1' @@ -21,6 +22,10 @@ jobs: # https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html - ruby-version: '3.1' gemfile: 'gemfiles/Gemfile.rails80' + # rails 7.0 requires ruby <= 3.3 + # https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html + - ruby-version: '3.4' + gemfile: 'gemfiles/Gemfile.rails70' name: Ruby ${{ matrix.ruby-version }} / Bundle ${{ matrix.gemfile }}