-
Notifications
You must be signed in to change notification settings - Fork 518
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
allow deps to checkout unmerged commits #2922
Open
gucliti
wants to merge
1
commit into
erlang:main
Choose a base branch
from
gucliti:allow-deps-unmerged-commit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 have to say I'm a bit confused by this.
Since this command directly follows a
git clone
, the refs should already be alright. Additionally, cloning the same repository twice would cause problems:I'm struggling to find the specific scenario in which:
How is this taking place exactly? I would expect only a few seconds if not minutes at most to happen between both commands (depending on repo size and network speed), so this seems like an odd situation where one would fetch a branch or tag that does not yet exist but is created during the repo download?
Since this is untested, it's hard to frame and figure out how to manually validate this situation.
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.
{deps, [
{abcd,
{git, "https://gerrit-hello.ca/a/kitty/kitty-abcd.git",
{ref, "fdf3bd64c113375399e570402be3864b539a0955"}}},
{bcde,
{git, "https://gerrit-hello.ca/a/kitty/kitty-bcde.git",
{ref, "225773cef58bdfab33457e421ae60c0aac0737a0"}}},
{cdef,
{git, "https://gerrit-hello.ca/a/kitty/kitty-cdef.git",
{ref, "361d0f873a1d3554104d0104873dcfb6dc614fc0"}}},
{escs,
{git, "https://gerrit-hello.ca/a/kitty/kitty-escs.git",
{ref, "39f13a1bd093974853314fb55c00f4cd71f0ab87"}}},
....
Scenario for the change:
For example, there is a parent project repository (sys) that depends on a set of submodules, each of which has its own repository. Each submodule has its own common test, and the parent project also has an integrated common test.
Let’s say a submodule "abcd" has a commit on its master branch (assume the commit SHA ID is "fdf3bd64...."). The submodule (abcd)'s commit triggers a CI integration test.
In the CI flow job (e.g., Jenkins), the parent project repository is pulled in clean workspace. At this point, the parent project’s rebar.config refers to the master branch refs (SHA) of each submodule. Then, the CI job modifies the rebar.config, replacing the SHA of submodule "abcd" with "fdf3bd64...". After fetching the dependencies of the parent project (sys), the integration test runs and provides a verdict for the corresponding commit of submodule "abcd".
Without the change, the parent project (sys)’s rebar3 deps would fail. This is because currently, rebar3 performs a git clone of "abcd" followed by git checkout "fdf3bd64...". However, the specific commit SHA ("fdf3bd64...") in submodule "abcd" does not exist in the history of the cloned master branch. As a result, git checkout "fdf3bd64..." would fail. This change attempts to fetch the SHA "fdf3bd64..." from the remote repository and then performs another git checkout "fdf3bd64...".
This change does not modify the original behavior of rebar3 (e.g., if the ref can already be found in the history of the local cloned repository).
This change is tested in a CI for the (sys) project.
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.
After this step, do you do a
rebar3 upgrade abcd
to make sure Rebar3 fetches the update and re-propagates the transitive dependency versions to the lock file, or is this skipped wholesale?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.
correct: CI job modifies both rebar.config & rebar.lock in the parent project (sys)’s just after a clean clone of (sys) into Jenkins. then directly start "rebar3 compile".
Manual "rebar3 upgrade abcd" to update rebar.lock works fine.
[repo/gucliti/sys]$ ./rebar3 upgrade abcd
Building ...
===> Verifying dependencies...
Building ...
Building ...
===> Upgrading abcd (from {git,"https://gerrit-hello.ca/a/kitty/kitty-abcd.git",
{ref,"d6dd6e5d2c35db54e9b5a59b38a252a4123cc783"}})
===> No upgrade needed for ...
....
===> No upgrade needed for ...
===> No upgrade needed for ...
===> No upgrade needed for ...
[repo/gucliti/sys]$
Note: above is real log when obfuscated names. "d6dd6e5d..." is a SHA from an unmerged commit.
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.
So should the CI steps just include a
rebar3 upgrade dep1,dep2,dep3
step to avoid having to add specific workarounds for people modifying autogenerated lock files? Rebar3 maintains its own files and deps to avoid these inconsistencies, I don't know that it's the best strategy to pepper workarounds for manual changes here and there?I'm still surprised the
git clone
step doesn't fail when the repo is already checked out.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.
Mangling
rebar3.config
andrebar.lock
aftergit clone
are almost same for CI script, it knows origial SHA of "depx". Yes, CI can just updatesrebar3.config
, thenrebar3 upgrade depx
.If not use modified version of rebar3, and only update the SHA (an unmerged commit) of the dependency module "depx" in
rebar3.config
,rebar3 upgrade depx
will fail,DIAGNOSTIC=1 rebar3 upgrade depx
shows:... fatal: reference is not a tree: d6dd6e5d...
However with the modified version of
rebar3
, it can successfully updaterebar.lock
withrebar3 upgrade depx
.The key point of this change is to support CI scenarios where a dependency that hasn't yet been merged into master needs to be used for integration testing for verdict on "depx".
CI flow almost always pick one "delta" (a change in dep_x):
git clone sys
in a new ephemera workspace, complile, test, and finally clear the workspace.