Skip to content
Draft

Use uv #1297

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
6 changes: 3 additions & 3 deletions .ci/container_setup.d/10-install-signing-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ pulp --config "${PULP_CLI_CONFIG}" debug has-plugin --name "deb" && HAS_DEB=true
pulp --config "${PULP_CLI_CONFIG}" debug has-plugin --name "ansible" && HAS_ANSIBLE=true || HAS_ANSIBLE=""
if [ "$HAS_DEB" ] || [ "$HAS_ANSIBLE" ]
then
if [ ! -f pytest_pulp_cli/GPG-PRIVATE-KEY-fixture-signing ]
if [ ! -f src/pytest_pulp_cli/GPG-PRIVATE-KEY-fixture-signing ]
then
curl -L https://github.com/pulp/pulp-fixtures/raw/master/common/GPG-PRIVATE-KEY-fixture-signing > pytest_pulp_cli/GPG-PRIVATE-KEY-fixture-signing
curl -L https://github.com/pulp/pulp-fixtures/raw/master/common/GPG-PRIVATE-KEY-fixture-signing > src/pytest_pulp_cli/GPG-PRIVATE-KEY-fixture-signing
fi
echo "Setup the signing services"
if "${CONTAINER_RUNTIME}" exec "pulp-ephemeral" id pulp
Expand All @@ -20,7 +20,7 @@ then
"${CONTAINER_RUNTIME}" exec "pulp-ephemeral" mkdir -p /var/lib/pulp/scripts/
# Setup key on the Pulp container
echo "0C1A894EBB86AFAE218424CADDEF3019C2D4A8CF:6:" | "${CONTAINER_RUNTIME}" exec -i "pulp-ephemeral" su "${PULP_USER}" -c "gpg --import-ownertrust"
"${CONTAINER_RUNTIME}" exec -i "pulp-ephemeral" su "${PULP_USER}" -c "gpg --import" < pytest_pulp_cli/GPG-PRIVATE-KEY-fixture-signing
"${CONTAINER_RUNTIME}" exec -i "pulp-ephemeral" su "${PULP_USER}" -c "gpg --import" < src/pytest_pulp_cli/GPG-PRIVATE-KEY-fixture-signing
if [ "$HAS_DEB" ]
then
echo "Setup deb release signing service"
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/validate_commit_message.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "gitpython>=3.1.46,<3.2.0",
# "pygithub>=2.8.1,<3.0.0",
# ]
# ///

Expand Down
17 changes: 6 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,24 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v5"
- uses: "actions/cache@v4"
with:
path: "~/.cache/pip"
key: "${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/*constraints.lock', '**/setup.py', '**/pyproject.toml') }}"
restore-keys: |
${{ runner.os }}-pip-

- name: "Set up Python"
uses: "actions/setup-python@v6"
with:
python-version: "3.14"
- name: "Install python dependencies"
run: |
pip install build setuptools wheel
- name: "Install uv"
uses: "astral-sh/setup-uv@v7"
with:
enable-cache: true
- name: "Build wheels"
run: |
make build
touch .root
- name: "Upload wheels"
uses: "actions/upload-artifact@v4"
with:
name: "pulp_cli_packages"
path: |
pulp-glue/dist/
.root
dist/
if-no-files-found: "error"
retention-days: 5
Expand Down
20 changes: 5 additions & 15 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,15 @@ jobs:
- "3.14"
steps:
- uses: "actions/checkout@v5"
- uses: "actions/cache@v4"
with:
path: "~/.cache/pip"
key: "${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/*constraints.lock', '**/setup.py', '**/pyproject.toml') }}"
restore-keys: |
${{ runner.os }}-pip-

- name: "Download wheels"
uses: "actions/download-artifact@v5"
with:
name: "pulp_cli_packages"
- name: "Set up Python"
uses: "actions/setup-python@v6"
with:
python-version: "${{ matrix.python }}"
- name: "Install python dependencies"
run: |
pip install dist/pulp_cli-*.whl pulp-glue/dist/pulp_glue-*.whl -r lint_requirements.txt
- name: "Install uv"
uses: "astral-sh/setup-uv@v7"
with:
enable-cache: true
- name: "Lint code"
run: |
make lint
make uv-lint
...
19 changes: 10 additions & 9 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ concurrency:
cancel-in-progress: true

