Skip to content
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

chore: switch vetting from golint -> go vet #10235

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 3 additions & 38 deletions .github/workflows/vet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@ set -e
# Display commands being run
set -x

cd $CHANGED

# Fail if a dependency was added without the necessary go.mod/go.sum change
# being part of the commit.
go mod tidy
for i in $(find . -name go.mod); do
pushd $(dirname $i)
go mod tidy
popd
done

# Documentation for the :^ pathspec can be found at:
# https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec
Expand All @@ -44,39 +41,7 @@ goimports -l . 2>&1 | tee /dev/stderr | (! read)
#
# Note: since we added the linter after-the-fact, some of the ignored errors here are because we can't change an
# existing interface. (as opposed to us not caring about the error)
golint ./... 2>&1 | (
grep -vE "gen\.go" |
grep -vE "receiver name [a-zA-Z]+[0-9]* should be consistent with previous receiver name" |
grep -vE "exported const AllUsers|AllAuthenticatedUsers|RoleOwner|SSD|HDD|PRODUCTION|DEVELOPMENT should have comment" |
grep -v "exported func Value returns unexported type pretty.val, which can be annoying to use" |
grep -vE "exported func (Increment|FieldTransformIncrement|FieldTransformMinimum|FieldTransformMaximum) returns unexported type firestore.transform, which can be annoying to use" |
grep -v "ExecuteStreamingSql" |
grep -v "MethodExecuteSql should be MethodExecuteSQL" |
grep -vE " executeStreamingSql(Min|Rnd)Time" |
grep -vE " executeSql(Min|Rnd)Time" |
grep -vE "pubsub\/pstest\/fake\.go.+should have comment or be unexported" |
grep -vE "pubsub\/subscription\.go.+ type name will be used as pubsub.PubsubWrapper by other packages" |
grep -v "ClusterId" |
grep -v "InstanceId" |
grep -v "firestore.arrayUnion" |
grep -v "firestore.arrayRemove" |
grep -v "maxAttempts" |
grep -v "UptimeCheckIpIterator" |
grep -vE "apiv[0-9]+" |
grep -v "ALL_CAPS" |
grep -v "go-cloud-debug-agent" |
grep -v "mock_test" |
grep -v "internal/testutil/funcmock.go" |
grep -v "internal/backoff" |
grep -v "internal/trace" |
grep -v "internal/gapicgen/generator" |
grep -v "internal/generated/snippets" |
grep -v "a blank import should be only in a main or test package" |
grep -v "method ExecuteSql should be ExecuteSQL" |
grep -vE "spanner/spansql/(sql|types).go:.*should have comment" |
grep -vE "\.pb\.go:" |
grep -v "third_party/go/doc"
) |
go vet ./... 2>&1 |
tee /dev/stderr | (! read)

staticcheck -go 1.15 ./... 2>&1 | (
Expand Down
34 changes: 32 additions & 2 deletions .github/workflows/vet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,47 @@
contents: read # to fetch code (actions/checkout)

jobs:
scan_changes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
- uses: actions/setup-go@v5
with:
go-version: '1.22.x'
- name: Get changed directories
id: changed_dirs
run: |

Check failure on line 24 in .github/workflows/vet.yml

View workflow job for this annotation

GitHub Actions / lint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:4:20: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: .github/workflows/vet.yml:24:7: shellcheck reported issue in this script: SC2086:info:4:20: Double quote to prevent globbing and word splitting [shellcheck]

Check failure on line 24 in .github/workflows/vet.yml

View workflow job for this annotation

GitHub Actions / lint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:8:47: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: .github/workflows/vet.yml:24:7: shellcheck reported issue in this script: SC2086:info:8:47: Double quote to prevent globbing and word splitting [shellcheck]

Check failure on line 24 in .github/workflows/vet.yml

View workflow job for this annotation

GitHub Actions / lint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:9:19: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: .github/workflows/vet.yml:24:7: shellcheck reported issue in this script: SC2086:info:9:19: Double quote to prevent globbing and word splitting [shellcheck]
dirs=$(go run ./internal/actions/cmd/changefinder -q)
if [ -z "$dirs" ]
then
echo "skip=1" >> $GITHUB_OUTPUT
echo "No changes worth diffing!"
else
for d in $dirs; do list=${list},\"${d}\"; done
echo "changed={\"changed\":[${list#,}]}" >> $GITHUB_OUTPUT
echo "skip=" >> $GITHUB_OUTPUT
fi
outputs:
changed_dirs: ${{ steps.changed_dirs.outputs.changed }}
skip: ${{ steps.changed_dirs.outputs.skip }}
vet:
needs: scan_changes
runs-on: ubuntu-latest
if: ${{ !needs.scan_changes.outputs.skip }}
strategy:
matrix: ${{ fromJson(needs.scan_changes.outputs.changed_dirs) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
- name: Install tools
run: |
go install golang.org/x/lint/golint@latest && \
go install golang.org/x/tools/cmd/goimports@latest && \
go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Execute vet.sh
run: ./.github/workflows/vet.sh
run: |
export CHANGED=${{ matrix.changed }}
./.github/workflows/vet.sh