-
Notifications
You must be signed in to change notification settings - Fork 674
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
[ci] Lint on non-test code importing packages from /tests #3214
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.
- Approving with one change requested
This is much cleaner. Thanks for the addition!
5d13a33
to
deae8a2
Compare
Rebased |
scripts/lint.sh
Outdated
IMPORT_FROM_TESTS=$( echo "${NON_TEST_GO_FILES}" | xargs grep -l '"github.com/ava-labs/tests/'); | ||
IMPORT_TEST_PKG=$( echo "${NON_TEST_GO_FILES}" | xargs grep -lP '"github.com/ava-labs/.*?test"'); | ||
IMPORT_FROM_TESTS=$( echo "${NON_TEST_GO_FILES}" | xargs grep -l '"github.com/ava-labs/avalanchego/tests/'); | ||
IMPORT_TEST_PKG=$( echo "${NON_TEST_GO_FILES}" | xargs grep -lP '"github.com/ava-labs/avalanchego/.*?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.
The closing double-quote was deliberate, to ensure that the package name ends in test
. This will now just allow anything with test
in the path to be ok.
Is that something we're ok with? I tend to err on the side of precision, but can see the benefit in opening it up like this.
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 we're in bikeshedding territory either way, so I'll revert the removal.
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.
Done
This avoids having to redundantly tag test code in `/tests` with `go:build test` or supply `--tags test` on every ginkgo invocation.
deae8a2
to
8532371
Compare
This avoids having to redundantly tag test code in
/tests
withgo:build test
or supply--tags test
on every ginkgo invocation.How was this tested
/tests
to non-test code and witnessing a failure:Non-test Go files importing test-only packages MUST have '//go:build test' tag: /home/me/src/avalanchego/master/main/main.go