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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jan 5, 2023

Conversation

andrewthauer
Copy link
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
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
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

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
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
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

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.
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