Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make gem-bump-version inherit ruby/bundler versions #7239

Conversation

jeffwidman
Copy link
Member

@jeffwidman jeffwidman commented May 4, 2023

We need to inherit the bundler version used in updater/Gemfile.lock when running the gem-bump-version GitHub action.

Otherwise when the action runs, ruby/setup-ruby will use a default bundler version, which will change BUNDLED WITH to this default version.

Normally that wouldn't matter, but we also pin the version of bundler used in the native helper for the bundler ecosystem. And when we run the Updater in production at GitHub, since BUNLDED WITH is the last time we run bundle install, it'll change the bundler version not only for the updater app, but also for the native helper. So we'd be silently getting a different version of bundler, but only when running the updater, which means local debugging would see the pinned bundler version.

Instead, let's avoid all that by ensuring we respect the version of bundler pinned in Gemfile.lock.

By default, setup/setup-ruby looks for Gemfile.lock in the root directory, so the way to do that is set the working directory to updater so it looks for updater/Gemfile.lock.

Unfortunately, that creates a new problem... ruby/setup-ruby looks for .ruby-version to find the Ruby version to run. Since we set the working directory to updater, it looks for updater/.ruby-version. And we don't want to move .ruby-version out of the root directory because that's where rubocop and other tooling such as IDE's look for it.

Deivid pointed out that in the context of running this action, the version of Ruby really doesn't matter, since it's only used for the bump-version.rb script, which is very simple/generic. However, when I tried running the action, ruby/setup-ruby complained that it required a version of ruby to be specified. We don't want to have yet-another-place to maintain the ruby version, so the way around that was to add a symlink: cd updater && ln -s ../.ruby-version .ruby-version.

I tested this in another repo, and it worked successfully... the resulting PR used the version of ruby pinned in the root .ruby-version and the version of bundler pinned in updater/Gemfile.lock's BUNDLED WITH.

Related:

@jeffwidman jeffwidman requested a review from a team as a code owner May 4, 2023 21:57
@jeffwidman jeffwidman changed the title Make gem-bump-version inherit ruby/bundler versions Make gem-bump-version inherit ruby/bundler versions May 4, 2023
We need to inherit the bundler version used in `updater/Gemfile.lock`
when running the `gem-bump-version` GitHub action.

Otherwise when the action runs, `ruby/setup-ruby` will use a default
`bundler` version, which will change `BUNDLED WITH` to this default
version.

Normally that wouldn't matter, but we also pin the version of `bundler`
used in the native helper for the `bundler` ecosystem. And when we run
the Updater in production at GitHub, since `BUNLDED WITH` is the last
time we run `bundle install`, it'll change the bundler version not only
for the `updater` app, but also for the native helper. So we'd be
silently getting a different version of `bundler`, but only when running
the `updater`, which means local debugging would see the pinned bundler
version.

Instead, let's avoid all that by ensuring we respect the version of
`bundler` pinned in `Gemfile.lock`.

By default, `setup/setup-ruby` looks for `Gemfile.lock` in the root
directory, so the way to do that is set the working directory to
`updater` so it looks for `updater/Gemfile.lock`.

Unfortunately, that creates a new problem... `ruby/setup-ruby` looks for
`.ruby-version` to find the Ruby version to run. Since we set the
working directory to `updater`, it looks for `updater/.ruby-version`.
And we don't want to move `.ruby-version` out of the root directory
because that's where `rubocop` and other tooling such as IDE's look for
it.

Deivid pointed out that in the context of running this action, the
version of Ruby really doesn't matter, since it's only used for the
`bump-version.rb` script, which is very simple/generic. However, when I
tried running the action, `ruby/setup-ruby` complained that it required
a version of ruby to be specified. We don't want to have
_yet-another-place_ to maintain the ruby version, so the way around that
was to add a symlink: `cd updater && ln -s ../.ruby-version
.ruby-version`.

I tested this in another repo, and it worked successfully... the
resulting PR used the version of `ruby` pinned in the root
`.ruby-version` and the version of `bundler` pinned in
`updater/Gemfile.lock`'s `BUNDLED WITH`.
@jeffwidman jeffwidman force-pushed the use-symlink-plus-working-directory-set-to-updater-for-bump-version branch from f2f5e62 to 8c91e89 Compare May 4, 2023 22:02
@jeffwidman jeffwidman mentioned this pull request May 4, 2023
@jeffwidman jeffwidman merged commit d556fd9 into main May 4, 2023
@jeffwidman jeffwidman deleted the use-symlink-plus-working-directory-set-to-updater-for-bump-version branch May 4, 2023 22:55
brettfo pushed a commit to brettfo/dependabot-core that referenced this pull request Oct 11, 2023
…#7239)

We need to inherit the bundler version used in `updater/Gemfile.lock`
when running the `gem-bump-version` GitHub action.

Otherwise when the action runs, `ruby/setup-ruby` will use a default
`bundler` version, which will change `BUNDLED WITH` to this default
version.

Normally that wouldn't matter, but we also pin the version of `bundler`
used in the native helper for the `bundler` ecosystem. And when we run
the Updater in production at GitHub, since `BUNLDED WITH` is the last
time we run `bundle install`, it'll change the bundler version not only
for the `updater` app, but also for the native helper. So we'd be
silently getting a different version of `bundler`, but only when running
the `updater`, which means local debugging would see the pinned bundler
version.

Instead, let's avoid all that by ensuring we respect the version of
`bundler` pinned in `Gemfile.lock`.

By default, `setup/setup-ruby` looks for `Gemfile.lock` in the root
directory, so the way to do that is set the working directory to
`updater` so it looks for `updater/Gemfile.lock`.

Unfortunately, that creates a new problem... `ruby/setup-ruby` looks for
`.ruby-version` to find the Ruby version to run. Since we set the
working directory to `updater`, it looks for `updater/.ruby-version`.
And we don't want to move `.ruby-version` out of the root directory
because that's where `rubocop` and other tooling such as IDE's look for
it.

Deivid pointed out that in the context of running this action, the
version of Ruby really doesn't matter, since it's only used for the
`bump-version.rb` script, which is very simple/generic. However, when I
tried running the action, `ruby/setup-ruby` complained that it required
a version of ruby to be specified. We don't want to have
_yet-another-place_ to maintain the ruby version, so the way around that
was to add a symlink: `cd updater && ln -s ../.ruby-version
.ruby-version`.

I tested this in another repo, and it worked successfully... the
resulting PR used the version of `ruby` pinned in the root
`.ruby-version` and the version of `bundler` pinned in
`updater/Gemfile.lock`'s `BUNDLED WITH`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants