From 7f3449af41b972aaf498e61a9480d4f145f5ba58 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sat, 21 Sep 2024 07:09:03 -0500 Subject: [PATCH 01/22] Add custom golint pre-commit check --- .evergreen/config.yml | 1 + .pre-commit-config.yaml | 15 +++++++++------ etc/golangci-lint.sh | 5 +++++ 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100755 etc/golangci-lint.sh diff --git a/.evergreen/config.yml b/.evergreen/config.yml index bf164f1a94..3528e9e561 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -2348,6 +2348,7 @@ buildvariants: run_on: - rhel8.7-small expansions: + # Keep this in sync with go version used in etc/golangci-lint.sh GO_DIST: "/opt/golang/go1.22" tasks: - name: ".static-analysis" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eb873a9e54..12c6d3aee9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,15 +50,18 @@ repos: - id: markdown-link-check exclude: ^(vendor) -- repo: https://github.com/golangci/golangci-lint - rev: v1.59.1 - hooks: - - id: golangci-lint - - repo: local hooks: - id: executable-shell name: executable-shell entry: chmod +x language: system - types: [shell] \ No newline at end of file + types: [shell] + + - id: golangci-lint + name: golangci-lint + language: system + types: [go] + require_serial: true + pass_filenames: false + entry: etc/golangci-lint.sh \ No newline at end of file diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh new file mode 100755 index 0000000000..d2b717ad3a --- /dev/null +++ b/etc/golangci-lint.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Keep this in sync with go version used in static-analysis Evergreen build variant. +go install golang.org/dl/go1.22.7@latest +go1.22.7 download 2> /dev/null +PATH="$(go1.22.7 env GOROOT)/bin:$PATH" golangci-lint run --config .golangci.yml ./... \ No newline at end of file From 7eb3bc72dc548ec3132e751d09f5885b0070aa20 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 07:49:53 -0500 Subject: [PATCH 02/22] use script --- Taskfile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index 484666c94a..a87226cb5e 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -60,7 +60,7 @@ tasks: cmds: - GOOS=linux GOARCH=386 etc/golangci-lint.sh - GOOS=linux GOARCH=arm etc/golangci-lint.sh - - GOOS=linux GOARCH=arm64 etc/golangci-lint.sh. + - GOOS=linux GOARCH=arm64 etc/golangci-lint.sh - GOOS=linux GOARCH=amd64 etc/golangci-lint.sh - GOOS=linux GOARCH=ppc64le etc/golangci-lint.sh - GOOS=linux GOARCH=s390x etc/golangci-lint.sh From 733bb75dadc51bf37fba00a7a4d3a709b3c05aea Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 09:24:31 -0500 Subject: [PATCH 03/22] fix script --- etc/golangci-lint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index 394288ef65..dfdf7c8b61 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -2,5 +2,6 @@ # Keep this in sync with go version used in static-analysis Evergreen build variant. go install golang.org/dl/go1.22.7@latest go1.22.7 download 2> /dev/null +export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 -PATH="$(go1.22.7 env GOROOT)/bin:$PATH" golangci-lint run --config .golangci.yml ./... \ No newline at end of file +golangci-lint run --config .golangci.yml ./... From ec71ae9306b6e3682d9ffd58cef96b869e9f8b2f Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 09:31:35 -0500 Subject: [PATCH 04/22] cleanup --- etc/golangci-lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index dfdf7c8b61..6a9090c056 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -2,6 +2,6 @@ # Keep this in sync with go version used in static-analysis Evergreen build variant. go install golang.org/dl/go1.22.7@latest go1.22.7 download 2> /dev/null -export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" +export PATH="$(go1.22.7 env GOROOT)/bin:$GOPATH/bin:$PATH" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 golangci-lint run --config .golangci.yml ./... From 22f7c9964744d5a384c7b82b8bed71bc146f068d Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 09:39:25 -0500 Subject: [PATCH 05/22] add go setup in GHA --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c4e5498fbf..a72ffa4ad9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,4 +18,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 + - uses: actions/setup-go@v5 + with: + go-version: 'stable' - uses: pre-commit/action@v3.0.1 From c27843ab6dea0bf654bceefaa107ad358250c9f3 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 10:03:21 -0500 Subject: [PATCH 06/22] fix path --- etc/golangci-lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index 6a9090c056..dfdf7c8b61 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -2,6 +2,6 @@ # Keep this in sync with go version used in static-analysis Evergreen build variant. go install golang.org/dl/go1.22.7@latest go1.22.7 download 2> /dev/null -export PATH="$(go1.22.7 env GOROOT)/bin:$GOPATH/bin:$PATH" +export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 golangci-lint run --config .golangci.yml ./... From c7d37adede8f4f471347634b3c2ae758c8e8c15c Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 11:37:18 -0500 Subject: [PATCH 07/22] debug --- etc/golangci-lint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index dfdf7c8b61..0ef6fdd3b9 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash # Keep this in sync with go version used in static-analysis Evergreen build variant. +set -ex go install golang.org/dl/go1.22.7@latest go1.22.7 download 2> /dev/null export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" From 52398d4baf64367fe5d7a9cbbc3c02e33db64380 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 11:47:37 -0500 Subject: [PATCH 08/22] debug --- .evergreen/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 3528e9e561..9c30016659 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -827,7 +827,8 @@ tasks: commands: - func: run-task vars: - targets: "check-fmt check-license check-modules lint" + # TODO: restore previous before merging + targets: "lint" - name: pull-request-helpers allowed_requesters: ["patch", "github_pr"] From fdcb2729d97fc0482a28a5a64d10fe538160c1ba Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 11:56:35 -0500 Subject: [PATCH 09/22] debug --- etc/golangci-lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index 0ef6fdd3b9..3c8071fb7a 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -2,7 +2,7 @@ # Keep this in sync with go version used in static-analysis Evergreen build variant. set -ex go install golang.org/dl/go1.22.7@latest -go1.22.7 download 2> /dev/null +go1.22.7 download export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 golangci-lint run --config .golangci.yml ./... From c6a0817827623836c672866e1637d436976e23fc Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 12:24:08 -0500 Subject: [PATCH 10/22] debug --- etc/golangci-lint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index 3c8071fb7a..675bac5563 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # Keep this in sync with go version used in static-analysis Evergreen build variant. set -ex +env go install golang.org/dl/go1.22.7@latest go1.22.7 download export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" From 7d47ab1acce901ab8651a761cc207225d948abd7 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 12:53:58 -0500 Subject: [PATCH 11/22] more debug --- etc/golangci-lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index 675bac5563..b81b7f80e6 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash # Keep this in sync with go version used in static-analysis Evergreen build variant. set -ex -env go install golang.org/dl/go1.22.7@latest +ls $GOPATH/bin go1.22.7 download export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 From 7d9c118de54d751a7edf1ea65d02c87a3bcdec85 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 14:43:00 -0500 Subject: [PATCH 12/22] more debug --- etc/golangci-lint.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index b81b7f80e6..8a31b5c9c3 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -1,8 +1,12 @@ #!/usr/bin/env bash # Keep this in sync with go version used in static-analysis Evergreen build variant. set -ex +ls $GOPATH/bin +ls $GOROOT go install golang.org/dl/go1.22.7@latest ls $GOPATH/bin +ls $GOPATH/bin/linux_386 +ls $GOROOT go1.22.7 download export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 From ddc7abfa2f45580461643704a491cccc39f427cf Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 14:50:35 -0500 Subject: [PATCH 13/22] more debug --- etc/golangci-lint.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index 8a31b5c9c3..c0a161e527 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash # Keep this in sync with go version used in static-analysis Evergreen build variant. set -ex -ls $GOPATH/bin -ls $GOROOT +# ls $GOPATH/bin +# ls $GOROOT go install golang.org/dl/go1.22.7@latest -ls $GOPATH/bin +# ls $GOPATH/bin ls $GOPATH/bin/linux_386 -ls $GOROOT +# ls $GOROOT go1.22.7 download export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 From 1a9346afba4e906789b5d4c61dc87619d93affb1 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 14:55:02 -0500 Subject: [PATCH 14/22] debug --- etc/golangci-lint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index c0a161e527..4c29d50dd4 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -5,6 +5,7 @@ set -ex # ls $GOROOT go install golang.org/dl/go1.22.7@latest # ls $GOPATH/bin +env ls $GOPATH/bin/linux_386 # ls $GOROOT go1.22.7 download From f77e77a7464a2160ef8c6d1d34c3afa35344e4e3 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 15:24:28 -0500 Subject: [PATCH 15/22] debug --- etc/golangci-lint.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index 4c29d50dd4..3596861fb5 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -1,13 +1,11 @@ #!/usr/bin/env bash # Keep this in sync with go version used in static-analysis Evergreen build variant. set -ex -# ls $GOPATH/bin -# ls $GOROOT go install golang.org/dl/go1.22.7@latest -# ls $GOPATH/bin -env -ls $GOPATH/bin/linux_386 -# ls $GOROOT +# Prepend the cross-platform path if necessary. +if [ -n "$GOOS" ]; then + export PATH="$GOPATH/bin/$GOOS_$GOGOARCH:$PATH" +fi go1.22.7 download export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 From deb039695fe80a158135a55775a30edb97732cb8 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 16:04:19 -0500 Subject: [PATCH 16/22] try again --- etc/golangci-lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index 3596861fb5..91db76bb1d 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -4,7 +4,7 @@ set -ex go install golang.org/dl/go1.22.7@latest # Prepend the cross-platform path if necessary. if [ -n "$GOOS" ]; then - export PATH="$GOPATH/bin/$GOOS_$GOGOARCH:$PATH" + export PATH="$GOPATH/bin/$GOOS_$GOGOARCH/bin:$PATH" fi go1.22.7 download export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" From e4820177f8294197e2f748f7a2bec0f608940e77 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 16:40:32 -0500 Subject: [PATCH 17/22] try again --- etc/golangci-lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index 91db76bb1d..c5d4424e43 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -4,7 +4,7 @@ set -ex go install golang.org/dl/go1.22.7@latest # Prepend the cross-platform path if necessary. if [ -n "$GOOS" ]; then - export PATH="$GOPATH/bin/$GOOS_$GOGOARCH/bin:$PATH" + export PATH="$GOPATH/bin/${GOOS}_${GOARCH}/bin:$PATH" fi go1.22.7 download export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" From 280e7e58c816110958c5c2127a2dd6082e0c5997 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 16:58:18 -0500 Subject: [PATCH 18/22] try again --- etc/golangci-lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index c5d4424e43..8fa62b5fc1 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -4,7 +4,7 @@ set -ex go install golang.org/dl/go1.22.7@latest # Prepend the cross-platform path if necessary. if [ -n "$GOOS" ]; then - export PATH="$GOPATH/bin/${GOOS}_${GOARCH}/bin:$PATH" + export PATH="$GOPATH/bin/${GOOS}_${GOARCH}:$PATH" fi go1.22.7 download export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" From d06d72f01d42c5b468c04a0e039fda14e22923e3 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 17:12:15 -0500 Subject: [PATCH 19/22] try again --- etc/golangci-lint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index 8fa62b5fc1..4e8117e2c0 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -6,6 +6,7 @@ go install golang.org/dl/go1.22.7@latest if [ -n "$GOOS" ]; then export PATH="$GOPATH/bin/${GOOS}_${GOARCH}:$PATH" fi +export GOROOT= go1.22.7 download export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 From 90d48aaf622d37a9076d68cc07340bdd045c589b Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 17:24:26 -0500 Subject: [PATCH 20/22] refactor --- etc/golangci-lint.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index 4e8117e2c0..361daf4088 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -1,13 +1,16 @@ #!/usr/bin/env bash # Keep this in sync with go version used in static-analysis Evergreen build variant. set -ex +GOOS_ORIG=${GOOS:-} +export GOOS= +GOARCH_ORIG=${GOARCH:-} +export GOARCH= + go install golang.org/dl/go1.22.7@latest -# Prepend the cross-platform path if necessary. -if [ -n "$GOOS" ]; then - export PATH="$GOPATH/bin/${GOOS}_${GOARCH}:$PATH" -fi -export GOROOT= go1.22.7 download export PATH="$(go1.22.7 env GOROOT)/bin:$PATH" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 + +export GOOS=$GOOS_ORIG +export GOARCH=$GOARCH_ORIG golangci-lint run --config .golangci.yml ./... From 549114378fceda6d0385bfeff116766185dad34d Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 17:30:38 -0500 Subject: [PATCH 21/22] undo change --- .evergreen/config.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 9c30016659..3528e9e561 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -827,8 +827,7 @@ tasks: commands: - func: run-task vars: - # TODO: restore previous before merging - targets: "lint" + targets: "check-fmt check-license check-modules lint" - name: pull-request-helpers allowed_requesters: ["patch", "github_pr"] From e54aa2a4c86f70e75dbd839c8f9a7c55048b3390 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Sep 2024 17:40:29 -0500 Subject: [PATCH 22/22] cleanup --- etc/golangci-lint.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh index 361daf4088..f7e6f5c20d 100755 --- a/etc/golangci-lint.sh +++ b/etc/golangci-lint.sh @@ -1,11 +1,13 @@ #!/usr/bin/env bash -# Keep this in sync with go version used in static-analysis Evergreen build variant. set -ex + +# Unset the cross-compiler overrides while downloading binaries. GOOS_ORIG=${GOOS:-} export GOOS= GOARCH_ORIG=${GOARCH:-} export GOARCH= +# Keep this in sync with go version used in static-analysis Evergreen build variant. go install golang.org/dl/go1.22.7@latest go1.22.7 download export PATH="$(go1.22.7 env GOROOT)/bin:$PATH"