Skip to content

Add cli publish from main and tests against it. - #4208

Merged
gerhard merged 3 commits into
dagger:mainfrom
sipsma:cli-main
Dec 19, 2022
Merged

gerhard merged 3 commits into
dagger:mainfrom
sipsma:cli-main

Conversation

@sipsma

@sipsma sipsma commented Dec 16, 2022 •

Copy link
Copy Markdown
Contributor

Context: this adds the ability to test the default CLI provisioning codepaths in the SDKs. The change before this only had unit tests that used a local http server pretending to be s3, which is good for quick testing, but given how important this functionality is it's also crucial to be able to test the SDKs against the actual s3 bucket they will be downloading the CLI from. Part of #3830


Major changes:

  1. Each push to main now publishes the CLI to our s3 buckets (alongside the existing publish of engine image on main)
    • It pushes it to path dagger/main/<commit sha>/dagger_<commit sha>_<os>_<arch>.tar.gz. This matches the paths we use for official releases (just replaces tag w/ commit sha)
    • This required setting up the nightly feature in goreleaser, which in turn required splitting out the goreleaser config into separate files to avoid templating nightmares, which in turn required we use goreleaser-pro now
    • I'm not sure whether it's actually worth setting up lifecycle policies to clean this. S3 costs ~0.02 /GB/month. Rounding up a lot say each release is a total of 100MB, then say we eventually accumulate 10,000 pushes to main someday, that's still only about $22 a month.
  2. We now run provisioning tests for both macos and linux on these events:
    1. As part of the publish workflow (both for main and for tag pushes).
      • After the cli+engine publish job finishes, jobs for macos and linux start that run each of the SDKs against the cli+engine that just got published.
      • This requires the test case modify the CLI URL SDKs use to point to the just published URL. We use an env var _INTERNAL_DAGGER_TEST_CLI_URL, but importantly that env var is only interpreted by test code, not actual runtime code, so it's not usable by external users.
      • This gives us continuous coverage of provisioning on each platform. If there's a problem our main CI checks will fail
      • You'll notice that the GHA yaml for setting this up is pretty disgusting; ran into corner cases around dependent jobs (fortunately lots of people online complaining about it with workarounds, noted in comments of yaml) and into limitations around templating that eventually lead me to just fallback to using an inlined bash script instead of nesting ifs and other hacks in yaml directly.
    2. In the engine version bump PR.
      • In this case we just let the completely unaltered defaults run in the test cases, so the SDKs hit the same URL they will hit if released.
      • This gives us coverage of the exact codepaths users will follow in released SDKs. It also blocks SDKs from upgrading to a new engine until they are validated to be able to provision from it

Tested by setting up corresponding infra + secrets in my fork (s3 bucket, tokens, etc.) and going through releases there. Enormous PITA to setup but extremely valuable ultimately...

  • Push to main
  • Push of engine tag
  • Engine bump PR from tag push
    • Note that it's not possible for tests to pass in my fork because, as mentioned above, these tests run with all defaults, no overrides, so the SDKs try to download from dl.dagger.io even though my fork is pushing to a different s3 bucket
    • They all fail with the expected error messages at least though

Outstanding issues:

  1. Python tests fail on macos with disturbing errors about wheel incompatibility from a dependency when starting the SDK:
  2. I don't love the complexity of thinking about all the different scenarios of when each provision test runs and against which CLI served from where. But to an extent that's just inherent to what we're doing.
    • Open to suggestions on simplifications around this and anything else of course
    • Docs will be crucial here too. If feedback doesn't send the approach in this PR totally different directions I'll write those out more (maybe just more thorough comments, maybe some diagrams, I'll see what makes sense)

@sipsma
sipsma force-pushed the cli-main branch 2 times, most recently from e57652c to ff1fad9 Compare December 16, 2022 11:16
@helderco

helderco commented Dec 16, 2022 •

Copy link
Copy Markdown
Contributor

Quick feedback: please always link a PR to an issue, even if it's part of a larger one or a comment. Helps to quickly get more context.

So this is part of:

@helderco

Copy link
Copy Markdown
Contributor
  1. Python tests fail on macos with disturbing errors about wheel incompatibility

That's weird. Indeed I get this manually, but not sure why that one was selected by Poetry then:

$ pip install https://files.pythonhosted.org/packages/a6/84/5c3f3ffc4143fa7e208d745d2239d915e74d3709fdbc64c3e98d3fd27e56/black-22.10.0-1fixedarch-cp311-cp311-macosx_11_0_x86_64.whl
ERROR: black-22.10.0-1fixedarch-cp311-cp311-macosx_11_0_x86_64.whl is not a supported wheel on this platform.

I could hunt down the issue but black isn't actually needed for tests. I'm going to quickly update your PR to just install test dependencies.

@sipsma

sipsma commented Dec 16, 2022

Copy link
Copy Markdown
Contributor Author

Quick feedback: please always link a PR to an issue, even if it's part of a larger one or a comment. Helps to quickly get more context.

You're totally right, I forgot to include the wider context, I updated the description with that too now. Appreciate the reminder! 🙏

@sipsma

sipsma commented Dec 16, 2022

Copy link
Copy Markdown
Contributor Author

I could hunt down the issue but black isn't actually needed for tests. I'm going to quickly update your PR to just install test dependencies.

Thank you! Looks like it worked: https://github.com/sipsma/dagger/actions/runs/3715971093/jobs/6301916456

@helderco helderco left a comment

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.

LGTM!

Agree that publish.yml has quite a bit of duplication, but don't know how to make it better. Not familiar with GHA. This is one of the reasons why doing CI in dagger is so much better, but here we can't dogfood. 🙂

@slumbering slumbering left a comment

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.

LGTM

@gerhard gerhard left a comment •

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.

I know what a pain this is, but I'm glad that you went through the entire setup and have a replica where you can experiment safely. Having that is super valuable!

FWIW, RELEASE_FQDN is what I was using in GoReleaser Pro to change the publish URL. Here is a screenshot of all the secrets that I have set in my gerhard/dagger fork:

image

You can see all my past changes & the workflow that I used to check everything in #3486

Looking good, let's get this in and improve via follow-up PRs 👍 🚀

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants