You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add dagger project update to all CI examples #2315
Should we always suggest dagger project update to be run before dagger do xxxx in our CI examples like GitHub Actions or Jenkins?
decide yes/no for now (decision of "no" for now) - [ ] if yes for now, what would trigger a change to "no" or to remove this advice
FAQ / doc / blog on how this works now (caveats, trade-offs) and what future will look like (@jlongtine could you sketch out blog outline for something like this?) with a diagram
Commit your pkg dir into git, don't do dagger project update in CI. This is a temporary solution until we have proper package management support.
Since this is the simplest answer, I think this is what we should recommend to users for now.
Follow along for more details into the alternative.
When not to commit?
I really don't like committing external dependencies in git. Some users will be the same, either by personal preference or some other requirement. It makes repos bigger forever.
I've built a reusable package for Morfose and I have cue.mod/pkg in .gitignore in the main project.
We do support this actually (somewhat) but you should understand the caveats so we should document this but consider it a more advanced guide perhaps. I can provide some light for now.
How package management (PM) works
I'll keep this very brief.
The cue.mod/pkg is a vendor directory. Right now, we put external packages in there, but with future PM, they should go to a $HOME/cue/modcache directory, globally.
The cue.mod/module.cue today only has the module: string field, but this file will later include everything also in a go.mod file (i.e., require, replace, etc...).
Installing an external dependency
In the meantime, dagger has already implemented an in-house solution, as a workaround, where if you install an external package with dagger project update example.com/docker/[email protected], additionaldagger.mod and dagger.sum files get created:
Which means that we checksum and check external dependencies... but not dagger built-in ones.
Updating dagger built-ins
Dagger built-ins (i.e., dagger.io and universe.dagger.io modules) are embeded in the dagger binary, so they aren't added to dagger.mod and dagger.sum.
If you change your binary version, you need to also update your built-ins from the new binary by doing dagger project update, which copies those modules over to cue.mod/pkg.
The issue with running dagger project update in CI
So, for external packages, the checksum should give you some security that a dagger project update won't give you different package contents from what your plan is importing/expecting.
But for built-ins, consider this risky scenario:
You're not pinning the dagger binary version in CI
You've not commited pkg to git
You're running dagger project update on every run
In this case, even if your built-ins are being updated according to what's embeded in your binary, you may get something that's incompatible with your plan, or simply get unexpected (i.e., different) results.
BUT... if you pin the dagger binary version in CI, then I don't see an issue. I may be wrong, if someone else has something to add.
Remember that with external packages, I'm assuming you're pinning to a tag version as well, and not a branch. Otherwise it's the same considerations.
Another scenario
The dagger-for-github package needs to test against multiple dagger versions. In this case you need not to commit the vendor (pkg) directory and need dagger project update each time because you have different binaries in your steps. This is a valid case.
Conclusion
If you know what you're doing, got ahead. 🙂
Commands summary
I've just checked these commands and they need a bit of fixing and consistency improvements related to updating built-ins vs external.
dagger project update
Copies built-ins from binary to cue.mod/pkg
Looks like it's not installing external packages anymore, I need to test this!
dagger project update -u
Should update installed packages (listed in cue.mod/dagger.mod) but looks like unreachable code now!
Hello, if this is not planned yet, could you please consider having a subcommand to vendor dependencies in the package management command? We appreciate having self-sufficient repositories containing all the dependencies 😉
@yann-soubeyrand the dependencies are already vendored to cue.mod/pkg when you run dagger project update, both built-in (core and universe) and external (from other git repos).
This issue about which convention to adopt in our CI examples. Vendor + commit, or run update every time.
Hi @helderco, I know that dependencies are vendored at the moment, I was refering to a sentence above which seems to indicate this could not be the case anymore in the future:
The cue.mod/pkg is a vendor directory. Right now, we put external packages in there, but with future PM, they should go to a $HOME/cue/modcache directory, globally.
I think this is a good idea, but I’d like to keep the ability to vendor dependencies if one needs to, for various reasons (much like go mod vendor allows to vendor go modules today).
Activity
jpadams commentedon May 4, 2022
https://discord.com/channels/707636530424053791/796905486145683506/950536303747932221
helderco commentedon May 6, 2022
The simplest answer
Commit your
pkgdir into git, don't dodagger project updatein CI. This is a temporary solution until we have proper package management support.Since this is the simplest answer, I think this is what we should recommend to users for now.
Follow along for more details into the alternative.
When not to commit?
I really don't like committing external dependencies in git. Some users will be the same, either by personal preference or some other requirement. It makes repos bigger forever.
I've built a reusable package for Morfose and I have
cue.mod/pkgin.gitignorein the main project.We do support this actually (somewhat) but you should understand the caveats so we should document this but consider it a more advanced guide perhaps. I can provide some light for now.
How package management (PM) works
I'll keep this very brief.
The
cue.mod/pkgis a vendor directory. Right now, we put external packages in there, but with future PM, they should go to a$HOME/cue/modcachedirectory, globally.The
cue.mod/module.cuetoday only has themodule: stringfield, but this file will later include everything also in ago.modfile (i.e., require, replace, etc...).Installing an external dependency
In the meantime, dagger has already implemented an in-house solution, as a workaround, where if you install an external package with
dagger project update example.com/docker/[email protected], additionaldagger.modanddagger.sumfiles get created:Which means that we checksum and check external dependencies... but not dagger built-in ones.
Updating dagger built-ins
Dagger built-ins (i.e.,
dagger.ioanduniverse.dagger.iomodules) are embeded in the dagger binary, so they aren't added todagger.modanddagger.sum.If you change your binary version, you need to also update your built-ins from the new binary by doing
dagger project update, which copies those modules over tocue.mod/pkg.The issue with running
dagger project updatein CISo, for external packages, the checksum should give you some security that a
dagger project updatewon't give you different package contents from what your plan is importing/expecting.But for built-ins, consider this risky scenario:
pkgto gitdagger project updateon every runIn this case, even if your built-ins are being updated according to what's embeded in your binary, you may get something that's incompatible with your plan, or simply get unexpected (i.e., different) results.
BUT... if you pin the dagger binary version in CI, then I don't see an issue. I may be wrong, if someone else has something to add.
Remember that with external packages, I'm assuming you're pinning to a tag version as well, and not a branch. Otherwise it's the same considerations.
Another scenario
The dagger-for-github package needs to test against multiple dagger versions. In this case you need not to commit the vendor (
pkg) directory and needdagger project updateeach time because you have different binaries in your steps. This is a valid case.Conclusion
If you know what you're doing, got ahead. 🙂
Commands summary
I've just checked these commands and they need a bit of fixing and consistency improvements related to updating built-ins vs external.
dagger project updatecue.mod/pkgdagger project update -ucue.mod/dagger.mod) but looks like unreachable code now!dagger project update <repo1>@<version1> <repo2>@<version1>pkgand updatesdagger.{mod,sum}filesdagger project update -u <repo1>@<version2> <repo2>@<version2>mircubed commentedon May 6, 2022
Thanks for the write up @helderco! @jpadams do you feel like this is enough feedback to make a decision or do we need more opinions?
If not, I will turn this into an Epic issue (to easily track it) and create some subtasks for improvements to commands and docs.
helderco commentedon May 6, 2022
There’s already an epic that encompasses this:
TomChv commentedon Jul 12, 2022
@jpadams Since this issue is already cover in an epic, should we keep it open ?
yann-soubeyrand commentedon Aug 9, 2022
Hello, if this is not planned yet, could you please consider having a subcommand to vendor dependencies in the package management command? We appreciate having self-sufficient repositories containing all the dependencies 😉
helderco commentedon Aug 9, 2022
@yann-soubeyrand the dependencies are already vendored to
cue.mod/pkgwhen you rundagger project update, both built-in (core and universe) and external (from other git repos).This issue about which convention to adopt in our CI examples. Vendor + commit, or run
updateevery time.yann-soubeyrand commentedon Aug 9, 2022
Hi @helderco, I know that dependencies are vendored at the moment, I was refering to a sentence above which seems to indicate this could not be the case anymore in the future:
I think this is a good idea, but I’d like to keep the ability to vendor dependencies if one needs to, for various reasons (much like
go mod vendorallows to vendor go modules today).helderco commentedon Aug 9, 2022
@yann-soubeyrand at the moment that's on hold, but there would be a
dagger project vendorcommand to do that.