From 6b439aa08c109b41ddc4406b951466d15d515b58 Mon Sep 17 00:00:00 2001 From: Kostiantyn Goloveshko Date: Sat, 21 Sep 2024 20:26:45 +0300 Subject: [PATCH] Move out code generation from general flow --- .github/workflows/release-pypi.yaml | 6 ++++++ .github/workflows/test-codegen.yml | 5 ----- .github/workflows/test-python.yml | 5 +++++ python/Makefile | 10 ++++++++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release-pypi.yaml b/.github/workflows/release-pypi.yaml index 85692a2a..4b13db3a 100644 --- a/.github/workflows/release-pypi.yaml +++ b/.github/workflows/release-pypi.yaml @@ -26,6 +26,12 @@ jobs: - name: Show Python version run: python --version + - name: Generate code + working-directory: ./python + run: | + make clean-real + make generate-real + - uses: cucumber/action-publish-pypi@v3.0.0 with: working-directory: "python" diff --git a/.github/workflows/test-codegen.yml b/.github/workflows/test-codegen.yml index 74f2ac8b..463c12e0 100644 --- a/.github/workflows/test-codegen.yml +++ b/.github/workflows/test-codegen.yml @@ -31,11 +31,6 @@ jobs: with: ruby-version: '3.1' - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: generate code for all languages run: | make clean-all diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 82f32e48..83461859 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -67,6 +67,11 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Generate code + working-directory: ./python + run: | + make clean-real + make generate-real - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/python/Makefile b/python/Makefile index 75715a3c..f7dc8997 100644 --- a/python/Makefile +++ b/python/Makefile @@ -8,7 +8,10 @@ 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: require install-deps +generate: ## Stub for the ancestor Makefile + echo "Skipping code generation - code is generated by Python" + +generate-real: require install-deps datamodel-codegen \ --output-model-type "pydantic_v2.BaseModel" \ --input $(HERE)../jsonschema/Envelope.json \ @@ -27,7 +30,10 @@ generate: require install-deps require: ## Check requirements for the code generation (python is required) @python --version >/dev/null 2>&1 || (echo "ERROR: python is required."; exit 1) -clean: ## Remove automatically generated files and related artifacts +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 install-deps: ## Install generation dependencies