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
24 changes: 11 additions & 13 deletions .ci/gen_certs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# ///

import argparse
import os
import sys
from pathlib import Path

import trustme

Expand All @@ -17,43 +17,41 @@ def main() -> None:
parser.add_argument(
"-d",
"--dir",
default=os.getcwd(),
default=".",
help="Directory where certificates and keys are written to. Defaults to cwd.",
)

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

if not os.path.isdir(cert_dir):
if not cert_dir.is_dir():
raise ValueError(f"--dir={cert_dir} is not a directory")

key_type = trustme.KeyType["ECDSA"]

# Generate the CA certificate
ca = trustme.CA(key_type=key_type)
# Write the certificate the client should trust
ca_cert_path = os.path.join(cert_dir, "ca.pem")
ca_cert_path = cert_dir / "ca.pem"
ca.cert_pem.write_to_path(path=ca_cert_path)

# Generate the server certificate
server_cert = ca.issue_cert("localhost", "127.0.0.1", "::1", key_type=key_type)
# Write the certificate and private key the server should use
server_key_path = os.path.join(cert_dir, "server.key")
server_cert_path = os.path.join(cert_dir, "server.pem")
server_key_path = cert_dir / "server.key"
server_cert_path = cert_dir / "server.pem"
server_cert.private_key_pem.write_to_path(path=server_key_path)
with open(server_cert_path, mode="w") as f:
f.truncate()
server_cert_path.write_text("")
for blob in server_cert.cert_chain_pems:
blob.write_to_path(path=server_cert_path, append=True)

# Generate the client certificate
client_cert = ca.issue_cert("admin@example.com", common_name="admin", key_type=key_type)
# Write the certificate and private key the client should use
client_key_path = os.path.join(cert_dir, "client.key")
client_cert_path = os.path.join(cert_dir, "client.pem")
client_key_path = cert_dir / "client.key"
client_cert_path = cert_dir / "client.pem"
client_cert.private_key_pem.write_to_path(path=client_key_path)
with open(client_cert_path, mode="w") as f:
f.truncate()
client_cert_path.write_text("")
for blob in client_cert.cert_chain_pems:
blob.write_to_path(path=client_cert_path, append=True)

Expand Down
11 changes: 5 additions & 6 deletions .ci/scripts/collect_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
# ///

import itertools
import os
import re
from pathlib import Path

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

# Read Towncrier settings
with open("pyproject.toml", "rb") as fp:
with Path("pyproject.toml").open("rb") as fp:
tc_settings = tomllib.load(fp)["tool"]["towncrier"]

CHANGELOG_FILE = tc_settings.get("filename", "NEWS.rst")
Expand Down Expand Up @@ -74,14 +74,13 @@ def split_changelog(changelog):


def main():
repo = Repo(os.getcwd())
repo = Repo(Path.cwd())
remote = repo.remotes[0]
branches = [ref for ref in remote.refs if re.match(r"^([0-9]+)\.([0-9]+)$", ref.remote_head)]
branches.sort(key=lambda ref: parse_version(ref.remote_head), reverse=True)
branches = [ref.name for ref in branches]

with open(CHANGELOG_FILE) as f:
main_changelog = f.read()
main_changelog = Path(CHANGELOG_FILE).read_text()
preamble, main_changes = split_changelog(main_changelog)
old_length = len(main_changes)

Expand All @@ -103,7 +102,7 @@ def main():
new_length = len(main_changes)
if old_length < new_length:
print(f"{new_length - old_length} new versions have been added.")
with open(CHANGELOG_FILE, "w") as fp:
with Path(CHANGELOG_FILE).open("w") as fp:
fp.write(preamble)
fp.writelines(change[1] for change in main_changes)

Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/pr_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
def main():
assert len(sys.argv) == 3

with open("pyproject.toml", "rb") as fp:
with Path("pyproject.toml").open("rb") as fp:
PYPROJECT_TOML = tomllib.load(fp)
BLOCKING_REGEX = re.compile(r"DRAFT|WIP|NO\s*MERGE|DO\s*NOT\s*MERGE|EXPERIMENT")
ISSUE_REGEX = re.compile(r"(?:fixes|closes)[\s:]+#(\d+)")
Expand Down
11 changes: 6 additions & 5 deletions .ci/scripts/validate_commit_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
from pathlib import Path

import tomllib
from github import Github

with open("pyproject.toml", "rb") as fp:
with Path("pyproject.toml").open("rb") as fp:
PYPROJECT_TOML = tomllib.load(fp)
KEYWORDS = ["fixes", "closes"]
BLOCKING_REGEX = [
Expand All @@ -36,11 +35,13 @@
if any(re.match(pattern, message) for pattern in BLOCKING_REGEX):
sys.exit("This PR is not ready for consumption.")

g = Github(os.environ.get("GITHUB_TOKEN"))
repo = g.get_repo("pulp/pulp-cli-deb")


def check_status(issue: str) -> None:
from github import Github

g = Github(os.environ.get("GITHUB_TOKEN"))
repo = g.get_repo("pulp/pulp-cli-deb")

gi = repo.get_issue(int(issue))
if gi.pull_request:
sys.exit(f"Error: issue #{issue} is a pull request.")
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build/
site/
dist/
*.po~
uv.lock

tests/cli.toml
GPG-PRIVATE-KEY-fixture-signing
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ _autofix:

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

.PHONY: _lint
_lint:
find tests .ci -name '*.sh' -print0 | xargs -0 shellcheck -x
ruff format --check --diff
ruff check
ruff check --output-format concise
.ci/scripts/check_cli_dependencies.py
.ci/scripts/check_click_for_mypy.py
mypy
Expand All @@ -45,7 +44,6 @@ _lint:

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

tests/cli.toml:
Expand Down
2 changes: 1 addition & 1 deletion pulp-glue-deb/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ line-length = 100

[tool.ruff.lint]
# This section is managed by the cookiecutter templates.
extend-select = ["I", "INT"]
extend-select = ["I", "INT", "PTH"]

6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ ignore_missing_imports = true
# This section is managed by the cookiecutter templates.
current_version = "0.6.0.dev"
commit = false
pre_commit_hooks = ["uv lock", "git add uv.lock"]
tag = false
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(\\.(?P<release>[a-z]+))?"
serialize = [
Expand Down Expand Up @@ -200,7 +199,7 @@ line-length = 100

[tool.ruff.lint]
# This section is managed by the cookiecutter templates.
extend-select = ["I", "INT"]
extend-select = ["I", "INT", "PTH"]

[tool.ruff.lint.isort]
# This section is managed by the cookiecutter templates.
Expand Down Expand Up @@ -241,9 +240,8 @@ lint = [
"types-toml",
]
test = [
"jinja2>=3.1.4,<3.2",
"pygments>=2.19.2",
"pytest>=7.0.0,<9.1",
"pytest>=7.0.0,<9.2",
"pytest-xdist>=3.8.0,<3.9",
"python-gnupg>=0.5.0,<0.6",
"secretstorage>=3.5.0",
Expand Down
Loading
Loading