Skip to content

feat: add module source pins - #8587

Merged
jedevc merged 1 commit into
dagger:mainfrom
jedevc:module-source-pins
Oct 18, 2024
Merged

jedevc merged 1 commit into
dagger:mainfrom
jedevc:module-source-pins

Conversation

@jedevc

@jedevc jedevc commented Sep 27, 2024 •

Copy link
Copy Markdown
Contributor

Fixes #7898.

This PR modifies the module config dependencies field to ensure that we preserve the original tags that the user specified during dagger install.

So with a command like:

$ dagger install github.com/dagger/dagger-test-modules

We get the following (see the diff between before and after):

diff --git a/dagger.json.old b/dagger.json
index 4ec8db5..533fc4a 100644
--- a/dagger.json.before
+++ b/dagger.json.after
@@ -4,7 +4,8 @@
   "dependencies": [
     {
       "name": "root-mod",
-      "source": "github.com/dagger/dagger-test-modules@323d56c9ece3492d13f58b8b603d31a7c511cd41"
+      "source": "github.com/dagger/dagger-test-modules@main",
+      "pin": "323d56c9ece3492d13f58b8b603d31a7c511cd41"
     }
   ],
   "source": ".",

This essentially allows us to keep the original source that we installed a dependency via, while also keeping the pins.

Note

Naming note - I chose pin because that matches up with terminology in other tooling, and it's also generic. If we ever support non-git remote source (e.g. OCI images), then pin is more generic and correct than commit.

To gracefully upgrade old dagger.jsons, we leave source unaltered, and copy the pin from the commit in the source (which is always guaranteed to be there).

@jedevc jedevc added the needs/changelog Pull requests that require a changelog entry label Sep 27, 2024
@jedevc
jedevc force-pushed the module-source-pins branch 3 times, most recently from 7b9b61e to ada2f4c Compare October 8, 2024 12:42
@jedevc
jedevc marked this pull request as ready for review October 8, 2024 12:45
@jedevc
jedevc requested review from a team as code owners October 8, 2024 12:45
@jedevc
jedevc requested a review from sipsma October 8, 2024 13:02
@jedevc
jedevc force-pushed the module-source-pins branch from ada2f4c to 82f08c7 Compare October 8, 2024 14:22
require.Equal(t, "", strings.TrimSpace(out))
}

func (ConfigSuite) TestDepPins(ctx context.Context, t *testctx.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be very nice to have a test where the pinned commit is behind HEAD on the branch and we verify that the pinned commit is used correctly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a test for this using dagger/dagger-test-modules#5, and another one for testing that dagger develop doesn't modify the pins.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved that one, will let you press the merge button in case anything else needed

@jpadams

jpadams commented Oct 16, 2024

Copy link
Copy Markdown
Contributor

cc @vmaffet-fast

@jedevc jedevc mentioned this pull request Oct 17, 2024
1 of 2 tasks
@jedevc
jedevc force-pushed the module-source-pins branch from a2c5268 to b2e1407 Compare October 17, 2024 14:54
@jedevc
jedevc requested a review from sipsma October 17, 2024 14:54
require.Equal(t, "", strings.TrimSpace(out))
}

func (ConfigSuite) TestDepPins(ctx context.Context, t *testctx.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved that one, will let you press the merge button in case anything else needed

Signed-off-by: Justin Chadwell <[email protected]>
@jedevc
jedevc force-pushed the module-source-pins branch from b2e1407 to 2738237 Compare October 18, 2024 10:07
@jedevc
jedevc merged commit 0d99f22 into dagger:main Oct 18, 2024
@jedevc
jedevc deleted the module-source-pins branch October 18, 2024 10:41
@jedevc jedevc added this to the v0.13.6 milestone Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs/changelog Pull requests that require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Allow me to keep tags in dagger.json

3 participants