diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 659bcb6..69593c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,13 +28,10 @@ jobs: run: uv sync --locked - name: Compile test files - working-directory: ./betterproto2_compiler - shell: bash - run: uv run poe generate + run: uv run poe generate-plugin - name: Execute test suite - working-directory: ./betterproto2 - run: uv run poe test + run: uv run poe test-lib - name: Add Pydantic @@ -42,8 +39,7 @@ jobs: run: uv sync --locked --extra=pydantic - name: Execute test suite - working-directory: ./betterproto2 - run: uv run poe test + run: uv run poe test-lib - name: Add all but Pydantic @@ -51,8 +47,7 @@ jobs: run: uv sync --locked --extra=grpclib --extra=grpcio --extra=protobuf - name: Execute test suite - working-directory: ./betterproto2 - run: uv run poe test + run: uv run poe test-lib - name: Add grpclib @@ -60,8 +55,7 @@ jobs: run: uv sync --locked --extra=grpclib - name: Execute test suite - working-directory: ./betterproto2 - run: uv run poe test + run: uv run poe test-lib - name: Add all but grpclib @@ -69,8 +63,7 @@ jobs: run: uv sync --locked --extra=pydantic --extra=grpcio --extra=protobuf - name: Execute test suite - working-directory: ./betterproto2 - run: uv run poe test + run: uv run poe test-lib - name: Add grpcio @@ -78,8 +71,7 @@ jobs: run: uv sync --locked --extra=grpcio - name: Execute test suite - working-directory: ./betterproto2 - run: uv run poe test + run: uv run poe test-lib - name: Add all but grpcio @@ -87,8 +79,7 @@ jobs: run: uv sync --locked --extra=pydantic --extra=grpclib --extra=protobuf - name: Execute test suite - working-directory: ./betterproto2 - run: uv run poe test + run: uv run poe test-lib - name: Add protobuf @@ -96,8 +87,7 @@ jobs: run: uv sync --locked --extra=protobuf - name: Execute test suite - working-directory: ./betterproto2 - run: uv run poe test + run: uv run poe test-lib - name: Add all but protobuf @@ -105,8 +95,7 @@ jobs: run: uv sync --locked --extra=pydantic --extra=grpclib --extra=grpcio - name: Execute test suite - working-directory: ./betterproto2 - run: uv run poe test + run: uv run poe test-lib tests: name: ${{ matrix.os }} / ${{ matrix.python-version }} @@ -129,19 +118,16 @@ jobs: run: uv sync --locked --all-extras --all-groups - name: Test betterproto2_compiler - working-directory: ./betterproto2_compiler shell: bash - run: uv run poe test + run: uv run poe test-plugin - name: Compile test files - working-directory: ./betterproto2_compiler shell: bash - run: uv run poe generate + run: uv run poe generate-plugin - name: Execute test suite - working-directory: ./betterproto2 shell: bash - run: uv run poe test + run: uv run poe test-lib # Run conformance test on all Ubuntu and MacOS versions - name: Install Node.js diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 4ea1b1e..7a96eec 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -28,26 +28,16 @@ jobs: run: uv sync --locked --all-extras --all-groups - name: Check formatting and linting (betterproto2) - working-directory: ./betterproto2 - shell: bash - run: uv run poe check + run: uv run poe check-lib - name: Check formatting and linting (betterproto2_compiler) - working-directory: ./betterproto2_compiler - shell: bash - run: uv run poe check + run: uv run poe check-plugin - name: Check proto formatting - working-directory: ./betterproto2_compiler - shell: bash - run: uv run poe check-proto - - - name: Pyright - working-directory: ./betterproto2 - shell: bash - run: uv run poe typecheck - - - name: Pyright - working-directory: ./betterproto2_compiler - shell: bash - run: uv run poe typecheck + run: uv run poe check-proto-plugin + + - name: Pyright (betterproto2) + run: uv run poe typecheck-lib + + - name: Pyright (betterproto2_compiler) + run: uv run poe typecheck-plugin diff --git a/betterproto2/pyproject.toml b/betterproto2/pyproject.toml index 6739817..69c6ce6 100644 --- a/betterproto2/pyproject.toml +++ b/betterproto2/pyproject.toml @@ -82,51 +82,3 @@ python_files = "test_*.py" python_classes = "" norecursedirs = "**/output_*" addopts = "-p no:warnings" - -[tool.poe.tasks.test] -cmd = "pytest" -help = "Run tests" - -[tool.poe.tasks.test-cov] -cmd = "pytest --cov=betterproto2 --cov-report=term --cov-report=html tests/" -help = "Run tests with code coverage report" - -[tool.poe.tasks.typecheck] -cmd = "pyright src" -help = "Typecheck the code with Pyright" - -[tool.poe.tasks.format] -sequence = ["_format", "_sort-imports"] -help = "Format the source code, and sort the imports" - -[tool.poe.tasks.check] -sequence = ["_check-format", "_check"] -help = "Check that the source code is formatted and the imports sorted" - -[tool.poe.tasks._format] -cmd = "ruff format src tests" -help = "Format the source code without sorting the imports" - -[tool.poe.tasks._sort-imports] -cmd = "ruff check --select I --fix src tests" -help = "Sort the imports" - -[tool.poe.tasks._check-format] -cmd = "ruff format --diff src tests" -help = "Check that the source code is formatted" - -[tool.poe.tasks._check] -cmd = "ruff check src tests" -help = "Check the code" - -[tool.poe.tasks.clean] -cmd = """ -rm -rf .coverage .mypy_cache .pytest_cache - dist betterproto.egg-info **/__pycache__ - testsoutput_* -""" -help = "Clean out generated files from the workspace" - -[tool.poe.tasks.serve-docs] -cmd = "mkdocs serve" -help = "Serve the documentation locally" diff --git a/betterproto2_compiler/pyproject.toml b/betterproto2_compiler/pyproject.toml index 497fdad..6d5ba65 100644 --- a/betterproto2_compiler/pyproject.toml +++ b/betterproto2_compiler/pyproject.toml @@ -76,105 +76,3 @@ select = [ [tool.ruff.lint.isort] combine-as-imports = true - -[tool.poe.tasks.test] -cmd = "pytest" -help = "Run tests" - -[tool.poe.tasks.generate] -# sequence = ["_generate_tests", "_generate_tests_lib"] -sequence = ["_generate_tests"] -help = "Generate test cases" - -[tool.poe.tasks._generate_tests] -script = "tests.generate:main" - -[tool.poe.tasks._generate_tests_lib] -shell = """ -python -m grpc.tools.protoc \ - --python_betterproto2_out=tests/output_betterproto \ - google/protobuf/any.proto \ - google/protobuf/api.proto \ - google/protobuf/duration.proto \ - google/protobuf/empty.proto \ - google/protobuf/field_mask.proto \ - google/protobuf/source_context.proto \ - google/protobuf/struct.proto \ - google/protobuf/timestamp.proto \ - google/protobuf/type.proto \ - google/protobuf/wrappers.proto - -python -m grpc.tools.protoc \ - --python_betterproto2_out=tests/output_betterproto_pydantic \ - --python_betterproto2_opt=pydantic_dataclasses \ - google/protobuf/any.proto \ - google/protobuf/api.proto \ - google/protobuf/duration.proto \ - google/protobuf/empty.proto \ - google/protobuf/field_mask.proto \ - google/protobuf/source_context.proto \ - google/protobuf/struct.proto \ - google/protobuf/timestamp.proto \ - google/protobuf/type.proto \ - google/protobuf/wrappers.proto - -python -m grpc.tools.protoc \ - --python_betterproto2_out=tests/output_betterproto_descriptor \ - --python_betterproto2_opt=google_protobuf_descriptors \ - google/protobuf/any.proto \ - google/protobuf/api.proto \ - google/protobuf/duration.proto \ - google/protobuf/empty.proto \ - google/protobuf/field_mask.proto \ - google/protobuf/source_context.proto \ - google/protobuf/struct.proto \ - google/protobuf/timestamp.proto \ - google/protobuf/type.proto \ - google/protobuf/wrappers.proto -""" - -[tool.poe.tasks.typecheck] -cmd = "pyright src" -help = "Typecheck the code with Pyright" - -[tool.poe.tasks.format] -sequence = ["_format", "_sort-imports"] -help = "Format the source code, and sort the imports" - -[tool.poe.tasks.check] -sequence = ["_check-format", "_check-ruff-lint"] -help = "Check that the source code is formatted and the code passes the linter" - -[tool.poe.tasks._format] -cmd = "ruff format src tests" -help = "Format the source code without sorting the imports" - -[tool.poe.tasks._sort-imports] -cmd = "ruff check --select I --fix src tests" -help = "Sort the imports" - -[tool.poe.tasks._check-format] -cmd = "ruff format --diff src tests" -help = "Check that the source code is formatted" - -[tool.poe.tasks._check-ruff-lint] -cmd = "ruff check src tests" -help = "Check the code with the Ruff linter" - -[tool.poe.tasks.check-proto] -cmd = "buf format --exit-code tests/inputs" -help = "Check that .proto files are formatted" - -# python -m grpc.tools.protoc \ -# --python_betterproto2_out=src/lib2 \ -# google/protobuf/any.proto \ -# google/protobuf/api.proto \ -# google/protobuf/duration.proto \ -# google/protobuf/empty.proto \ -# google/protobuf/field_mask.proto \ -# google/protobuf/source_context.proto \ -# google/protobuf/struct.proto \ -# google/protobuf/timestamp.proto \ -# google/protobuf/type.proto \ -# google/protobuf/wrappers.proto \ -# google/protobuf/compiler/plugin.proto diff --git a/pyproject.toml b/pyproject.toml index 44d5993..7aac231 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,123 @@ [tool.uv.workspace] members = ["betterproto2", "betterproto2_compiler"] + +[dependency-groups] +dev = ["poethepoet>=0.34.0"] + +# ── Runtime library (betterproto2) ───────────────────────────────────────── + +[tool.poe.tasks.test-lib] +cmd = "pytest" +cwd = "betterproto2" +help = "Run runtime library tests" + +[tool.poe.tasks.test-lib-cov] +cmd = "pytest --cov=betterproto2 --cov-report=term --cov-report=html tests/" +cwd = "betterproto2" +help = "Run runtime library tests with coverage" + +[tool.poe.tasks.typecheck-lib] +cmd = "pyright src" +cwd = "betterproto2" +help = "Typecheck the runtime library with Pyright" + +[tool.poe.tasks.format-lib] +sequence = ["_format-lib", "_sort-imports-lib"] +help = "Format the runtime library source code and sort imports" + +[tool.poe.tasks.check-lib] +sequence = ["_check-format-lib", "_check-lib"] +help = "Check that the runtime library source code is formatted and imports sorted" + +[tool.poe.tasks._format-lib] +cmd = "ruff format src tests" +cwd = "betterproto2" + +[tool.poe.tasks._sort-imports-lib] +cmd = "ruff check --select I --fix src tests" +cwd = "betterproto2" + +[tool.poe.tasks._check-format-lib] +cmd = "ruff format --diff src tests" +cwd = "betterproto2" + +[tool.poe.tasks._check-lib] +cmd = "ruff check src tests" +cwd = "betterproto2" + +[tool.poe.tasks.clean-lib] +shell = """ +rm -rf .coverage .mypy_cache .pytest_cache dist betterproto2.egg-info testsoutput_* +find . -type d -name __pycache__ -exec rm -rf {} + +""" +cwd = "betterproto2" +help = "Clean generated files from the runtime workspace" + +[tool.poe.tasks.serve-docs-lib] +cmd = "mkdocs serve" +cwd = "betterproto2" +help = "Serve the runtime library documentation locally" + +# ── Compiler plugin (betterproto2_compiler) ──────────────────────────────── + +[tool.poe.tasks.test-plugin] +cmd = "pytest" +cwd = "betterproto2_compiler" +help = "Run compiler tests" + +[tool.poe.tasks.generate-plugin] +sequence = ["_generate-tests-plugin"] +help = "Generate test cases" + +[tool.poe.tasks._generate-tests-plugin] +script = "tests.generate:main" +cwd = "betterproto2_compiler" + +[tool.poe.tasks.typecheck-plugin] +cmd = "pyright src" +cwd = "betterproto2_compiler" +help = "Typecheck the compiler with Pyright" + +[tool.poe.tasks.format-plugin] +sequence = ["_format-plugin", "_sort-imports-plugin"] +help = "Format the compiler source code and sort imports" + +[tool.poe.tasks.check-plugin] +sequence = ["_check-format-plugin", "_check-ruff-lint-plugin"] +help = "Check that the compiler source code is formatted and passes the linter" + +[tool.poe.tasks._format-plugin] +cmd = "ruff format src tests" +cwd = "betterproto2_compiler" + +[tool.poe.tasks._sort-imports-plugin] +cmd = "ruff check --select I --fix src tests" +cwd = "betterproto2_compiler" + +[tool.poe.tasks._check-format-plugin] +cmd = "ruff format --diff src tests" +cwd = "betterproto2_compiler" + +[tool.poe.tasks._check-ruff-lint-plugin] +cmd = "ruff check src tests" +cwd = "betterproto2_compiler" + +[tool.poe.tasks.check-proto-plugin] +cmd = "buf format --exit-code tests/inputs" +cwd = "betterproto2_compiler" +help = "Check that .proto files are formatted" + +# ── Aggregate ────────────────────────────────────────────────────────────── + +[tool.poe.tasks.all] +sequence = [ + "generate-plugin", + "typecheck-lib", + "typecheck-plugin", + "check-lib", + "check-plugin", + "check-proto-plugin", + "test-lib", + "test-plugin", +] +help = "Run all CI steps end-to-end" diff --git a/uv.lock b/uv.lock index daf83b8..571a423 100644 --- a/uv.lock +++ b/uv.lock @@ -12,6 +12,9 @@ members = [ "betterproto2-compiler", ] +[manifest.dependency-groups] +dev = [{ name = "poethepoet", specifier = ">=0.34.0" }] + [[package]] name = "annotated-types" version = "0.7.0"