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
4 changes: 2 additions & 2 deletions .ci/scripts/validate_commit_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
repo = g.get_repo("pulp/pulp-cli")


def check_status(issue):
def check_status(issue: str) -> None:
gi = repo.get_issue(int(issue))
if gi.pull_request:
sys.exit(f"Error: issue #{issue} is a pull request.")
if gi.closed_at:
sys.exit(f"Error: issue #{issue} is closed.")


def check_changelog(issue):
def check_changelog(issue: str) -> None:
matches = list(Path("CHANGES").rglob(f"{issue}.*"))

if len(matches) < 1:
Expand Down
21 changes: 9 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,27 @@ jobs:
build:
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: "Checkout"
uses: "actions/checkout@v5"
- name: "Set up Python"
uses: "actions/setup-python@v6"
with:
python-version: "3.14"
- name: "Install python dependencies"
run: |
pip install build setuptools wheel
allow-prereleases: true
- 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
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
security-events: "write"

steps:
- name: "Checkout repository"
- name: "Checkout"
uses: "actions/checkout@v5"
- name: "Initialize CodeQL"
uses: "github/codeql-action/init@v3"
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/collect_changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ jobs:
with:
ref: "main"
fetch-depth: 0
- uses: "actions/setup-python@v6"
- name: "Set up Python"
uses: "actions/setup-python@v6"
with:
python-version: "3.x"
python-version: "3.14"
allow-prereleases: true
- name: "Setup git"
run: |
git config user.name pulpbot
Expand Down
24 changes: 8 additions & 16 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,18 @@ jobs:
- "3.11"
- "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: "Checkout"
uses: "actions/checkout@v5"
- 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
allow-prereleases: true
- name: "Install uv"
uses: "astral-sh/setup-uv@v7"
with:
enable-cache: true
- name: "Lint code"
run: |
make lint
make uv-lint
...
25 changes: 14 additions & 11 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 @@ -33,24 +33,27 @@ jobs:
check-commits:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v5"
- name: "Checkout"
uses: "actions/checkout@v5"
with:
fetch-depth: 0
- name: "Set up Python"
uses: "actions/setup-python@v6"
with:
python-version: "3.x"
- name: "Install python dependencies"
run: |
pip install toml pygithub
python-version: "3.14"
allow-prereleases: true
- 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
20 changes: 13 additions & 7 deletions .github/workflows/pr_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,25 @@ jobs:
permissions:
pull-requests: "write"
steps:
- uses: "actions/checkout@v5"
- name: "Checkout"
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"
python-version: "3.14"
allow-prereleases: true
- 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
10 changes: 8 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@ jobs:
needs: "build"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v5"
- name: "Checkout"
uses: "actions/checkout@v5"
- 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: "3.x"
python-version: "3.14"
allow-prereleases: true
- name: "Install uv"
uses: "astral-sh/setup-uv@v7"
with:
enable-cache: true
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
- name: "Set up Python"
uses: "actions/setup-python@v6"
with:
python-version: "3.x"
python-version: "3.14"
allow-prereleases: true
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ jobs:
- name: "Set up Python"
uses: "actions/setup-python@v6"
with:
python-version: "3.x"
python-version: "3.14"
allow-prereleases: true
- name: "Setup git"
run: |
git config user.name pulpbot
Expand Down
58 changes: 25 additions & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@ jobs:
unittest:
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: "Checkout"
uses: "actions/checkout@v5"
- name: "Download wheels"
uses: "actions/download-artifact@v5"
with:
Expand All @@ -30,12 +24,14 @@ 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
allow-prereleases: true
- 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 @@ -73,14 +69,8 @@ jobs:
lower_bounds: true
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: "Checkout"
uses: "actions/checkout@v5"
- name: "Download wheels"
uses: "actions/download-artifact@v5"
with:
Expand All @@ -90,18 +80,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 +97,15 @@ jobs:
PULP_ENABLED_PLUGINS: "${{ matrix.pulp_enabled_plugins }}"
OAS_VERSION: "${{ matrix.oas_version }}"
run: |
.ci/run_container.sh make paralleltest
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 paralleltest
...
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
GPG-PRIVATE-KEY-fixture-signing
site/
dist/
*.po~

tests/cli.toml
GPG-PRIVATE-KEY-fixture-signing
.root
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ 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
Expand All @@ -30,6 +34,11 @@ lint:
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
6 changes: 6 additions & 0 deletions cookiecutter/apply_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ def main(bootstrap: bool, force: bool) -> None:
except (FileNotFoundError, KeyError):
raise click.ClickException("This does not look like a pulp cli repository.")

if config.get("src_layout") is not True:
raise click.ClickException(
"In oder to proceed, this repository needs to be migrated to the src_layout. "
"See the adjacent migrate script."
)

config.setdefault("main_package", config["app_label"])
config["current_version"] = pyproject_toml["project"]["version"]

Expand Down
Loading
Loading