-
Notifications
You must be signed in to change notification settings - Fork 900
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
Fix Gemfile.lock.release handling for plugins #22075
base: master
Are you sure you want to change the base?
Conversation
lib/manageiq/environment.rb
Outdated
@@ -16,7 +16,6 @@ def self.manageiq_plugin_update(plugin_root = nil, force_bundle_update: true) | |||
# determine plugin root dir. Assume we are called from a 'bin/' script in the plugin root | |||
plugin_root ||= Pathname.new(caller_locations.last.absolute_path).dirname.parent | |||
|
|||
setup_gemfile_lock if ENV["CI"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point the Gemfile.lock will have already been patched and this would just overwrite it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still need this for build...or does build manually copy the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build doesn't call bin/setup
in each plugin dir, it only does this for the core repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok - I forgot that core doesn't call into these methods...I really need to push my branch where it does, cause I keep confusing myself haha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. So is this line needed or not?
bin/ci/patch_plugin_gemfile_lock
Outdated
with open('Gemfile.lock') as f: | ||
gemfile_lock = f.read() | ||
|
||
gemfile_lock_patched = re.compile("GIT\n remote: %s\n revision: .+\n branch: .+\n" %(os.environ['GITHUB_REPOSITORY'])).sub('PATH\n remote: .\n', gemfile_lock) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE these GitHub actions env vars don't with with cross-repo but this is no different from the existing before_install checks so I left it for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to log the Gemfile.lock before and after patching? Or maybe just the diff? I was hoping to see what this looks like in the CI log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo in your comment... I'm not sure what you're saying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, it was supposed to be env vars
, basically when running cross-repo for the oparin branch the GITHUB_BASE_REF
is still master
because the PR is created in the cross-repo repository. This is used https://github.com/ManageIQ/manageiq/blob/master/bin/before_install#L25 and will be used by the providers, just means we can't test this easily with cross-repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah... shucks... I just asked below if we can test it with cross repo to see how it works. I guess you can do the old fashioned way and just create a WIP plugin PR to use this code to verify it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I just committed a Gemfile.lock.release
to bypass the need to copy it from core
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to log the Gemfile.lock before and after patching? Or maybe just the diff? I was hoping to see what this looks like in the CI log.
Gemfile.lock is already logged in CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was more interested in seeing what it changed and less about the full contents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see an end to end run of this in CI to better understand what's being patched but I like the idea of surgically fixing this for release branches to ensure we're testing with the same gems.
bin/ci/patch_plugin_gemfile_lock
Outdated
with open('Gemfile.lock') as f: | ||
gemfile_lock = f.read() | ||
|
||
gemfile_lock_patched = re.compile("GIT\n remote: %s\n revision: .+\n branch: .+\n" %(os.environ['GITHUB_REPOSITORY'])).sub('PATH\n remote: .\n', gemfile_lock) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to log the Gemfile.lock before and after patching? Or maybe just the diff? I was hoping to see what this looks like in the CI log.
bin/ci/patch_plugin_gemfile_lock
Outdated
with open('Gemfile.lock') as f: | ||
gemfile_lock = f.read() | ||
|
||
gemfile_lock_patched = re.compile("GIT\n remote: %s\n revision: .+\n branch: .+\n" %(os.environ['GITHUB_REPOSITORY'])).sub('PATH\n remote: .\n', gemfile_lock) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo in your comment... I'm not sure what you're saying.
And this is what the diff looks like for the manageiq-providers-autosde plugin:
So the new block looks like this:
|
Will the bundle install in the ruby setup update any dependencies under |
You mean like if a plugin updated their gemspec but we didn't update the Gemfile.lock? The bundle install will fail since it can't resolve the dependencies until we update Gemfile.lock which is what we want rather than silently succeeding but not using the right gem versions. Ran a test to show this, I downgraded the resolved autosde_openapi_client to 1.0.54 in the Gemfile.lock where the spec requires ~> 1.1.0: https://github.com/ManageIQ/manageiq-providers-autosde/runs/8016809143?check_suite_focus=true#step:5:49 |
23ef482
to
78b3650
Compare
78b3650
to
8f51075
Compare
@Fryguy what do you think about this? |
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation. |
@Fryguy you good to merge? |
Is this good to go? |
Honestly I don't remember - this was a cross-repo thing, but I'm not sure it's needed? |
@Fryguy this wasn't cross repo, the issue here is that when running specs on release branches on GHA plugins are not using the |
Ok thanks - I double checked and Ruby is installed by default in GHA, so this could be a ruby script: See https://github.com/Fryguy/sandbox/actions/runs/5178658485/jobs/9330435149#step:10:18 (installed version is |
Hm must have been added since I originally tested this (has been almost a year I guess so that makes sense). Okay I'm going to have to rewrite and retest this then |
8f51075
to
432e8cd
Compare
I thought setup_gemfile_lock was also called in core bin/setup, so specs would use it. But I don't see that here. 🤔 |
Yea, I can only find it within this file. |
ok, trying to follow this thread in development, in ci, It was moved into that script so the gemfile.lock can be setup before all this ruby processing. I'm 👍 on this. We just need to update the 35 repos with this change so this is WIP: rewrite in ruby? ugh. do we just revisit this every 6-12 months? |
I haven't had time to rewrite the script in ruby and retest this whole thing. Are we 👎 on a python script? Is that a blocker for merge? |
432e8cd
to
21f8197
Compare
We were just waiting on a rewrite to Ruby. We can merge now with python and change in a follow up. Separately we need a change to all of the plugins bin/before_install. However, alternatively we may want to move towards running a shared bin/before_install from core. I had started that work but never finished it. |
Think I vote keeping python and moving script to not sure if it will be tricky to link in the ci.yaml file. Maybe as simple as |
I was about to merge but noticed the python script doesn't modify the Gemfile.lock.release, but instead modifies Gemfile.lock. Not sure I understand how that's supposed to work? |
Guess I need a better PR description, the problem I was trying to solve was that plugin specs on release branches weren't running with the gems that were in the Gemfile.lock.release because bundler saw the Gemfile.lock as invalid due to the plugin local path override and would bundle update everything. This script patches the |
ok. did that clear up the confusion. Or at least ready to blast out all child projects to point to this common script? |
@agrare ok that part makes sense, but the "copy Gemfile.lock.release to Gemfile.lock" line was removed here https://github.com/ManageIQ/manageiq/pull/22075/files#diff-3407d3d6c1f5822da11eac8ba10639efe824e11d65c8bd19ce034253ea124eb9L85. Or is this relying on the core bin/before_install ( Lines 40 to 45 in 34f0a74
|
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the |
21f8197
to
206b325
Compare
Checked commits agrare/manageiq@508107c~...206b325 with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint |
setup_gemfile_lock if ci? | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively, if we want to make a slow transition, we can run this unless we are running build version 2:
setup_gemfile_lock if ci? && ENV["BUILD"] != "v2"
and when we upgrade the github/ci.yaml
we can set an env BUILD=v2
when we upgrade the ci.yaml
to call bin/ci/patch_plugin_gemfile_lock
This pull request is not mergeable. Please rebase and repush. |
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the |
1 similar comment
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the |
When plugins run tests on a release branch the
Gemfile.lock.release
was copied toGemfile.lock
but since the plugin spec doesn't match (GIT
vsPATH
) theGemfile.lock
was invalidated and rebuilt with the latest gem versions.This meant that plugin tests on release branches were not actually testing with the gems from the release.
This change patches the
Gemfile.lock
to fix the engine spec so theGemfile.lock
isn't invalidated. It will have to be called by thebin/before_install
script in each plugin.NOTE: this has to be done prior to ruby setup since that runs bundle install, thus I implemented this in Python as that is available on github actions already. Awk/sed all process one line at a time so rebuilding the entire gem block proved impractical though I'm sure it could be done.