diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 749b596..f1907eb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -87,6 +87,11 @@ jobs: run: go test ./... working-directory: protoc-gen-connect-python + - name: check running `just generate` does not create a diff + # NOTE: running on macOS as our sed command only works there + if: startsWith(matrix.os, 'macos-') + run: uv run just checkgenerate + - uses: codecov/codecov-action@v5 if: ${{ matrix.coverage == 'cov' }} diff --git a/conformance/buf.gen.yaml b/conformance/buf.gen.yaml index f68e2eb..ac37db9 100644 --- a/conformance/buf.gen.yaml +++ b/conformance/buf.gen.yaml @@ -9,7 +9,9 @@ plugins: - local: - go - run + - -C - ../protoc-gen-connect-python + - . out: test/gen opt: - imports=relative diff --git a/example/buf.gen.yaml b/example/buf.gen.yaml index ba9fa2e..8d1e4fb 100644 --- a/example/buf.gen.yaml +++ b/example/buf.gen.yaml @@ -7,5 +7,7 @@ plugins: - local: - go - run + - -C - ../protoc-gen-connect-python + - . out: . diff --git a/justfile b/justfile index 352d76c..a13f963 100644 --- a/justfile +++ b/justfile @@ -1,39 +1,51 @@ +# https://just.systems/ + BUF_VERSION := "v1.57.0" [private] @default: check +# Format Python files format: uv run ruff check --fix . uv run ruff format . +# Lint Python files lint: uv run ruff format --check . uv run ruff check . +# Typecheck Python files typecheck: uv run pyright +# Run unit tests with no extras [working-directory: 'noextras'] test-noextras *args: uv run --exact pytest {{args}} +# Run unit tests test *args: (test-noextras args) uv run pytest {{args}} +# Run lint, typecheck and test check: lint typecheck test +# Run conformance tests [working-directory: 'conformance'] conformance *args: uv run pytest {{args}} +# Build docs docs: uv run mkdocs build +# Serve the docs locally [working-directory: 'site'] docs-serve: docs uv run python -m http.server 8000 +# Generate conformance files [working-directory: 'conformance'] generate-conformance: go run github.com/bufbuild/buf/cmd/buf@{{BUF_VERSION}} generate @@ -42,12 +54,19 @@ generate-conformance: @# structure, we use sed to fix the imports instead. LC_ALL=c find test/gen -type f -exec sed -i '' 's/from connectrpc.conformance.v1/from gen.connectrpc.conformance.v1/' {} + +# Generate example files [working-directory: 'example'] generate-example: go run github.com/bufbuild/buf/cmd/buf@{{BUF_VERSION}} generate +# Generate test files [working-directory: 'test'] generate-test: go run github.com/bufbuild/buf/cmd/buf@{{BUF_VERSION}} generate +# Run all generation targets, and format the generated code generate: generate-conformance generate-example generate-test format + +# Used in CI to verify that `just generate` doesn't produce a diff +checkgenerate: generate + test -z "$(git status --porcelain | tee /dev/stderr)" diff --git a/test/buf.gen.yaml b/test/buf.gen.yaml index 6c23e84..d9c826c 100644 --- a/test/buf.gen.yaml +++ b/test/buf.gen.yaml @@ -7,7 +7,9 @@ plugins: - local: - go - run + - -C - ../protoc-gen-connect-python + - . out: . opt: - imports=relative