Skip to content

Commit

Permalink
Merge pull request #433 from jku/enable-python-3.9
Browse files Browse the repository at this point in the history
Try to support Python 3.9
kommendorkapten authored Dec 2, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents f332ecd + b0d6f7b commit ac1e1de
Showing 5 changed files with 41 additions and 12 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -9,13 +9,26 @@ permissions: {}

jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
toxenv: [lint-signer, lint-repo, test-signer, test-repo, test-e2e]
toxenv: [lint-signer, test-signer]
pyversion: ['3.9', '3.12']
os: [ubuntu-latest, macos-latest]
# Only run repository on 3.12 (dependency pinning is easier with single version)
include:
- toxenv: lint-repo
pyversion: '3.12'
os: ubuntu-latest
- toxenv: test-repo
pyversion: '3.12'
os: ubuntu-latest
- toxenv: test-e2e
pyversion: '3.12'
os: ubuntu-latest
runs-on: ${{ matrix.os }}
env:
TOXENV: ${{ matrix.toxenv }}

@@ -24,7 +37,7 @@ jobs:

- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.12'
python-version: ${{ matrix.pyversion }}
cache: 'pip'
cache-dependency-path: |
signer/pyproject.toml
5 changes: 4 additions & 1 deletion signer/pyproject.toml
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ dependencies = [
"tuf ~= 3.1",
"click ~= 8.1",
]
requires-python = ">=3.10"
requires-python = ">=3.9"
dynamic = ["version"]

[project.scripts]
@@ -30,6 +30,9 @@ lint = [
[tool.hatch.version]
path = "tuf_on_ci_sign/__init__.py"

[tool.mypy]
python_version = "3.9"

[[tool.mypy.overrides]]
module = [
"securesystemslib.*",
11 changes: 9 additions & 2 deletions signer/tuf_on_ci_sign/_signer_repository.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@

"""Internal repository module for TUF-on-CI signer tools"""

from __future__ import annotations

import copy
import filecmp
import json
@@ -11,7 +13,6 @@
from dataclasses import dataclass
from datetime import datetime, timedelta
from enum import Enum, unique
from glob import glob

import click
from securesystemslib.exceptions import UnverifiedSignatureError
@@ -83,7 +84,13 @@ def blue(text: str) -> str:

def _find_changed_roles(known_good_dir: str, signing_event_dir: str) -> list[str]:
"""Return list of roles that exist and have changed in this signing event"""
files = glob("*.json", root_dir=signing_event_dir)

files = []
for _, _, filenames in os.walk(signing_event_dir):
for filename in filenames:
if filename.endswith(".json"):
files.append(filename)

changed_roles = []
for fname in files:
if not os.path.exists(f"{known_good_dir}/{fname}") or not filecmp.cmp(
2 changes: 2 additions & 0 deletions signer/tuf_on_ci_sign/delegate.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@

"""tuf-on-ci-delegate: A command line tool to modify TUF-on-CI delegations"""

from __future__ import annotations

import copy
import logging
import os
16 changes: 10 additions & 6 deletions signer/tuf_on_ci_sign/import_repo.py
Original file line number Diff line number Diff line change
@@ -2,10 +2,11 @@

"""tuf-on-ci-import: A command line import tool for TUF-on-CI signing events"""

from __future__ import annotations

import json
import logging
import os
from glob import glob

import click
from tuf.api.metadata import Key, Role, Signed
@@ -138,11 +139,14 @@ def import_repo(verbose: int, push: bool, event_name: str, import_file: str | No
ok = True
# handle root and all target files, in order of delegations
roles = ["root", "targets"]
for filename in glob("*.json", root_dir=f"{toplevel}/metadata"):
rolename = filename[: -len(".json")]
if rolename in ["root", "timestamp", "snapshot", "targets"]:
continue
roles.append(rolename)
for _, _, filenames in os.walk(f"{toplevel}/metadata"):
for filename in filenames:
if not filename.endswith(".json"):
continue
rolename = filename[: -len(".json")]
if rolename in ["root", "timestamp", "snapshot", "targets"]:
continue
roles.append(rolename)

for rolename in roles:
if rolename not in import_data:

0 comments on commit ac1e1de

Please sign in to comment.