jobs:
build:
uses: "./.github/workflows/build.yml"
lint:
needs:
- "build"
uses: "./.github/workflows/lint.yml"
test:
build:
needs:
- "lint"
uses: "./.github/workflows/build.yml"
test:
needs:
- "build"
uses: "./.github/workflows/test.yml"
docs:
needs:
Expand All @@ -40,17 +40,18 @@ jobs:
uses: "actions/setup-python@v6"
with:
python-version: "3.x"
- name: "Install python dependencies"
run: |
pip install toml pygithub
- name: "Install uv"
uses: "astral-sh/setup-uv@v7"
with:
enable-cache: true
- name: "Check commit message"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}"
run: |
for SHA in $(curl -H "Authorization: token $GITHUB_TOKEN" "$GITHUB_CONTEXT" | jq -r '.[].sha')
do
python .ci/scripts/validate_commit_message.py "$SHA"
uv run -q .ci/scripts/validate_commit_message.py "$SHA"
VALUE=$?
if [ "$VALUE" -gt 0 ]; then
exit "$VALUE"
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/pr_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,24 @@ jobs:
permissions:
pull-requests: "write"
steps:
- uses: "actions/checkout@v5"
- name: "Fetch Repository"
uses: "actions/checkout@v5"
with:
fetch-depth: 0
- uses: "actions/setup-python@v6"
- name: "Set up Python"
uses: "actions/setup-python@v6"
with:
python-version: "3.x"
- name: "Install uv"
uses: "astral-sh/setup-uv@v7"
with:
enable-cache: true
- name: "Determine PR labels"
run: |
pip install GitPython==3.1.42
git fetch origin ${{ github.event.pull_request.head.sha }}
python .ci/scripts/pr_labels.py "origin/${{ github.base_ref }}" "${{ github.event.pull_request.head.sha }}" >> "$GITHUB_ENV"
- uses: "actions/github-script@v8"
name: "Apply PR Labels"
uv run -q .ci/scripts/pr_labels.py "origin/${{ github.base_ref }}" "${{ github.event.pull_request.head.sha }}" >> "$GITHUB_ENV"
- name: "Apply PR Labels"
uses: "actions/github-script@v8"
with:
script: |
const { ADD_LABELS, REMOVE_LABELS } = process.env;
Expand Down
51 changes: 20 additions & 31 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v5"
- uses: "actions/cache@v4"
with:
path: "~/.cache/pip"
key: "${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/*constraints.lock', '**/setup.py', '**/pyproject.toml') }}"
restore-keys: |
${{ runner.os }}-pip-

- name: "Download wheels"
uses: "actions/download-artifact@v5"
with:
Expand All @@ -30,12 +23,13 @@ jobs:
uses: "actions/setup-python@v6"
with:
python-version: "3.14"
- name: "Install Python Test Dependencies"
run: |
pip install dist/pulp_cli-*.whl pulp-glue/dist/pulp_glue-*.whl -r test_requirements.txt
- name: "Install uv"
uses: "astral-sh/setup-uv@v7"
with:
enable-cache: true
- name: "Run tests"
run: |
make unittest
uv run --isolated --with dist/pulp_glue*.whl --with dist/pulp_cli*.whl --only-group test make unittest
test:
runs-on: "ubuntu-24.04"
needs:
Expand Down Expand Up @@ -74,13 +68,6 @@ jobs:
python: "3.13"
steps:
- uses: "actions/checkout@v5"
- uses: "actions/cache@v4"
with:
path: "~/.cache/pip"
key: "${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/*constraints.lock', '**/setup.py', '**/pyproject.toml') }}"
restore-keys: |
${{ runner.os }}-pip-

- name: "Download wheels"
uses: "actions/download-artifact@v5"
with:
Expand All @@ -90,18 +77,10 @@ jobs:
with:
python-version: "${{ matrix.python }}"
allow-prereleases: true
- name: "Install Python Test Dependencies"
run: |
if [ "${{matrix.lower_bounds}}" ]
then
pip install dist/pulp_cli-*.whl pulp-glue/dist/pulp_glue-*.whl -r test_requirements.txt -c lower_bounds_constraints.lock
elif [ "${{matrix.upper_bounds}}" ]
then
.ci/scripts/calc_constraints.py pyproject.toml pulp-glue/pyproject.toml --upper > upper_bounds_constraints.lock
pip install dist/pulp_cli-*.whl pulp-glue/dist/pulp_glue-*.whl -r test_requirements.txt -c upper_bounds_constraints.lock
else
pip install dist/pulp_cli-*.whl pulp-glue/dist/pulp_glue-*.whl -r test_requirements.txt
fi
- name: "Install uv"
uses: "astral-sh/setup-uv@v7"
with:
enable-cache: true
- name: "Run tests"
env:
CONTAINER_RUNTIME: "${{ matrix.container_runtime }}"
Expand All @@ -115,5 +94,15 @@ jobs:
PULP_ENABLED_PLUGINS: "${{ matrix.pulp_enabled_plugins }}"
OAS_VERSION: "${{ matrix.oas_version }}"
run: |
.ci/run_container.sh make livetest
if [ "${{matrix.lower_bounds}}" ]
then
RESOLUTION=("--resolution" "lowest-direct")
elif [ "${{matrix.upper_bounds}}" ]
then
RESOLUTION=("--resolution" "highest")
else
RESOLUTION=()
fi

