Skip to content

Commit

Permalink
Add a lint check for generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
nickstenning committed Nov 16, 2023
1 parent 1493293 commit 209e6ed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 12 additions & 1 deletion script/lint
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion telemetry/tracestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 209e6ed

Please sign in to comment.