From f958ec54a8c537b0406ce65ea3ecd27bae720785 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Tue, 7 Apr 2026 11:38:45 +0200 Subject: [PATCH] Update cookiecutter --- .github/workflows/cookiecutter.yml | 18 +++++---- cookiecutter/ci/templates/macros | 38 +++++++++++++++++++ .../.github/workflows/cookiecutter.yml | 23 ++++------- .../pyproject.toml.update | 3 ++ .../pyproject.toml.update | 3 ++ pulp-glue/pyproject.toml | 1 + pyproject.toml | 1 + 7 files changed, 63 insertions(+), 24 deletions(-) create mode 100644 cookiecutter/ci/templates/macros diff --git a/.github/workflows/cookiecutter.yml b/.github/workflows/cookiecutter.yml index 679245b7e..30497dc5a 100644 --- a/.github/workflows/cookiecutter.yml +++ b/.github/workflows/cookiecutter.yml @@ -21,20 +21,22 @@ jobs: with: token: "${{ secrets.RELEASE_TOKEN }}" path: "pulp-cli" - - name: "Set up Python" - uses: "actions/setup-python@v6" - with: - python-version: "3.x" - name: "Setup git" run: | git config user.name pulpbot git config user.email pulp-infra@redhat.com - - name: "Install python dependencies" - run: | - pip install cookiecutter tomlkit + - name: "Set up Python" + uses: "actions/setup-python@v6" + with: + python-version: "3.14" + allow-prereleases: true + - name: "Install uv" + uses: "astral-sh/setup-uv@v7" + with: + enable-cache: true - name: "Apply cookiecutter templates" run: | - ../pulp-cli/cookiecutter/apply_templates.py + uv run ../pulp-cli/cookiecutter/apply_templates.py if [ "$(git status --porcelain)" ] then git add . diff --git a/cookiecutter/ci/templates/macros b/cookiecutter/ci/templates/macros new file mode 100644 index 000000000..40785f2ca --- /dev/null +++ b/cookiecutter/ci/templates/macros @@ -0,0 +1,38 @@ +{%- macro concurrency() -%} +concurrency: + {%- raw %} + group: "main-${{ github.ref_name }}-${{ github.workflow }}" + {%- endraw %} + cancel-in-progress: true +{%- endmacro -%} + +{%- macro checkout(deep=false) -%} +- name: "Checkout" + uses: "actions/checkout@v6" + {%- if deep %} + with: + fetch-depth: 0 + {%- endif %} +{%- endmacro -%} + +{%- macro download_wheels() -%} +- name: "Download wheels" + uses: "actions/download-artifact@v8" + with: + name: "pulp_cli_packages" +{%- endmacro -%} + +{%- macro setup_python(version="3.14") -%} +- name: "Set up Python" + uses: "actions/setup-python@v6" + with: + python-version: "{{ version }}" + allow-prereleases: true +{%- endmacro -%} + +{%- macro install_uv() -%} +- name: "Install uv" + uses: "astral-sh/setup-uv@v7" + with: + enable-cache: true +{%- endmacro -%} diff --git a/cookiecutter/ci/{{ cookiecutter.__project_name }}/.github/workflows/cookiecutter.yml b/cookiecutter/ci/{{ cookiecutter.__project_name }}/.github/workflows/cookiecutter.yml index 269cb51b4..2c3ee080d 100644 --- a/cookiecutter/ci/{{ cookiecutter.__project_name }}/.github/workflows/cookiecutter.yml +++ b/cookiecutter/ci/{{ cookiecutter.__project_name }}/.github/workflows/cookiecutter.yml @@ -1,3 +1,4 @@ +{%- import 'macros' as macros with context -%} --- name: "Update CI from cookiecutter" on: @@ -23,20 +24,15 @@ jobs: token: "${{ secrets.RELEASE_TOKEN }}" {%- endraw %} path: "pulp-cli{{ cookiecutter.__app_label_suffix }}" - - name: "Set up Python" - uses: "actions/setup-python@v6" - with: - python-version: "3.x" - name: "Setup git" run: | git config user.name pulpbot git config user.email pulp-infra@redhat.com - - name: "Install python dependencies" - run: | - pip install cookiecutter tomlkit + {{ macros.setup_python() | indent(6) }} + {{ macros.install_uv() | indent(6) }} - name: "Apply cookiecutter templates" run: | - ../pulp-cli/cookiecutter/apply_templates.py + uv run ../pulp-cli/cookiecutter/apply_templates.py if [ "$(git status --porcelain)" ] then git add . @@ -77,20 +73,15 @@ jobs: token: "${{ secrets.RELEASE_TOKEN }}" {%- endraw %} path: "pulp-cli{{ cookiecutter.__app_label_suffix }}" - - name: "Set up Python" - uses: "actions/setup-python@v6" - with: - python-version: "3.x" - name: "Setup git" run: | git config user.name pulpbot git config user.email pulp-infra@redhat.com - - name: "Install python dependencies" - run: | - pip install packaging tomlkit + {{ macros.setup_python() | indent(6) }} + {{ macros.install_uv() | indent(6) }} - name: "Apply cookiecutter templates" run: | - ../pulp-cli/cookiecutter/update_pulp_cli.py + uv run ../pulp-cli/cookiecutter/update_pulp_cli.py if [ "$(git status --porcelain)" ] then git add . diff --git a/cookiecutter/ci/{{ cookiecutter.__project_name }}/pulp-glue{{ cookiecutter.__app_label_suffix }}/pyproject.toml.update b/cookiecutter/ci/{{ cookiecutter.__project_name }}/pulp-glue{{ cookiecutter.__app_label_suffix }}/pyproject.toml.update index 0c53498b9..e913353cd 100644 --- a/cookiecutter/ci/{{ cookiecutter.__project_name }}/pulp-glue{{ cookiecutter.__app_label_suffix }}/pyproject.toml.update +++ b/cookiecutter/ci/{{ cookiecutter.__project_name }}/pulp-glue{{ cookiecutter.__app_label_suffix }}/pyproject.toml.update @@ -29,6 +29,9 @@ files = "{% if cookiecutter.src_layout %}src{% else %}pulp_glue{% endif %}/**/*. mypy_path = ["{% if cookiecutter.src_layout %}src{% else %}.{% endif %}"] namespace_packages = true explicit_package_bases = true +{%- if cookiecutter.__app_label_suffix == "" %} +plugins = ["pydantic.mypy"] +{%- endif %} [[tool.mypy.overrides]] # This section is managed by the cookiecutter templates. diff --git a/cookiecutter/ci/{{ cookiecutter.__project_name }}/pyproject.toml.update b/cookiecutter/ci/{{ cookiecutter.__project_name }}/pyproject.toml.update index d4127a0c6..41c7f6c56 100644 --- a/cookiecutter/ci/{{ cookiecutter.__project_name }}/pyproject.toml.update +++ b/cookiecutter/ci/{{ cookiecutter.__project_name }}/pyproject.toml.update @@ -181,6 +181,9 @@ files = "{% if cookiecutter.src_layout %}src{% else %}pulpcore{% endif %}/**/*.p mypy_path = ["{% if cookiecutter.src_layout %}src{% else %}.{% endif %}"{% if cookiecutter.glue %}, "pulp-glue{{ cookiecutter.__app_label_suffix }}{% if cookiecutter.src_layout %}/src{% endif %}"{% endif %}] namespace_packages = true explicit_package_bases = true +{%- if cookiecutter.__app_label_suffix == "" %} +plugins = ["pydantic.mypy"] +{%- endif %} [[tool.mypy.overrides]] # This section is managed by the cookiecutter templates. diff --git a/pulp-glue/pyproject.toml b/pulp-glue/pyproject.toml index bafb2feac..6e7cae158 100644 --- a/pulp-glue/pyproject.toml +++ b/pulp-glue/pyproject.toml @@ -54,6 +54,7 @@ files = "src/**/*.py, tests/**/*.py" mypy_path = ["src"] namespace_packages = true explicit_package_bases = true +plugins = ["pydantic.mypy"] [[tool.mypy.overrides]] # This section is managed by the cookiecutter templates. diff --git a/pyproject.toml b/pyproject.toml index a23246f49..0e45adaff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -235,6 +235,7 @@ files = "src/**/*.py, tests/*.py" mypy_path = ["src", "pulp-glue/src"] namespace_packages = true explicit_package_bases = true +plugins = ["pydantic.mypy"] [[tool.mypy.overrides]] # This section is managed by the cookiecutter templates.