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
15 changes: 9 additions & 6 deletions .ci/gen_certs.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "trustme>=1.2.1,<1.3.0",
# ]
# ///

import argparse
import os
import sys
import typing as t

import trustme


def main(argv: t.Optional[t.List[str]] = None) -> None:
if argv is None:
argv = sys.argv[1:]

def main() -> None:
parser = argparse.ArgumentParser(prog="gen_certs")
parser.add_argument(
"-d",
Expand All @@ -18,7 +21,7 @@ def main(argv: t.Optional[t.List[str]] = None) -> None:
help="Directory where certificates and keys are written to. Defaults to cwd.",
)

args = parser.parse_args(argv)
args = parser.parse_args(sys.argv[1:])
cert_dir = args.dir

if not os.path.isdir(cert_dir):
Expand Down
119 changes: 119 additions & 0 deletions .ci/scripts/calc_constraints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/bin/python3
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "packaging>=25.0,<25.1",
# "tomli>=2.3.0,<2.4.0;python_version<'3.11'",
# ]
# ///

import argparse
import fileinput
import sys

from packaging.requirements import Requirement
from packaging.version import Version

try:
import tomllib
except ImportError:
import tomli as tomllib


def split_comment(line):
split_line = line.split("#", maxsplit=1)
try:
comment = " # " + split_line[1].strip()
except IndexError:
comment = ""
return split_line[0].strip(), comment


def to_upper_bound(req):
try:
requirement = Requirement(req)
except ValueError:
return f"# UNPARSABLE: {req}"
else:
for spec in requirement.specifier:
if spec.operator == "~=":
return f"# NO BETTER CONSTRAINT: {req}"
if spec.operator == "<=":
operator = "=="
max_version = spec.version
return f"{requirement.name}{operator}{max_version}"
if spec.operator == "<":
operator = "~="
version = Version(spec.version)
if version.micro != 0:
max_version = f"{version.major}.{version.minor}.{version.micro - 1}"
elif version.minor != 0:
max_version = f"{version.major}.{version.minor - 1}"
elif version.major != 0:
max_version = f"{version.major - 1}.0"
else:
return f"# NO BETTER CONSTRAINT: {req}"
return f"{requirement.name}{operator}{max_version}"
return f"# NO UPPER BOUND: {req}"


def to_lower_bound(req):
try:
requirement = Requirement(req)
except ValueError:
return f"# UNPARSABLE: {req}"
else:
for spec in requirement.specifier:
if spec.operator == ">=":
if requirement.name == "pulpcore":
# Currently an exception to allow for pulpcore bugfix releases.
# TODO Semver libraries should be allowed too.
operator = "~="
else:
operator = "=="
min_version = spec.version
return f"{requirement.name}{operator}{min_version}"
return f"# NO LOWER BOUND: {req}"


def main():
"""Calculate constraints for the lower bound of dependencies where possible."""
parser = argparse.ArgumentParser(
prog=sys.argv[0],
description="Calculate constraints for the lower or upper bound of dependencies where "
"possible.",
)
parser.add_argument("-u", "--upper", action="store_true")
parser.add_argument("filename", nargs="*")
args = parser.parse_args()

modifier = to_upper_bound if args.upper else to_lower_bound

req_files = [filename for filename in args.filename if not filename.endswith("pyproject.toml")]
pyp_files = [filename for filename in args.filename if filename.endswith("pyproject.toml")]
if req_files:
with fileinput.input(files=req_files) as req_file:
for line in req_file:
if line.strip().startswith("#"):
# Shortcut comment only lines
print(line.strip())
else:
req, comment = split_comment(line)
new_req = modifier(req)
print(new_req + comment)
for filename in pyp_files:
with open(filename, "rb") as fp:
pyproject = tomllib.load(fp)
for req in pyproject["project"]["dependencies"]:
new_req = modifier(req)
print(new_req)
optional_dependencies = pyproject["project"].get("optional-dependencies")
if optional_dependencies:
for opt in optional_dependencies.values():
for req in opt:
new_req = modifier(req)
print(new_req)


if __name__ == "__main__":
main()
9 changes: 8 additions & 1 deletion .ci/scripts/check_cli_dependencies.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#!/bin/env python3
import tomllib
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "packaging>=25.0,<25.1",
# ]
# ///

import typing as t
from pathlib import Path

import tomllib
from packaging.requirements import Requirement

