Extract test.go files from published packages #16011
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
We have a lot of dependencies brought in by codegen due to some files named
test.go
. These are included in published packages and compiled artifacts because Go only excludes files ending with_test.go
from downstream dependencies.AFAICT these files are intended for test helpers, but they bloat our consumers by pulling in things like AWS and Azure SDKs. These dependencies then make their way into bridged providers via tfgen's codegen imports:
This PR re-arranges
GenerateProgramBatchTest
logic to consolidate everything underpkg/codegen/testing/test
instead of the language-specific codegen packages. By doing so we no longer include test dependencies in non-test packages that are consumed downstream.As an example, this takes the
pulumi-language-go
binary from ~61MB down to ~36MB, and speeds up build times:This doesn't completely remove these dependencies from downstream because most also include
pkg/v3/testing/integration
in tests. It does only compile these dependencies into the test binary, though.Before:
After:
NB: This is on top of v3.113.0 because v3.113.3 introduced some API changes to codegen which haven't been picked up by the bridge yet.
The awsx tests are failing with
make: *** No rule to make target 'upstream'.
and I'm not sure what to do with that.Checklist
make tidy
to update any new dependenciesmake lint
to verify my code passes the lint checkgofumpt
make changelog
and committed thechangelog/pending/<file>
documenting my change