diff --git a/.github/workflows/release-pypi.yaml b/.github/workflows/release-pypi.yaml index 9c6cc77c..c4f1f03c 100644 --- a/.github/workflows/release-pypi.yaml +++ b/.github/workflows/release-pypi.yaml @@ -29,8 +29,8 @@ jobs: - name: Generate code working-directory: ./python run: | - make clean-real - make generate-real + make clean + make generate - uses: cucumber/action-publish-pypi@v3.0.0 with: diff --git a/.github/workflows/test-codegen.yml b/.github/workflows/test-codegen.yml index 463c12e0..e3eb5d38 100644 --- a/.github/workflows/test-codegen.yml +++ b/.github/workflows/test-codegen.yml @@ -31,6 +31,11 @@ jobs: with: ruby-version: '3.1' + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + - name: generate code for all languages run: | make clean-all diff --git a/python/Makefile b/python/Makefile index 20a494b9..2412715d 100644 --- a/python/Makefile +++ b/python/Makefile @@ -8,15 +8,12 @@ HERE := $(dir $(MKFILE_PATH)) help: ## Show this help @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \n\nWhere is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) -generate: ## Stub for the ancestor Makefile - echo "Skipping code generation - code is generated by Python" - -generate-real: require install-deps +generate: require install-deps datamodel-codegen \ --output-model-type "dataclasses.dataclass" \ --base-class ".json_converter.JSONDataclassMixin" \ --input $(HERE)../jsonschema/Envelope.json \ - --output $(HERE)src/cucumber_messages/messages.py \ + --output $(HERE)src/cucumber_messages/_messages.py \ --input-file-type=jsonschema \ --class-name Envelope \ --target-python-version=3.9 \ @@ -34,10 +31,7 @@ require: ## Check requirements for the code generation (python is required) @python --version >/dev/null 2>&1 || (echo "ERROR: python is required."; exit 1) clean: ## Stub for the ancestor Makefile - echo "Skipping code cleanup - code cleanup is done by Python" - -clean-real: ## Remove automatically generated files and related artifacts - rm -rf $(HERE)src/_messages.py + rm -rf $(HERE)src/cucumber_messages/_messages.py. install-deps: ## Install generation dependencies python -m ensurepip --upgrade diff --git a/python/src/cucumber_messages/__init__.py b/python/src/cucumber_messages/__init__.py index 34ac5777..e5162b55 100644 --- a/python/src/cucumber_messages/__init__.py +++ b/python/src/cucumber_messages/__init__.py @@ -1,5 +1,5 @@ from . import json_converter -from .messages import * +from ._messages import * # Renaming types because of confusing collision naming HookType = Type diff --git a/python/src/cucumber_messages/messages.py b/python/src/cucumber_messages/_messages.py similarity index 100% rename from python/src/cucumber_messages/messages.py rename to python/src/cucumber_messages/_messages.py