diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4e8b50c..be372ed 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,7 +37,9 @@ jobs: with: go-version-file: go.mod cache: false # for this job we rely on golangci-lint-action's cache - - name: Lint + - name: Lint (other) + run: script/lint + - name: Lint (golangci-lint) uses: golangci/golangci-lint-action@v3 with: version: v1.52 diff --git a/script/lint b/script/lint index 42468b2..9e8c3c9 100755 --- a/script/lint +++ b/script/lint @@ -2,7 +2,18 @@ set -eu +: "${GITHUB_ACTIONS:=}" + cd "$(dirname "$0")" cd .. -exec go run github.com/golangci/golangci-lint/cmd/golangci-lint run +go generate ./... +if ! git diff --exit-code >/dev/null; then + echo "Error: generated code is not up-to-date! Run 'go generate ./...' and update your branch." >&2 + exit 1 +fi + +# On GitHub actions, this is run as a separate task +if [ "$GITHUB_ACTIONS" != "true" ]; then + exec go run github.com/golangci/golangci-lint/cmd/golangci-lint run +fi diff --git a/telemetry/tracestate.go b/telemetry/tracestate.go index 18359c4..3fb1d83 100644 --- a/telemetry/tracestate.go +++ b/telemetry/tracestate.go @@ -26,7 +26,7 @@ const ( // Don't forget to rerun `go generate ./...` if you add or remove values from // the DetailLevel or SampleMode enums. // -//go:generate stringer -type=DetailLevel,SampleMode -output=tracestate_string.go +//go:generate go run golang.org/x/tools/cmd/stringer -type=DetailLevel,SampleMode -output=tracestate_string.go type DetailLevel int type SampleMode int