Skip to content

Commit f4eb908

Browse files
Fix generation and add check to CI (#12)
Signed-off-by: Stefan VanBuren <[email protected]>
1 parent a169a8f commit f4eb908

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ jobs:
8787
run: go test ./...
8888
working-directory: protoc-gen-connect-python
8989

90+
- name: check running `just generate` does not create a diff
91+
# NOTE: running on macOS as our sed command only works there
92+
if: startsWith(matrix.os, 'macos-')
93+
run: uv run just checkgenerate
94+
9095
- uses: codecov/codecov-action@v5
9196
if: ${{ matrix.coverage == 'cov' }}
9297

conformance/buf.gen.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ plugins:
99
- local:
1010
- go
1111
- run
12+
- -C
1213
- ../protoc-gen-connect-python
14+
- .
1315
out: test/gen
1416
opt:
1517
- imports=relative

example/buf.gen.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ plugins:
77
- local:
88
- go
99
- run
10+
- -C
1011
- ../protoc-gen-connect-python
12+
- .
1113
out: .

justfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,51 @@
1+
# https://just.systems/
2+
13
BUF_VERSION := "v1.57.0"
24

35
[private]
46
@default: check
57

8+
# Format Python files
69
format:
710
uv run ruff check --fix .
811
uv run ruff format .
912

13+
# Lint Python files
1014
lint:
1115
uv run ruff format --check .
1216
uv run ruff check .
1317

18+
# Typecheck Python files
1419
typecheck:
1520
uv run pyright
1621

22+
# Run unit tests with no extras
1723
[working-directory: 'noextras']
1824
test-noextras *args:
1925
uv run --exact pytest {{args}}
2026

27+
# Run unit tests
2128
test *args: (test-noextras args)
2229
uv run pytest {{args}}
2330

31+
# Run lint, typecheck and test
2432
check: lint typecheck test
2533

34+
# Run conformance tests
2635
[working-directory: 'conformance']
2736
conformance *args:
2837
uv run pytest {{args}}
2938

39+
# Build docs
3040
docs:
3141
uv run mkdocs build
3242

43+
# Serve the docs locally
3344
[working-directory: 'site']
3445
docs-serve: docs
3546
uv run python -m http.server 8000
3647

48+
# Generate conformance files
3749
[working-directory: 'conformance']
3850
generate-conformance:
3951
go run github.com/bufbuild/buf/cmd/buf@{{BUF_VERSION}} generate
@@ -42,12 +54,19 @@ generate-conformance:
4254
@# structure, we use sed to fix the imports instead.
4355
LC_ALL=c find test/gen -type f -exec sed -i '' 's/from connectrpc.conformance.v1/from gen.connectrpc.conformance.v1/' {} +
4456

57+
# Generate example files
4558
[working-directory: 'example']
4659
generate-example:
4760
go run github.com/bufbuild/buf/cmd/buf@{{BUF_VERSION}} generate
4861

62+
# Generate test files
4963
[working-directory: 'test']
5064
generate-test:
5165
go run github.com/bufbuild/buf/cmd/buf@{{BUF_VERSION}} generate
5266

67+
# Run all generation targets, and format the generated code
5368
generate: generate-conformance generate-example generate-test format
69+
70+
# Used in CI to verify that `just generate` doesn't produce a diff
71+
checkgenerate: generate
72+
test -z "$(git status --porcelain | tee /dev/stderr)"

test/buf.gen.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ plugins:
77
- local:
88
- go
99
- run
10+
- -C
1011
- ../protoc-gen-connect-python
12+
- .
1113
out: .
1214
opt:
1315
- imports=relative

0 commit comments

Comments
 (0)