Skip to content

Commit 209e6ed

Browse files
committed
Add a lint check for generated code
1 parent 1493293 commit 209e6ed

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ jobs:
3737
with:
3838
go-version-file: go.mod
3939
cache: false # for this job we rely on golangci-lint-action's cache
40-
- name: Lint
40+
- name: Lint (other)
41+
run: script/lint
42+
- name: Lint (golangci-lint)
4143
uses: golangci/golangci-lint-action@v3
4244
with:
4345
version: v1.52

script/lint

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22

33
set -eu
44

5+
: "${GITHUB_ACTIONS:=}"
6+
57
cd "$(dirname "$0")"
68
cd ..
79

8-
exec go run github.com/golangci/golangci-lint/cmd/golangci-lint run
10+
go generate ./...
11+
if ! git diff --exit-code >/dev/null; then
12+
echo "Error: generated code is not up-to-date! Run 'go generate ./...' and update your branch." >&2
13+
exit 1
14+
fi
15+
16+
# On GitHub actions, this is run as a separate task
17+
if [ "$GITHUB_ACTIONS" != "true" ]; then
18+
exec go run github.com/golangci/golangci-lint/cmd/golangci-lint run
19+
fi

telemetry/tracestate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const (
2626
// Don't forget to rerun `go generate ./...` if you add or remove values from
2727
// the DetailLevel or SampleMode enums.
2828
//
29-
//go:generate stringer -type=DetailLevel,SampleMode -output=tracestate_string.go
29+
//go:generate go run golang.org/x/tools/cmd/stringer -type=DetailLevel,SampleMode -output=tracestate_string.go
3030
type DetailLevel int
3131
type SampleMode int
3232

0 commit comments

Comments
 (0)