GLUE_DIR = "pulp-glue-deb"
Expand Down
6 changes: 6 additions & 0 deletions .ci/scripts/check_click_for_mypy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/env python3
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "packaging>=25.0,<25.1",
# ]
# ///

from importlib import metadata

Expand Down
9 changes: 8 additions & 1 deletion .ci/scripts/collect_changes.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#!/bin/env python3
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "gitpython>=3.1.46,<3.2.0",
# "packaging>=25.0,<25.1",
# ]
# ///

import itertools
import os
import re
import tomllib

import tomllib
from git import GitCommandError, Repo
from packaging.version import parse as parse_version

Expand Down
8 changes: 7 additions & 1 deletion .ci/scripts/pr_labels.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#!/bin/env python3
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "gitpython>=3.1.46,<3.2.0",
# ]
# ///

# This script is running with elevated privileges from the main branch against pull requests.

import re
import sys
import tomllib
from pathlib import Path

import tomllib
from git import Repo


Expand Down
9 changes: 8 additions & 1 deletion .ci/scripts/validate_commit_message.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "gitpython>=3.1.46,<3.2.0",
# ]
# ///

import os
import re
import subprocess
import sys
import tomllib
from pathlib import Path

import tomllib
from github import Github

with open("pyproject.toml", "rb") as fp:
Expand Down
25 changes: 0 additions & 25 deletions .github/dependabot.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
${{ runner.os }}-pip-

- name: "Set up Python"
uses: "actions/setup-python@v5"
uses: "actions/setup-python@v6"
with:
python-version: "3.11"
python-version: "3.14"
- name: "Install python dependencies"
run: |
pip install build setuptools wheel
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/collect_changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
with:
ref: "main"
fetch-depth: 0
- uses: "actions/setup-python@v5"
- uses: "actions/setup-python@v6"
with:
python-version: "3.11"
python-version: "3.x"
- name: "Setup git"
run: |
git config user.name pulpbot
Expand Down
51 changes: 49 additions & 2 deletions .github/workflows/cookiecutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
token: "${{ secrets.RELEASE_TOKEN }}"
path: "pulp-cli-deb"
- name: "Set up Python"
uses: "actions/setup-python@v5"
uses: "actions/setup-python@v6"
with:
python-version: "3.11"
python-version: "3.x"
- name: "Setup git"
run: |
git config user.name pulpbot
Expand Down Expand Up @@ -57,4 +57,51 @@ jobs:
env:
GH_TOKEN: "${{ secrets.RELEASE_TOKEN }}"
continue-on-error: true
update-dependencies:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v5"
with:
repository: "pulp/pulp-cli"
path: "pulp-cli"
- uses: "actions/checkout@v5"
with:
token: "${{ secrets.RELEASE_TOKEN }}"
path: "pulp-cli-deb"
- 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 [email protected]
- name: "Install python dependencies"
run: |
pip install packaging tomlkit
- name: "Apply cookiecutter templates"
run: |
../pulp-cli/cookiecutter/update_pulp_cli.py
if [ "$(git status --porcelain)" ]
then
git add .
git commit -m "Update CLI and GLUE"
fi
- name: "Create Pull Request"
uses: "peter-evans/create-pull-request@v7"
id: "create_pr"
with:
token: "${{ secrets.RELEASE_TOKEN }}"
title: "Update CLI and GLUE"
body: ""
branch: "update_cli"
delete-branch: true
path: "pulp-cli-deb"
- name: "Mark PR automerge"
run: |
gh pr merge --rebase --auto "${{ steps.create_pr.outputs.pull-request-number }}"
if: "steps.create_pr.outputs.pull-request-number"
env:
GH_TOKEN: "${{ secrets.RELEASE_TOKEN }}"
continue-on-error: true
...
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
matrix:
python:
- "3.11"
- "3.13"
- "3.14"
steps:
- uses: "actions/checkout@v5"
- uses: "actions/cache@v4"
Expand All @@ -27,7 +27,7 @@ jobs:
with:
name: "pulp_cli_packages"
- name: "Set up Python"
uses: "actions/setup-python@v5"
uses: "actions/setup-python@v6"
with:
python-version: "${{ matrix.python }}"
- name: "Install python dependencies"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
with:
fetch-depth: 0
- name: "Set up Python"
uses: "actions/setup-python@v5"
uses: "actions/setup-python@v6"
with:
python-version: "3.11"
python-version: "3.x"
- name: "Install python dependencies"
run: |
pip install toml pygithub
Expand Down
Loading
Loading