Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
9 changes: 7 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ repos:
- id: markdown-link-check
exclude: ^(vendor)

- repo: https://github.com/golangci/golangci-lint
rev: v1.60.1
- repo: local
hooks:
- id: golangci-lint
name: golangci-lint
language: system
types: [go]
require_serial: true
pass_filenames: false
entry: etc/golangci-lint.sh
18 changes: 7 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,18 @@ doc:
fmt:
go fmt ./...

.PHONY: install-golangci-lint
install-golangci-lint:
go install github.com/golangci/golangci-lint/cmd/[email protected]

# Lint with various GOOS and GOARCH targets to catch static analysis failures that may only affect
# specific operating systems or architectures. For example, staticcheck will only check for 64-bit
# alignment of atomically accessed variables on 32-bit architectures (see
# https://staticcheck.io/docs/checks#SA1027)
.PHONY: lint
lint: install-golangci-lint
GOOS=linux GOARCH=386 golangci-lint run --config .golangci.yml ./...
GOOS=linux GOARCH=arm golangci-lint run --config .golangci.yml ./...
GOOS=linux GOARCH=arm64 golangci-lint run --config .golangci.yml ./...
GOOS=linux GOARCH=amd64 golangci-lint run --config .golangci.yml ./...
GOOS=linux GOARCH=ppc64le golangci-lint run --config .golangci.yml ./...
GOOS=linux GOARCH=s390x golangci-lint run --config .golangci.yml ./...
lint:
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=amd64 etc/golangci-lint.sh
GOOS=linux GOARCH=ppc64le etc/golangci-lint.sh
GOOS=linux GOARCH=s390x etc/golangci-lint.sh

.PHONY: update-notices
update-notices:
Expand Down
24 changes: 24 additions & 0 deletions etc/golangci-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -ex

# Keep this in sync with go version used in static-analysis Evergreen build variant.
GO_VERSION=1.22.8
GOLANGCI_LINT_VERSION=1.60.1

# Unset the cross-compiler overrides while downloading binaries.
GOOS_ORIG=${GOOS:-}
export GOOS=
GOARCH_ORIG=${GOARCH:-}
export GOARCH=

go install golang.org/dl/go$GO_VERSION@latest
go${GO_VERSION} download
GOROOT="$(go${GO_VERSION} env GOROOT)"
PATH="$GOROOT/bin:$PATH"
export PATH
export GOROOT
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v${GOLANGCI_LINT_VERSION}

export GOOS=$GOOS_ORIG
export GOARCH=$GOARCH_ORIG
golangci-lint run --config .golangci.yml ./...
Loading