Skip to content
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

feat(Earthfile): Add checksums and tarballs for crank #5779

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tampakrap
Copy link
Contributor

@tampakrap tampakrap commented Jun 4, 2024

Description of your changes

I have:

  • Read and followed Crossplane's contribution process.
  • Run earthly +reviewable to ensure this PR is ready for review.
  • Added or updated unit tests.
  • Added or updated e2e tests.
  • Linked a PR or a docs tracking issue to document this change.
  • Added backport release-x.y labels to auto-backport this PR.

Need help with this checklist? See the cheat sheet.

@tampakrap tampakrap requested a review from a team as a code owner June 4, 2024 23:26
@tampakrap tampakrap requested a review from phisco June 4, 2024 23:26
Copy link
Member

@jbw976 jbw976 left a comment

Choose a reason for hiding this comment

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

This looks like a reasonable approach with reasonable commands @tampakrap!

I tried taking this for a local test spin to verify it works and what the resulting output artifacts look like. The earthly +build works OK for me, I get no errors.

However, I don't see the output files in the _output directory. All I see written there is the _output/charts/ dir. To be clear, this looks to be an issue from before your PR as I don't see any of the crank/crossplane binaries there either:

❯ tree _output
_output
└── charts
    └── crossplane-0.0.0-1717543403-806ce6f8.tgz

1 directory, 1 file

Do you have any insight into where these _output files are getting written to? I tried poking around the earthly build container and I couldn't find an easily understandable path for them there either, just various paths under ./tmp/earthly/buildkit/runc-overlayfs/snapshots/snapshots, which look transient in nature. Is there a consistent/final location where all these _output files are expected to be written to? I'd love to find those so I can test these changes further.

Related, but out of scope of this PR: I'd also like to understand how best to support the common scenario from the past of building the crossplane CLI crank binary and running it locally - hard to do that now without the files being written to the _output dir of the host file system 😇

SAVE ARTIFACT crank AS LOCAL _output/bin/${GOOS}_${GOARCH}/crank
SAVE ARTIFACT crank.sha256 AS LOCAL _output/bin/${GOOS}_${GOARCH}/crank.sha256
SAVE ARTIFACT crank.tar.gz AS LOCAL _output/bundle/${GOOS}_${GOARCH}/crank.tar.gz
Copy link
Member

Choose a reason for hiding this comment

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

is there particular "standard" guidance that helped you land on bundle as the name of this dir? curious to see if there's an already defined practice we're following :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think there is any standard naming applied here, and I don't really have a preference on how to name the dir. I chose bundle because this is what up uses 😉 https://cli.upbound.io/stable/v0.30.0/bundle

@jbw976
Copy link
Member

jbw976 commented Jun 6, 2024

ah, I notice that the binary files are saved to _output with earthly +multiplatform-build and earthly +go-build, but not with earthly +build. That behavior is a bit surprising - I'll add that to the list of feedback in #5750 and we can move forward with this PR 🤓

@tampakrap
Copy link
Contributor Author

ah, I notice that the binary files are saved to _output with earthly +multiplatform-build and earthly +go-build, but not with earthly +build. That behavior is a bit surprising - I'll add that to the list of feedback in #5750 and we can move forward with this PR 🤓

correct, thanks for the reminder, I also noticed it and forgot to send the PR, I'm submitting it now

@tampakrap
Copy link
Contributor Author

ah, I notice that the binary files are saved to _output with earthly +multiplatform-build and earthly +go-build, but not with earthly +build. That behavior is a bit surprising - I'll add that to the list of feedback in #5750 and we can move forward with this PR 🤓

correct, thanks for the reminder, I also noticed it and forgot to send the PR, I'm submitting it now

#5782

@jbw976
Copy link
Member

jbw976 commented Jun 10, 2024

With #5782 now merged, @tampakrap do you want to fetch/rebase on later in master, then we can review testing and reviewing this PR? 🙏

@tampakrap
Copy link
Contributor Author

With #5782 now merged, @tampakrap do you want to fetch/rebase on later in master, then we can review testing and reviewing this PR? 🙏

let's finish with #5781 first because it collides with this one

@jbw976
Copy link
Member

jbw976 commented Jun 12, 2024

sweet, #5781 is merged now too - want to rebase this one and we'll start testing/reviewing? 💪

- The checksums will help people to verify that their downloaded binary
  is not corrupted
- The tarballs provide faster downloads. This is beneficial when
  downloading crank often, for example in CI jobs.
- The tarballs and checksums can be useful for creating distro and brew
  packages, see crossplane#4899

