Skip to content

Add dagger project update to all CI examples #2315

Closed

Description

@jpadams

Should we always suggest dagger project update to be run before dagger do xxxx in our CI examples like GitHub Actions or Jenkins?

Activity

  1. self-assigned this
    on Apr 26, 2022
  2. helderco commented on May 6, 2022

    @helderco
    Contributor

    The simplest answer

    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], additional dagger.mod and dagger.sum files get created:

    -- cue.mod/dagger.mod
    example.com/docker/compose v0.3.5
    
    -- cue.mod/dagger.sum
    example.com/docker/compose h1:HZS38yXTuteMrwhMZZQTprfFRPDZP70K8rbMFxdIQdY=
    

    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:

    1. You're not pinning the dagger binary version in CI
    2. You've not commited pkg to git
    3. 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!
    • dagger project update <repo1>@<version1> <repo2>@<version1>
      • Installs specified external packages into pkg and updates dagger.{mod,sum} files
    • dagger project update -u <repo1>@<version2> <repo2>@<version2>
      • Updates specified external packages to latest versions if applicable
  3. mircubed commented on May 6, 2022

    @mircubed
    Contributor

    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.

  4. helderco commented on May 6, 2022

    @helderco
    Contributor

    There’s already an epic that encompasses this:

  5. TomChv commented on Jul 12, 2022

    @TomChv
    Member

    @jpadams Since this issue is already cover in an epic, should we keep it open ?

  6. yann-soubeyrand commented on Aug 9, 2022

    @yann-soubeyrand
    Contributor

    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 😉

  7. helderco commented on Aug 9, 2022

    @helderco
    Contributor

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

  8. yann-soubeyrand commented on Aug 9, 2022

    @yann-soubeyrand
    Contributor

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

  9. helderco commented on Aug 9, 2022

    @helderco
    Contributor

    @yann-soubeyrand at the moment that's on hold, but there would be a dagger project vendor command to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions