-
-
Notifications
You must be signed in to change notification settings - Fork 911
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
Use dagger for build and test pipeline #4186
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know enough about dagger (its on my to study list, appreciate if you have any good material to point me to), but besides a couple of comments, looks good to me.
the lint issues can be solved by running gofumpt
go.mod
Outdated
// DO NOT UPDATE THIS!! needs to be v0.0.0-20210512092938-c05353c2d58c | ||
require github.com/ProtonMail/go-crypto v0.0.0-20230626094100-7e9e0395ebec // indirect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can ignore the // DO NOT UPDATE
thing, its outdated...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS: I'll fix this on main later to not conflict with this pr :)
ci/main.go
Outdated
|
||
builder = builder.WithExec([]string{"go", "mod", "tidy"}). | ||
WithExec([]string{"go", "build"}). | ||
WithExec([]string{"go", "test", "./..."}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the original pipeline, this would call ./script/test.sh
, which also appends to $GITHUB_STEP_SUMMARY
... not sure if that's possible with dagger too..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that should be possible, I'll try it out
Taskfile.yml
Outdated
env: | ||
LC_ALL: C | ||
vars: | ||
TEST_OPTIONS: '{{default "" .TEST_OPTIONS}}' | ||
SOURCE_FILES: '{{default "./..." .SOURCE_FILES}}' | ||
TEST_PATTERN: '{{default "." .TEST_PATTERN}}' | ||
cmds: | ||
- go test {{.TEST_OPTIONS}} -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt {{.SOURCE_FILES}} -run {{.TEST_PATTERN}} -timeout=5m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave this as is, maybe add a ci
task, that calls go run ./ci
go.mod
Outdated
@@ -4,6 +4,7 @@ go 1.20 | |||
|
|||
require ( | |||
code.gitea.io/sdk/gitea v0.15.1 | |||
dagger.io/dagger v0.7.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make ./ci
its own module? so whoever go install
goreleaser don't need to download dagger and all this other deps too...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good call
Thank you for reviewing this @caarlos0! We gave you a shout-out in today's Dagger Community Call (https://dagger.io/events fwiw). Recording will be uploaded to YouTube in a day (or a few at most). Will drop a link when it's public. cc @jpadams @mircubed @d3rp3tt3 Thank you @marcosnils for helping kick this off 💪 |
ci/builder.go
Outdated
WithExec([]string{"chown", "-R", "nonroot", "/src"}). | ||
WithNewFile("/usr/local/sbin/docker", dagger.ContainerWithNewFileOpts{ | ||
Contents: `#!/bin/sh | ||
DOCKER_HOST=tcp://localhost:2375 /usr/bin/docker $@`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kpenfound given that @caarlos0 seems to be quite responsive to merge this maybe we can take the opportunity to make this change in goreleaser so this hack is not necessary?
@caarlos0 FWIW we had to do this beacuse goreleaser
tests seem to overriding env variables when calling docker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Originally this code ran outside of the goreleaser repo so it was running the tests without modifications. A few workarounds were necessary to accommodate that. In this case, there's a few tests where localhost
is hardcoded and overriding any DOCKER_HOST
env
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, totally, feel free to make the necessary changes! <3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@caarlos0 basically goreleaser
tests are overriding go test
envs since they're being set here https://github.com/goreleaser/goreleaser/blob/7c6201f5f588fa1a8504f5cffa6264646fdee1eb/internal/pipe/docker/docker_test.go#LL992C17-L992C17 and then used here
goreleaser/internal/pipe/docker/api.go
Line 51 in 7c6201f
cmd.Env = ctx.Env.Strings() |
The change that would help us to remove this hack is if goreleaser
appended ctx.Env
envs to the current existing variables here
goreleaser/internal/pipe/docker/api.go
Line 51 in 7c6201f
cmd.Env = ctx.Env.Strings() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's probably the right thing to do, and what most people would expect to happen.
Honestly kinda surprised no one reported that as a bug yet 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's probably the right thing to do, and what most people would expect to happen.
Honestly kinda surprised no one reported that as a bug yet thinking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merged!
This is causing issues when trying to run tests in Dagger. ref: goreleaser#4186 (comment) Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
This is causing issues when trying to run tests in Dagger. ref: #4186 (comment) Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com> Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
Thanks again @caarlos0 ! You can check out the recording for the shout out here (13:20 timestamp) :) https://www.youtube.com/watch?v=dRfcSIIAvG4 |
Pretty cool! Thanks for the mention and the PR 💜 |
one Q about this: can we automate updates, like we do with dependabot? if not, is there any plans to do so? |
hey, thanks for all the effort on this, but I think I'll leave it as-is for now. |
:(
sent from mobile
Em dom., 14 de jan. de 2024 15:38, Carlos Alexandro Becker <
***@***.***> escreveu:
… Closed #4186 <#4186>.
—
Reply to this email directly, view it on GitHub
<#4186 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMBLWQA4FLOVKEKGZINNNLYOQQ3VAVCNFSM6AAAAAA2JDDME6VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJRGQ4DCOJQGU4DKMA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
sounds good @caarlos0 ! Maybe we can take another run at this with a future version of Dagger :) |
This PR changes the test CI workflow to use a dagger pipeline. The net result is that dependencies required to run the full test suite locally are reduced to just Go and Docker. Runtimes locally should be significantly reduced because of Dagger's caching abilities, and the same can be applied in CI with some infrastructure changes.
This work was previously seen in a demo of this from equinix demo day
TODO: