Merge pull request #2565 from kolyshkin/lint-tests

Add golangci-lint run --tests=false, fix found issues
This commit is contained in:
Miloslav Trmač 2025-04-14 13:50:12 +02:00 committed by GitHub
commit 44877b3af2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 8 additions and 18 deletions

View File

@ -237,7 +237,11 @@ test-all-local: validate-local validate-docs test-unit-local
validate-local:
hack/validate-git-marks.sh
hack/validate-gofmt.sh
GOBIN=$(GOBIN) hack/validate-lint.sh
$(GOBIN)/golangci-lint run --build-tags "${BUILDTAGS}"
# An extra run with --tests=false allows detecting code unused outside of tests;
# ideally the linter should be able to find this automatically.
# Since everything is already cached, this additional run doesn't take much time.
$(GOBIN)/golangci-lint run --build-tags "${BUILDTAGS}" --tests=false
BUILDTAGS="${BUILDTAGS}" hack/validate-vet.sh
# This invokes bin/skopeo, hence cannot be run as part of validate-local

View File

@ -1,16 +0,0 @@
#!/bin/bash
errors=$($GOBIN/golangci-lint run --build-tags "${BUILDTAGS}" 2>&1)
if [ "$?" -eq 0 ]; then
echo 'Congratulations! All Go source files have been linted.'
else
{
echo "Errors from golangci-lint:"
echo "$errors"
echo
echo 'Please fix the above errors. You can test via "golangci-lint" and commit the result.'
echo
} >&2
exit 1
fi

View File

@ -1,4 +1,4 @@
//go:build !linux
//go:build unix && !linux
package main

View File

@ -1,3 +1,5 @@
//go:build unix
package main
import (