Signed-off-by: Theo Chatzimichos <[email protected]>
@tampakrap tampakrap force-pushed the earthfile_checksums_tarballs branch from 806ce6f to 9fbdb7e Compare June 12, 2024 08:34
@tampakrap
Copy link
Contributor Author

rebased

Copy link
Member

@jbw976 jbw976 left a comment

Choose a reason for hiding this comment

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

After reviewing and testing this functionality, these changes look good to me @tampakrap! See some testing notes below.

The only question I still have, which isn't strictly related to this PR, is that I'm not seeing the binaries, checksums, and tarballs published to https://releases.crossplane.io/build/merge/. I wanted to validate that these new checksum/tarball artifacts were being published alongside the existing artifacts, and I expected them to be from the conversation with @negz in https://github.com/crossplane/crossplane/pull/5765/files#r1621518143 that declared:

PRs should be uploaded to https://releases.crossplane.io/build/merge...

So not blocking, because I think publishing to releases.crossplane.io isn't happening for any PRs right now, but something to think about.

Testing information for this PR:

After building for local Mac M1 with earthly +build and for Windows with earthly --platform=windows/amd64 +go-build, I see all the expected binaries, checksums, and tarballs:

❯ tree _output
_output
├── bin
│   ├── darwin_arm64
│   │   ├── crank
│   │   ├── crank.sha256
│   │   ├── crossplane
│   │   └── crossplane.sha256
│   └── windows_amd64
│       ├── crank.exe
│       ├── crank.exe.sha256
│       ├── crossplane.exe
│       └── crossplane.exe.sha256
├── bundle
│   ├── darwin_arm64
│   │   ├── crank.tar.gz
│   │   └── crank.tar.gz.sha256
│   └── windows_amd64
│       ├── crank.tar.gz
│       └── crank.tar.gz.sha256
└── charts
    └── crossplane-0.0.0-1718181266-9fbdb7e5.tgz

The sha256 files look to be correct and verifiable with something like:

❯ echo "$(cat crank.sha256) crank" | sha256sum --check
crank: OK

The tarballs appear to have the correct content, e.g. crank and its sha256 file:

_output/bundle/darwin_arm64
❯ ll
total 68664
drwxr-xr-x@ 4 jared  staff   128B Jun 12 17:50 .
drwxr-xr-x@ 5 jared  staff   160B Jun 13 17:37 ..
-rw-r--r--@ 1 jared  staff    34M Apr 16  2020 crank.tar.gz
-rw-r--r--@ 1 jared  staff    64B Apr 16  2020 crank.tar.gz.sha256
_output/bundle/darwin_arm64 
❯ tar -xzf crank.tar.gz
_output/bundle/darwin_arm64
❯ ll
total 229432
drwxr-xr-x@ 6 jared  staff   192B Jun 13 17:37 .
drwxr-xr-x@ 5 jared  staff   160B Jun 13 17:37 ..
-rwxr-xr-x@ 1 jared  staff    78M Jun 12 17:50 crank
-rw-r--r--@ 1 jared  staff    64B Jun 12 17:50 crank.sha256
-rw-r--r--@ 1 jared  staff    34M Apr 16  2020 crank.tar.gz
-rw-r--r--@ 1 jared  staff    64B Apr 16  2020 crank.tar.gz.sha256

@jbw976
Copy link
Member

jbw976 commented Jun 14, 2024

I think publishing to releases.crossplane.io isn't happening for any PRs right now,

aha, @negz explained this to me offline. The publishing step won't run unless the AWS_USR secret is present as shown in https://github.com/crossplane/crossplane/blob/master/.github/workflows/ci.yml#L339. That value is an organization level secret, which will not be "passed to the runner when a workflow is triggered from a forked repository", as per the github docs.

So it is expected on this PR that publishing binaries won't run. Given that the publishing step just uploads all of _output as shown in https://github.com/crossplane/crossplane/blob/master/Earthfile#L409, so there is no new logic to add to ensure that the new artifacts are included, I'm good to merge this PR now. Thanks @tampakrap! 🙇‍♂️

@tampakrap
Copy link
Contributor Author

Apart from the functionality though, I would like an opinion on the naming and the structure. Are we fine keeping the dir name as bundle? Are we fine putting it in the _output topdir or do we want to have it for example inside bin? I don't really have any strong opinion on any of the two, I'm open to suggestions.

@jbw976
Copy link
Member

jbw976 commented Jun 15, 2024

The current layout and naming is fine for me @tampakrap! ✅

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.

None yet

2 participants