Don't allow testsignal to pick up non-stdlib dependencies - #1343
Merged
Conversation
Contributor
Author
|
Lint currently failing due to #1342 not being merged yet. |
brandur
force-pushed
the
brandur-no-non-stdlib-deps
branch
from
August 6, 2026 06:18
a2c522a to
fdc7371
Compare
This one's aimed at producing a more permanent structural fix for #1342 by keeping an eye out for the same problematic condition using the depguard lint. As a summary of the problem corrected by #1342: * We use the `testsignal` package in all kinds of non-test code, so packages including River always build against it. * `testsignal` was importing `riversharedtest`, which imports Testify, Goleak, YAML (through Testify). * This was causing all packages built against River to pick up an extra ~10 kB worth of dependencies in their production builds, which is bad. Here, add some new rules for depguard: * Don't allow test packages like Goleak or Testify to be imported by any non-test Go files. We make an exception for internal test support packages like `riverdbtest` and `riverdrivertest`. * Don't allow `testsignal` to have any dependencies beyond stdlib and `testutil`. * Don't allow `testutil` to have any non-stdlib dependencies. This rule is so that `testsignal` doesn't pick up unexpected dependencies transitively through `testutil`.
brandur
force-pushed
the
brandur-no-non-stdlib-deps
branch
from
August 6, 2026 06:48
fdc7371 to
52a3ba5
Compare
bgentry
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This one's aimed at producing a more permanent structural fix for #1342
by keeping an eye out for the same problematic condition using the
depguard lint. As a summary of the problem corrected by #1342:
We use the
testsignalpackage in all kinds of non-test code, sopackages including River always build against it.
testsignalwas importingriversharedtest, which imports Testify,Goleak, YAML (through Testify).
This was causing all packages built against River to pick up an extra
~10 kB worth of dependencies in their production builds, which is bad.
Here, add some new rules for depguard:
Don't allow test packages like Goleak or Testify to be imported by any
non-test Go files. We make an exception for internal test support
packages like
riverdbtestandriverdrivertest.Don't allow
testsignalto have any dependencies beyond stdlib andtestutil.Don't allow
testutilto have any non-stdlib dependencies. This ruleis so that
testsignaldoesn't pick up unexpected dependenciestransitively through
testutil.