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
2 changes: 2 additions & 0 deletions .ci/run_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export PULP_CONTENT_ORIGIN
${PULP_HTTPS:+--env PULP_HTTPS} \
${PULP_OAUTH2:+--env PULP_OAUTH2} \
${PULP_API_ROOT:+--env PULP_API_ROOT} \
${PULP_DOMAIN_ENABLED:+--env PULP_DOMAIN_ENABLED} \
${PULP_ENABLED_PLUGINS:+--env PULP_ENABLED_PLUGINS} \
--env PULP_CONTENT_ORIGIN \
--detach \
--name "pulp-ephemeral" \
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()
45 changes: 22 additions & 23 deletions .ci/scripts/check_cli_dependencies.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
#!/bin/env python3
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "packaging>=25.0,<25.1",
# ]
# ///

import tomllib
import typing as t
from pathlib import Path

import tomllib
from packaging.requirements import Requirement

GLUE_DIR = "pulp-glue-gem"


def dependencies(path: Path) -> t.Iterator[Requirement]:
with (path / "pyproject.toml").open("rb") as fp:
pyproject = tomllib.load(fp)

return (Requirement(r) for r in pyproject["project"]["dependencies"])


if __name__ == "__main__":
base_path = Path(__file__).parent.parent.parent
glue_path = "pulp-glue-gem"
with (base_path / "pyproject.toml").open("rb") as fp:
cli_pyproject = tomllib.load(fp)

cli_dependency = next(
(
Requirement(r)
for r in cli_pyproject["project"]["dependencies"]
if r.startswith("pulp-cli")
)
)

with (base_path / glue_path / "pyproject.toml").open("rb") as fp:
glue_pyproject = tomllib.load(fp)

glue_dependency = next(
(
Requirement(r)
for r in glue_pyproject["project"]["dependencies"]
if r.startswith("pulp-glue")
)
)
glue_path = base_path / GLUE_DIR

cli_dependency = next((r for r in dependencies(base_path) if r.name == "pulp-cli"))
glue_dependency = next((r for r in dependencies(glue_path) if r.name == "pulp-glue"))

if cli_dependency.specifier != glue_dependency.specifier:
print("🪢 CLI and GLUE dependencies mismatch:")
Expand Down
21 changes: 15 additions & 6 deletions .ci/scripts/check_click_for_mypy.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#!/bin/env python3
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "packaging>=25.0,<25.1",
# ]
# ///

import click
from packaging.version import parse
from importlib import metadata

if parse(click.__version__) < parse("8.1.1") or parse(click.__version__) >= parse("8.2"):
print("🚧 Linting with mypy is currently only supported with click~=8.1.1. 🚧")
print("🔧 Please run `pip install click~=8.1.1` first. 🔨")
exit(1)
from packaging.version import Version

if __name__ == "__main__":
click_version = Version(metadata.version("click"))
if click_version < Version("8.1.1"):
print("🚧 Linting with mypy is currently only supported with click>=8.1.1. 🚧")
print("🔧 Please run `pip install click>=8.1.1` first. 🔨")
exit(1)
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.

6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
build:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "actions/checkout@v5"
- uses: "actions/cache@v4"
with:
path: "~/.cache/pip"
Expand All @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

steps:
- name: "Checkout repository"
uses: "actions/checkout@v4"
uses: "actions/checkout@v5"
- name: "Initialize CodeQL"
uses: "github/codeql-action/init@v3"
with:
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/collect_changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ jobs:
collect-changes:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "actions/checkout@v5"
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 All @@ -25,10 +25,18 @@ jobs:
python3 .ci/scripts/collect_changes.py
- name: "Create Pull Request"
uses: "peter-evans/create-pull-request@v7"
id: "create_pr"
with:
token: "${{ secrets.RELEASE_TOKEN }}"
title: "Update Changelog"
body: ""
branch: "update_changes"
delete-branch: true
- 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
...
Loading
Loading