Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's guaranteed that the cli will be installed. Also, why is this changing now? I don't see the change for display_logs macro?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it is for a long time now. And this workflow file was just outdated compared to the templates.

(Apparently not everybody adjusting the templates brings the changes to these bootstrap files too.)

docker images || true
docker ps -a || true
docker logs pulp || true
Expand Down
2 changes: 1 addition & 1 deletion templates/github/.ci/assets/ci_constraints.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 8 additions & 1 deletion templates/github/.ci/scripts/skip_tests.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -18,10 +24,11 @@
import sys
import os
import re
import git
import textwrap
import argparse

import git

DOC_PATTERNS = [
r"^docs/",
r"\.md$",
Expand Down
10 changes: 9 additions & 1 deletion templates/github/.ci/scripts/validate_commit_message.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
17 changes: 3 additions & 14 deletions templates/github/.github/workflows/build.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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: |
Expand Down Expand Up @@ -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"
Expand Down
14 changes: 4 additions & 10 deletions templates/github/.github/workflows/ci.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"
Expand All @@ -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"
Expand Down
1 change: 0 additions & 1 deletion templates/github/.github/workflows/pr_checks.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
2 changes: 1 addition & 1 deletion templates/github/.github/workflows/sanity.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# This script expects all <app_label>-api.json files to exist in the plugins root directory.
# It produces a <app_label>-python-client.tar and <app_label>-python-client-docs.tar file in the plugins root directory.
# It produces a <app_label>-python-client.tar file in the plugins root directory.

{% include 'header.j2' %}

Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion templates/github/.github/workflows/scripts/script.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions templates/github/.github/workflows/test.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this now the last invocation of install_python_deps?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. I didn't make the uv change complete in all places. Kind of reducing the risk here.


{{ setup_env() | indent(6) }}

Expand Down
5 changes: 2 additions & 3 deletions templates/github/.github/workflows/update-labels.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
Loading