diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 17a4d4e9..62af6dcd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,15 +39,13 @@ jobs: fetch-depth: 1 repository: "pulp/pulp-openapi-generator" path: "pulp-openapi-generator" - - name: "Install python dependencies" - run: | - uv pip install build packaging twine wheel mkdocs jq - name: "Build package" run: | - python3 -m build - twine check dist/* + uv build + uvx twine check dist/* - name: "Install built packages" run: | + # This seems to be the only way to inject the constraints file. uv pip install dist/pulp_catdog-*-py3-none-any.whl -c .ci/assets/ci_constraints.txt - name: "Generate api specs" run: | @@ -89,15 +87,6 @@ jobs: if-no-files-found: "error" retention-days: 5 overwrite: true - - name: "Upload python client docs" - uses: "actions/upload-artifact@v7" - with: - name: "python-client-docs.tar" - path: | - pulp_catdog/catdog-python-client-docs.tar - if-no-files-found: "error" - retention-days: 5 - overwrite: true - name: "Build Ruby bindings packages" run: | .github/workflows/scripts/build_ruby_client.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b9646d4..5231c4d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: path: "plugin_template" - uses: "actions/setup-python@v6" with: - python-version: "3.11" + python-version: "3.12" - name: "Install uv" uses: "astral-sh/setup-uv@v7" with: @@ -34,9 +34,7 @@ jobs: .ci/bootstrap_catdog.sh # Below this line we include the steps of the ci workflow of the generated plugin - - name: "Install python dependencies" - run: | - uv pip install requests pygithub pyyaml + - name: "Check commit message" # This will fail for our fake plugin if: false diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4d49ab66..40cafdb7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -37,9 +37,8 @@ jobs: - name: "Lint plugin_template" working-directory: "plugin_template" run: | - uv pip install ruff - ruff format --check --diff plugin-template utils.py - ruff check plugin-template utils.py + uvx ruff format --check --diff plugin-template utils.py + uvx ruff check plugin-template utils.py - name: "Bootstrap catdog plugin" working-directory: "plugin_template" run: | @@ -55,7 +54,7 @@ jobs: run: | yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows - - name: "Check formatting" + - name: "Check formating" run: | ruff format --check --diff diff --git a/.github/workflows/sanity.yml b/.github/workflows/sanity.yml index 08ac2a54..c84a8ffe 100644 --- a/.github/workflows/sanity.yml +++ b/.github/workflows/sanity.yml @@ -33,7 +33,7 @@ jobs: - uses: "actions/setup-python@v6" with: - python-version: "3.11" + python-version: "3.12" - name: "Install uv" uses: "astral-sh/setup-uv@v7" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e9245259..b65771a4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,8 +38,7 @@ jobs: - uses: "actions/setup-python@v6" with: - python-version: "3.11" - + python-version: "3.12" - name: "Install uv" uses: "astral-sh/setup-uv@v7" with: @@ -86,7 +85,7 @@ jobs: - name: "Install python dependencies" run: | - uv pip install build towncrier twine wheel httpie docker netaddr boto3 'ansible~=10.3.0' mkdocs jq jsonpatch bump-my-version + uv pip install httpie docker netaddr boto3 'ansible~=10.3.0' mkdocs jsonpatch echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/pulp_catdog/.ci/assets/httpie/" >> $GITHUB_ENV - name: "Set environment variables" @@ -150,7 +149,7 @@ jobs: if: always() run: | echo "Need to debug? Please check: https://github.com/marketplace/actions/debugging-with-tmate" - http --timeout 30 --check-status --pretty format --print hb "https://pulp${PULP_API_ROOT}api/v3/status/" || true + pulp status || true docker images || true docker ps -a || true docker logs pulp || true diff --git a/templates/github/.ci/assets/ci_constraints.txt b/templates/github/.ci/assets/ci_constraints.txt index 3380502b..2b7015ff 100644 --- a/templates/github/.ci/assets/ci_constraints.txt +++ b/templates/github/.ci/assets/ci_constraints.txt @@ -1,6 +1,6 @@ # Pulpcore versions without the openapi command do no longer work in the CI # Pulpcore versions without the django 5 storage compatibility will fail, >3.63,<3.70 -pulpcore>=3.21.30,!=3.23.*,!=3.24.*,!=3.25.*,!=3.26.*,!=3.27.*,!=3.29.*,!=3.30.*,!=3.31.*,!=3.32.*,!=3.33.*,!=3.34.*,!=3.35.*,!=3.36.*,!=3.37.*,!=3.38.*,!=3.40.*,!=3.41.*,!=3.42.*,!=3.43.*,!=3.44.*,!=3.45.*,!=3.46.*,!=3.47.*,!=3.48.*,!=3.50.*,!=3.51.*,!=3.52.*,!=3.53.*,!=3.54.*,!=3.64.*,!=3.65.*,!=3.66.*,!=3.67.*,!=3.68.*,!=3.69.* +pulpcore>=3.49.0,!=3.50.*,!=3.51.*,!=3.52.*,!=3.53.*,!=3.54.*,!=3.64.*,!=3.65.*,!=3.66.*,!=3.67.*,!=3.68.*,!=3.69.* tablib!=3.6.0 diff --git a/templates/github/.ci/scripts/skip_tests.py b/templates/github/.ci/scripts/skip_tests.py index a68d000d..3106f4af 100755 --- a/templates/github/.ci/scripts/skip_tests.py +++ b/templates/github/.ci/scripts/skip_tests.py @@ -1,4 +1,10 @@ #!/usr/bin/env python3 +# /// script +# requires-python = ">=3.12" +# dependencies = [ +# "gitpython>=3.1.62", +# ] +# /// """ skip_tests.py - Check if only documentation files were changed in a git branch @@ -18,10 +24,11 @@ import sys import os import re -import git import textwrap import argparse +import git + DOC_PATTERNS = [ r"^docs/", r"\.md$", diff --git a/templates/github/.ci/scripts/validate_commit_message.py b/templates/github/.ci/scripts/validate_commit_message.py index a4dc9004..f5207a3a 100644 --- a/templates/github/.ci/scripts/validate_commit_message.py +++ b/templates/github/.ci/scripts/validate_commit_message.py @@ -1,14 +1,22 @@ # This file is managed by the plugin template. # Do not edit. +# /// script +# requires-python = ">=3.12" +# dependencies = [ +# "pygithub", +# "pyyaml", +# ] +# /// + import os import re import subprocess import sys import tomllib -import yaml from pathlib import Path +import yaml from github import Github diff --git a/templates/github/.github/workflows/build.yml.j2 b/templates/github/.github/workflows/build.yml.j2 index 68d732c1..ac0c3921 100644 --- a/templates/github/.github/workflows/build.yml.j2 +++ b/templates/github/.github/workflows/build.yml.j2 @@ -25,7 +25,6 @@ jobs: {{ checkout(path=plugin_name) | indent(6) }} {{ checkout(repository="pulp/pulp-openapi-generator", path="pulp-openapi-generator") | indent(6) }} {{ setup_python() | indent(6) }} - {{ install_python_deps(["build", "packaging", "twine", "wheel", "mkdocs", "jq"]) | indent(6) }} {%- if os_required_packages %} - name: "Install OS packages" run: | @@ -34,10 +33,11 @@ jobs: {%- endif %} - name: "Build package" run: | - python3 -m build - twine check dist/* + uv build + uvx twine check dist/* - name: "Install built packages" run: | + # This seems to be the only way to inject the constraints file. uv pip install dist/{{ plugin_name | snake }}-*-py3-none-any.whl -c .ci/assets/ci_constraints.txt - name: "Generate api specs" run: | @@ -78,17 +78,6 @@ jobs: if-no-files-found: "error" retention-days: 5 overwrite: true - - name: "Upload python client docs" - uses: "actions/upload-artifact@v7" - with: - name: "python-client-docs.tar" - path: | - {%- for plugin in plugins %} - {{ plugin_name }}/{{ plugin.app_label }}-python-client-docs.tar - {%- endfor %} - if-no-files-found: "error" - retention-days: 5 - overwrite: true {%- if deploy_client_to_rubygems %} {{ run_script(name="Build Ruby bindings packages", file="build_ruby_client.sh") | indent(6) }} - name: "Upload Ruby client" diff --git a/templates/github/.github/workflows/ci.yml.j2 b/templates/github/.github/workflows/ci.yml.j2 index c3edeb3b..23e40b51 100644 --- a/templates/github/.github/workflows/ci.yml.j2 +++ b/templates/github/.github/workflows/ci.yml.j2 @@ -22,21 +22,17 @@ defaults: working-directory: "{{ plugin_name }}" jobs: - {%- if check_commit_message or lint_requirements %} + {%- if check_commit_message %} check-commits: runs-on: "ubuntu-latest" steps: {{ checkout(depth=0, path=plugin_name) | indent(6) }} - {{ setup_python() | indent(6) }} - {%- if check_commit_message %} - {{ install_python_deps(["requests", "pygithub", "pyyaml"]) | indent(6) }} + {{ setup_python(pyversion="3.12") | indent(6) }} - name: "Check commit message" - if: github.event_name == 'pull_request' env: {{ set_env_vars() | indent(10) }} run: | .github/workflows/scripts/check_commit.sh - {%- endif %} {%- endif %} check-changes: @@ -49,9 +45,7 @@ jobs: steps: {{ checkout(depth=0, path=plugin_name) | indent(6) }} - {{ setup_python() | indent(6) }} - - {{ install_python_deps(["gitpython"]) | indent(6) }} + {{ setup_python(pyversion="3.12") | indent(6) }} - name: "Analyze changed files" id: "check" @@ -68,7 +62,7 @@ jobs: BASE_REF={{ "${{ github.event.pull_request.base.sha }}" }} echo "Checking against:" git name-rev $BASE_REF - python3 .ci/scripts/skip_tests.py . $BASE_REF + uv run --script .ci/scripts/skip_tests.py . $BASE_REF exit_code=$? if [ $exit_code -ne 0 ] && [ $exit_code -ne 1 ]; then echo "Error: skip_tests.py returned unexpected exit code $exit_code" diff --git a/templates/github/.github/workflows/pr_checks.yml.j2 b/templates/github/.github/workflows/pr_checks.yml.j2 index 6e9a71cc..09042b37 100644 --- a/templates/github/.github/workflows/pr_checks.yml.j2 +++ b/templates/github/.github/workflows/pr_checks.yml.j2 @@ -40,7 +40,6 @@ jobs: - name: "Determine PR labels" run: | {%- raw %} - uv pip install GitPython==3.1.42 git fetch origin ${{ github.event.pull_request.head.sha }} uv run --script .ci/scripts/pr_labels.py "origin/${{ github.base_ref }}" "${{ github.event.pull_request.head.sha }}" >> "$GITHUB_ENV" {%- endraw %} diff --git a/templates/github/.github/workflows/sanity.yml.j2 b/templates/github/.github/workflows/sanity.yml.j2 index 9957e9fe..cf199eeb 100644 --- a/templates/github/.github/workflows/sanity.yml.j2 +++ b/templates/github/.github/workflows/sanity.yml.j2 @@ -26,7 +26,7 @@ jobs: steps: {{ checkout(path=plugin_name) | indent(6) }} - {{ setup_python() | indent(6) }} + {{ setup_python(pyversion="3.12") | indent(6) }} {{ install_python_deps(["-r", "lint_requirements.txt"]) | indent(6) }} diff --git a/templates/github/.github/workflows/scripts/before_install.sh.j2 b/templates/github/.github/workflows/scripts/before_install.sh.j2 index 9db7e055..6c3f6449 100755 --- a/templates/github/.github/workflows/scripts/before_install.sh.j2 +++ b/templates/github/.github/workflows/scripts/before_install.sh.j2 @@ -18,7 +18,9 @@ if [ -f .github/workflows/scripts/pre_before_install.sh ]; then source .github/workflows/scripts/pre_before_install.sh fi -COMPONENT_VERSION="$(bump-my-version show current_version | tail -n -1 | python -c 'from packaging.version import Version; print(Version(input()))')" +{# This is common for both setup.py and pyproject.toml based branches. +project.version may be the more canonical place once this transition is complete. -#} +COMPONENT_VERSION="$(python -c 'import tomllib; from packaging.version import Version; print(Version(tomllib.load(open("pyproject.toml", "rb"))["tool"]["bumpversion"]["current_version"]))')" COMPONENT_SOURCE="./{{ plugin_name }}/dist/{{ plugin_name | snake }}-${COMPONENT_VERSION}-py3-none-any.whl" {%- set PULPCORE_PREFIX = "" if plugin_name == "pulpcore" else " pulpcore" %} diff --git a/templates/github/.github/workflows/scripts/build_python_client.sh.j2 b/templates/github/.github/workflows/scripts/build_python_client.sh.j2 index b2b6a0d2..a0ad2650 100755 --- a/templates/github/.github/workflows/scripts/build_python_client.sh.j2 +++ b/templates/github/.github/workflows/scripts/build_python_client.sh.j2 @@ -1,7 +1,7 @@ #!/bin/bash # This script expects all -api.json files to exist in the plugins root directory. -# It produces a -python-client.tar and -python-client-docs.tar file in the plugins root directory. +# It produces a -python-client.tar file in the plugins root directory. {% include 'header.j2' %} @@ -17,35 +17,12 @@ rm -rf "{{ plugin.name | snake }}-client" ./gen-client.sh "../{{ plugin_name }}/{{ plugin.app_label }}-api.json" "{{ plugin.app_label }}" python "{{ plugin.name | snake }}" pushd {{ plugin.name | snake }}-client -python -m build - -twine check "dist/{{ plugin.name | snake }}_client-"*"-py3-none-any.whl" -twine check "dist/{{ plugin.name | snake }}_client-"*".tar.gz" +uv build +uvx twine check "dist/{{ plugin.name | snake }}_client-"*"-py3-none-any.whl" +uvx twine check "dist/{{ plugin.name | snake }}_client-"*".tar.gz" tar cvf "../../{{ plugin_name }}/{{ plugin.app_label }}-python-client.tar" ./dist -find ./docs/* -exec sed -i 's/Back to README/Back to HOME/g' {} \; -find ./docs/* -exec sed -i 's/README//g' {} \; -cp README.md docs/index.md -sed -i 's/docs\///g' docs/index.md -find ./docs/* -exec sed -i 's/\.md//g' {} \; - -cat >> mkdocs.yml << DOCSYAML ---- -site_name: {{ plugin.name | camel }} Client -site_description: {{ plugin.app_label | camel }} bindings -site_author: Pulp Team -site_url: https://docs.pulpproject.org/{{ plugin.name | snake }}_client/ -repo_name: {{ github_org }}/{{ plugin.name | snake }} -repo_url: https://github.com/{{ github_org }}/{{ plugin.name | snake }} -theme: readthedocs -DOCSYAML - -# Building the bindings docs -mkdocs build - -# Pack the built site. -tar cvf ../../{{ plugin_name }}/{{ plugin.app_label }}-python-client-docs.tar ./site popd {%- endfor %} popd diff --git a/templates/github/.github/workflows/scripts/check_commit.sh.j2 b/templates/github/.github/workflows/scripts/check_commit.sh.j2 index 816f786b..709594b9 100755 --- a/templates/github/.github/workflows/scripts/check_commit.sh.j2 +++ b/templates/github/.github/workflows/scripts/check_commit.sh.j2 @@ -9,5 +9,5 @@ set -euv for SHA in $(curl -H "Authorization: token $GITHUB_TOKEN" "$GITHUB_CONTEXT" | jq -r '.[].sha') do - python3 .ci/scripts/validate_commit_message.py "$SHA" + uv run --script .ci/scripts/validate_commit_message.py "$SHA" done diff --git a/templates/github/.github/workflows/scripts/script.sh.j2 b/templates/github/.github/workflows/scripts/script.sh.j2 index 4775576d..2092dac4 100755 --- a/templates/github/.github/workflows/scripts/script.sh.j2 +++ b/templates/github/.github/workflows/scripts/script.sh.j2 @@ -67,7 +67,7 @@ pushd ../pulp-openapi-generator rm -rf "./${PACKAGE}-client" ./gen-client.sh "${COMPONENT}-api.json" "${COMPONENT}" python "${PACKAGE}" pushd "${PACKAGE}-client" - python -m build + uv build popd else if [ ! -f "${PACKAGE}-client/dist/${PACKAGE}_client-${VERSION}-py3-none-any.whl" ] diff --git a/templates/github/.github/workflows/scripts/update_backport_labels.py.j2 b/templates/github/.github/workflows/scripts/update_backport_labels.py.j2 index 9b36875c..6bb3e528 100644 --- a/templates/github/.github/workflows/scripts/update_backport_labels.py.j2 +++ b/templates/github/.github/workflows/scripts/update_backport_labels.py.j2 @@ -1,5 +1,15 @@ {% include 'header.j2' %} +# /// script +# requires-python = ">=3.12" +# dependencies = [ +# "pyyaml", +# "requests", +# ] +# /// + +# This script is running with elevated privileges from the main branch against pull requests. + import requests import yaml import random diff --git a/templates/github/.github/workflows/test.yml.j2 b/templates/github/.github/workflows/test.yml.j2 index 5f171fa9..34cd65e9 100644 --- a/templates/github/.github/workflows/test.yml.j2 +++ b/templates/github/.github/workflows/test.yml.j2 @@ -38,7 +38,7 @@ jobs: {{ checkout(repository="pulp/pulp-openapi-generator", path="pulp-openapi-generator") | indent(6) }} - {{ setup_python() | indent(6) }} + {{ setup_python(pyversion="3.12") | indent(6) }} - name: "Download plugin package" uses: "actions/download-artifact@v8" @@ -70,7 +70,7 @@ jobs: {%- endfor %} {%- endif %} - {{ install_python_deps(["build", "towncrier", "twine", "wheel", "httpie", "docker", "netaddr", "boto3", "ansible~=10.3.0", "mkdocs", "jq", "jsonpatch", "bump-my-version"]) | indent(6) }} + {{ install_python_deps(["httpie", "docker", "netaddr", "boto3", "ansible~=10.3.0", "mkdocs", "jsonpatch"]) | indent(6) }} {{ setup_env() | indent(6) }} diff --git a/templates/github/.github/workflows/update-labels.yml.j2 b/templates/github/.github/workflows/update-labels.yml.j2 index a8510e95..91274467 100644 --- a/templates/github/.github/workflows/update-labels.yml.j2 +++ b/templates/github/.github/workflows/update-labels.yml.j2 @@ -21,13 +21,12 @@ jobs: update_backport_labels: runs-on: "ubuntu-latest" steps: - {{ setup_python() | indent(6) }} + {{ setup_python(pyversion="3.12") | indent(6) }} {{ configure_git() | indent(6) }} - {{ install_python_deps(["requests", "pyyaml"]) | indent(6) }} - uses: "actions/checkout@v6" - name: "Update labels" run: | - python3 .github/workflows/scripts/update_backport_labels.py + uv run --script .github/workflows/scripts/update_backport_labels.py env: {%- raw %} GITHUB_TOKEN: "${{ secrets.RELEASE_TOKEN }}"