-
Notifications
You must be signed in to change notification settings - Fork 12
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 workspace modules with BP_GO_WORK_USE
#537
Use workspace modules with BP_GO_WORK_USE
#537
Conversation
7adf77c
to
93ba5fb
Compare
@robdimsdale @ForestEckhardt Unfortunately, I couldn't figure out how to run integration tests locally. Reverse engineering the |
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.
Hey there! This PR look great. My only call out is that I would like to see some unit test for the new functionality that you added. I would be more than happy to consult with you on adding those or back filling them and letting you take a look. Just let me know!
I shall happily add unit tests! Until then, would you be able to instruct me on how to run the integration locally? |
" Running 'go work init'", | ||
" Running 'go work use ./some/module1 ./some/module2'", | ||
fmt.Sprintf(` Running 'go build -o %s -buildmode pie -trimpath .'`, filepath.Join(layerPath, "bin")), | ||
" Completed in 0s", |
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.
🤔 It's consistently expecting 0s
while other tests want 1s
. I can't quite tell why.
It looks like all of the integration tests are failing at the moment. Could you take a look in that? |
Signed-off-by: Max Brauer <[email protected]>
57f4f6b
to
199a46e
Compare
Done. Finally I figured out how to run the integration tests for a builder locally with: ./scripts/integration.sh --builder paketobuildpacks/builder-jammy-buildpackless-tiny --token "$GIT_TOKEN" I understand that it runs across a matrix of Also, thanks to ForestEckhardt/freezer#10 I was able to figure out how to rescue myself from All that being said, ./scripts/unit.sh
./scripts/integration.sh --builder paketobuildpacks/builder-jammy-buildpackless-tiny --token "$GIT_TOKEN" passes for me. |
I think that this look great! |
Summary
When a submodule uses
replace
directives referring to modules within the same repository using a relative path, e.g.../../
, then the submodule cannot be built with paketo-buildpacks/go-build.With Go's workspaces it's possible to include a submodule in the set of main modules so such a submodule can be built.
By allowing users to set
BP_GO_WORK_USE
the buildpack will first rungo work init
followed bygo work use <modules...>
, before building withgo build <...>
.If this PR would be considered and ever get merged, I'd be happy to follow-up with a companion docs PR for https://paketo.io/docs/howto/go/.
Use Cases
I want to build cert-manager’s images w/ buildpacks. Unfortunately, but to the best of my knowledge, as of
>=1.12
vanilla checkouts (e.g. [email protected]) cannot be built with paketo-buildpacks/[email protected] for their use of relativereplace
directives. What I've tried:path=./cmd/controller
doesn’t work b/c then it can’t see../../
BP_GO_TARGET=./cmd/controller
doesn’t work because it’s not contained by the main moduleBP_GO_BUILD_FLAGS="-C ./cmd/controller"
doesn’t work b/c of a limitation (or by design) in paketo-buildpacks/go-build. (it doesn’t put-C
first, whichgo build
expects. fixing it probably doesn’t help, b/c the buildpack makes assumptions about the working dir. it’s complicated)(There’s a chance my research wasn’t exhaustive. Can you think of a way to build images off of vanilla cert-manager?)
However, with Go workspaces a vanilla check-out of cert-manager can be built. This is even documented by cert-manager.io/building/#go-workspaces. When the workspace
use
s./cmd/controller
it’s part of the main module and the buildpack succeeds. However,go.work
is not being checked in by upstream. Afaik it's not common to check ingo.work*
either. As a workaround I could augment every version of upstream I want to build withgo.work
, but that’s not ideal. I'd rather use build a vanilla checkout with buildpacks.After building this branch and building paketo-buildpacks/go with it, cert-manager's images built.
Checklist