Skip to content

feat(ruby): add Gemfile.Lock updater#1790

Merged
chingor13 merged 1 commit intogoogleapis:mainfrom
andrewthauer:feat-gemfile-lock
Jan 5, 2023
Merged

feat(ruby): add Gemfile.Lock updater#1790
chingor13 merged 1 commit intogoogleapis:mainfrom
andrewthauer:feat-gemfile-lock

Conversation

@andrewthauer
Copy link
Copy Markdown
Contributor

@andrewthauer andrewthauer commented Dec 31, 2022

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1768 🦕

Adds support for updating the ruby gem version in a committed Gemfile.lock file. This helps ensure that bundle install works correctly after a version.rb version change. There is also some additional logic introduced to simulate how ruby Gem::Version handles - with prerelease semvers (e.g. 1.0.0-alpha is parsed as `1.0.0.pre.alpha).

A future update could make use of the new common stringifyRubyVersion to translate the version into the more commonly used . prerelease seperatorwhich is treated "as is" and avoids the .pre. replacement of -.

Adds support for updating the ruby gem version in a committed
Gemfile.lock file. This helps ensure that bundle install works correctly
after a version.rb version change. There is also some additional logic
introduced to simulate how ruby Gem::Version handles `-` with prerelease
semvers (e.g. `1.0.0-alpha` is parsed as `1.0.0.pre.alpha).

A future update could make use of the new common stringifyRubyVersion to
translate the version into the more commonly used `.` prerelease seperatorwhich
is treated "as is" and avoids the `.pre.` replacement of `-`.
Copy link
Copy Markdown
Contributor

@chingor13 chingor13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@andrewthauer
Copy link
Copy Markdown
Contributor Author

andrewthauer commented Jan 13, 2023

@chingor13 - Question. What is the typical cadence for releases of release-please-action? I see https://github.com/google-github-actions/release-please-action/pull/681 has been open for a little while now.

@kjellberg
Copy link
Copy Markdown

kjellberg commented Jan 17, 2023

I think this PR just broke my CI for a Rails application. It's now automatically overwriting the first listed gem's version in Gemfile.lock. With or without a specified version file.

Example from a release-please PR request in a Rails repo:

# Gemfile.lock
- actioncable (7.0.4)
+ actioncable (0.0.1)

Release please config:

    steps:
      - uses: GoogleCloudPlatform/release-please-action@v3
        id: release
        with:
          release-type: ruby
          version-file: "version.rb"
          bump-minor-pre-major: true
# Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    actioncable (7.0.4)
      actionpack (= 7.0.4)
      activesupport (= 7.0.4)
      nio4r (~> 2.0)
      websocket-driver (>= 0.6.1)
    actionmailbox (7.0.4)
    .....

@andrewthauer
Copy link
Copy Markdown
Contributor Author

andrewthauer commented Jan 17, 2023

@kjellberg - Sorry to hear this. It looks like you haven't set a package-name in the release action config. My initial guess is this could be related. If you set this does the problem go away? If so, I think a quick fix would be to bypass this feature if the package-name isn't set. I can throw up a PR to fix if that's the case.

@andrewthauer
Copy link
Copy Markdown
Contributor Author

It looks like this is likely the problem. Putting together a PR to fix the issue.

andrewthauer added a commit to andrewthauer/release-please that referenced this pull request Jan 17, 2023
PR googleapis#1790 introduced support to update Gemfile.lock files. However this
introduced an issue that updates random gem versions when the
`package-name` (gemName) is not provided (which is optional). This fix
ensures the gemName is valid before attempting to update the
Gemfile.lock file.
@kjellberg
Copy link
Copy Markdown

It looks like this is likely the problem. Putting together a PR to fix the issue.

Makes sense.. thanks :)

chingor13 pushed a commit that referenced this pull request Jan 17, 2023
PR #1790 introduced support to update Gemfile.lock files. However this
introduced an issue that updates random gem versions when the
`package-name` (gemName) is not provided (which is optional). This fix
ensures the gemName is valid before attempting to update the
Gemfile.lock file.
carlosantoniodasilva added a commit to judoscale/judoscale-ruby that referenced this pull request Apr 28, 2025
…iles

This is meant to update the Gemfile.lock files to the new version that's
being created, otherwise they'll become invalid when we merge the
release PR, causing test failures and requiring us to manually run bundle
install, as it happened with v1.11.0.

This is a combination of "I hope it works", based on some searching and
putting pieces together:

googleapis/release-please#1768
googleapis/release-please#1790
googleapis/release-please#1621
carlosantoniodasilva added a commit to judoscale/judoscale-ruby that referenced this pull request Apr 28, 2025
…iles

This is meant to update the Gemfile.lock files to the new version that's
being created, otherwise they'll become invalid when we merge the
release PR, causing test failures and requiring us to manually run bundle
install, as it happened with v1.11.0.

This is a combination of "I hope it works", based on some searching and
putting pieces together:

googleapis/release-please#1768
googleapis/release-please#1790
googleapis/release-please#1621
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add GemfileLock updater to bump version in Gemfile.lock for Ruby

3 participants