Skip to content

Commit 851c11c

Browse files
committed
fix: pdp bits and add a CI rule
1 parent 6b286cf commit 851c11c

3 files changed

Lines changed: 50 additions & 5 deletions

File tree

.github/workflows/codegen.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Codegen
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: ["main"]
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
codegen:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-go@v5
22+
with:
23+
go-version-file: go.mod
24+
# Compile the generators under the `codegen` build tag. The reusable
25+
# go-check/go-test workflows build without this tag, so a generator that
26+
# no longer compiles would otherwise slip through CI.
27+
- run: make codegen-build
28+
# Run `go generate` and fail if the committed generated files are stale.
29+
- run: make gen-check

Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: gen build test
1+
.PHONY: gen build test codegen-build gen-check ci
22

33
gen:
44
go generate ./...
@@ -8,3 +8,19 @@ build:
88

99
test:
1010
go test ./...
11+
12+
# Compile the code generators under the `codegen` build tag they actually run
13+
# with. A normal `go build ./...` never sets this tag, so a generator that no
14+
# longer compiles (e.g. it references a renamed or removed type) would otherwise
15+
# go unnoticed until someone runs `go generate`.
16+
codegen-build:
17+
go build -tags codegen $(shell go list ./... | grep '/gen$$')
18+
19+
# Regenerate everything and fail if the committed output changed, catching both
20+
# generators that no longer compile and generated files that are out of date.
21+
gen-check: gen
22+
@git diff --exit-code -- '*_gen.go' '*_gen.*.go' || \
23+
{ echo "generated files are out of date; run 'make gen' and commit the result" >&2; exit 1; }
24+
25+
# Aggregate target suitable for CI.
26+
ci: build codegen-build gen-check test

commands/pdp/sign/sign.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ type (
1616
)
1717

1818
var (
19-
DataSetCreate = commands.MustParse[*DataSetCreateArguments, *DataSetCreateOK]("/pdp/sign/dataset/create")
20-
DataSetDelete = commands.MustParse[*DataSetDeleteArguments, *DataSetDeleteOK]("/pdp/sign/dataset/delete")
21-
PiecesAdd = commands.MustParse[*PiecesAddArguments, *PiecesAddOK]("/pdp/sign/pieces/add")
22-
PiecesRemoveSchedule = commands.MustParse[*PiecesRemoveScheduleArguments, *PiecesRemoveScheduleOK]("/pdp/sign/pieces/remove/schedule")
19+
DataSetCreate = commands.MustParse[*DataSetCreateArguments]("/pdp/sign/dataset/create")
20+
DataSetDelete = commands.MustParse[*DataSetDeleteArguments]("/pdp/sign/dataset/delete")
21+
PiecesAdd = commands.MustParse[*PiecesAddArguments]("/pdp/sign/pieces/add")
22+
PiecesRemoveSchedule = commands.MustParse[*PiecesRemoveScheduleArguments]("/pdp/sign/pieces/remove/schedule")
2323
)

0 commit comments

Comments
 (0)