uv run "${RESOLUTION[@]}" --isolated --with dist/pulp_glue*.whl --with dist/pulp_cli*.whl --only-group test .ci/run_container.sh make livetest
...
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
*.egg-info
__pycache__/
build/
tests/cli.toml
pytest_pulp_cli/GPG-PRIVATE-KEY-fixture-signing
site/
dist/
*.po~

tests/cli.toml
GPG-PRIVATE-KEY-fixture-signing
.root
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

LANGUAGES=de
GLUE_PLUGINS=$(notdir $(wildcard pulp-glue/pulp_glue/*))
CLI_PLUGINS=$(notdir $(wildcard pulpcore/cli/*))
GLUE_PLUGINS=$(notdir $(wildcard pulp-glue/src/pulp_glue/*))
CLI_PLUGINS=$(notdir $(wildcard src/pulpcore/cli/*))

.PHONY: info
info:
Expand All @@ -12,24 +12,33 @@ info:

.PHONY: build
build:
cd pulp-glue; pyproject-build -n
pyproject-build -n
uv build --all

.PHONY: format
format:
ruff format
ruff check --fix

.PHONY: uv-format
uv-format:
uv lock
uv run --isolated --group lint $(MAKE) format

.PHONY: lint
lint:
find tests .ci -name '*.sh' -print0 | xargs -0 shellcheck -x
ruff format --check --diff
ruff check --diff
.ci/scripts/check_click_for_mypy.py
MYPYPATH=pulp-glue mypy
mypy
cd pulp-glue; mypy
@echo "🙊 Code 🙈 LGTM 🙉 !"

.PHONY: uv-lint
uv-lint:
uv lock --check
uv run --isolated --group lint $(MAKE) lint

tests/cli.toml:
cp $@.example $@
@echo "In order to configure the tests to talk to your test server, you might need to edit $@ ."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "gitpython>=3.1.46,<3.2.0",
# "pygithub>=2.8.1,<3.0.0",
# ]
# ///

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,24 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v5"
{%- include "cache_action" %}
- name: "Set up Python"
uses: "actions/setup-python@v6"
with:
python-version: "3.14"
- name: "Install python dependencies"
run: |
pip install build setuptools wheel
- name: "Install uv"
uses: "astral-sh/setup-uv@v7"
with:
enable-cache: true
- name: "Build wheels"
run: |
make build
touch .root
- name: "Upload wheels"
uses: "actions/upload-artifact@v4"
with:
name: "pulp_cli_packages"
path: |
pulp-glue{{ cookiecutter.__app_label_suffix }}/dist/
.root
dist/
if-no-files-found: "error"
retention-days: 5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,15 @@ jobs:
- "3.14"
steps:
- uses: "actions/checkout@v5"
{%- include "cache_action" %}
- name: "Download wheels"
uses: "actions/download-artifact@v5"
with:
name: "pulp_cli_packages"
- name: "Set up Python"
uses: "actions/setup-python@v6"
with:
python-version: "{{ "${{ matrix.python }}" }}"
- name: "Install python dependencies"
run: |
pip install dist/pulp_cli{{ cookiecutter.__app_label_suffix | replace ("-", "_") }}-*.whl {%- if cookiecutter.glue %} pulp-glue{{ cookiecutter.__app_label_suffix }}/dist/pulp_glue{{ cookiecutter.__app_label_suffix | replace ("-", "_") }}-*.whl {%- endif %} -r lint_requirements.txt
- name: "Install uv"
uses: "astral-sh/setup-uv@v7"
with:
enable-cache: true
- name: "Lint code"
run: |
make lint
make uv-lint
...
Loading
Loading