From e62d7b15b5bc18c9711fffec43cd316763728737 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Thu, 23 Apr 2026 12:08:16 +0200 Subject: [PATCH] EXP Update CI --- .ci/ansible/filter/repr.py | 1 + .ci/scripts/calc_constraints.py | 5 +++-- .ci/scripts/check_gettext.sh | 21 ------------------- .ci/scripts/check_release.py | 4 ++-- .ci/scripts/check_requirements.py | 2 +- .ci/scripts/collect_changes.py | 1 - .ci/scripts/schema.py | 1 + .ci/scripts/skip_tests.py | 7 ++++--- .ci/scripts/update_github.py | 1 + .ci/scripts/validate_commit_message.py | 2 +- .github/workflows/lint.yml | 6 +----- .../stage-changelog-for-default-branch.py | 1 - .../scripts/update_backport_labels.py | 5 +++-- Makefile | 21 +++++++++++++++++++ pulp_gem/app/models.py | 4 ++-- pulp_gem/app/replica.py | 4 ++-- pulp_gem/app/serializers.py | 8 +++---- pulp_gem/app/tasks/publishing.py | 7 +++---- pulp_gem/app/tasks/synchronizing.py | 5 ++--- pulp_gem/app/viewsets.py | 18 ++++++++-------- pulp_gem/pytest_plugin.py | 2 ++ pulp_gem/specs.py | 13 ++++++------ .../tests/functional/api/test_crud_remotes.py | 3 ++- .../functional/api/test_download_content.py | 3 ++- pulp_gem/tests/functional/api/test_publish.py | 3 ++- .../tests/functional/api/test_pull_through.py | 3 ++- .../tests/functional/api/test_replicate.py | 3 ++- pulp_gem/tests/functional/api/test_sync.py | 5 +++-- pulp_gem/tests/unit/test_serializers.py | 7 ++++--- pyproject.toml | 18 ++++++++++++++++ template_config.yml | 2 -- 31 files changed, 103 insertions(+), 83 deletions(-) delete mode 100755 .ci/scripts/check_gettext.sh create mode 100644 Makefile diff --git a/.ci/ansible/filter/repr.py b/.ci/ansible/filter/repr.py index 8455c344..c8c1678d 100644 --- a/.ci/ansible/filter/repr.py +++ b/.ci/ansible/filter/repr.py @@ -1,4 +1,5 @@ from __future__ import absolute_import, division, print_function + from packaging.version import parse as parse_version __metaclass__ = type diff --git a/.ci/scripts/calc_constraints.py b/.ci/scripts/calc_constraints.py index f6e3500b..c089dc2d 100755 --- a/.ci/scripts/calc_constraints.py +++ b/.ci/scripts/calc_constraints.py @@ -7,11 +7,12 @@ import argparse import fileinput -import urllib.request import sys +import urllib.request + +import yaml from packaging.requirements import Requirement from packaging.version import Version -import yaml try: import tomllib diff --git a/.ci/scripts/check_gettext.sh b/.ci/scripts/check_gettext.sh deleted file mode 100755 index 5d03d3eb..00000000 --- a/.ci/scripts/check_gettext.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# WARNING: DO NOT EDIT! -# -# This file was generated by plugin_template, and is managed by it. Please use -# './plugin-template --github pulp_gem' to update this file. -# -# For more info visit https://github.com/pulp/plugin_template - -# make sure this script runs at the repo root -cd "$(dirname "$(realpath -e "$0")")"/../.. - -set -u - -MATCHES="$(grep -n -r --include \*.py "_(f" pulp_gem )" - -if [ $? -ne 1 ]; then - printf "\nERROR: Detected mix of f-strings and gettext:\n" - echo "$MATCHES" - exit 1 -fi diff --git a/.ci/scripts/check_release.py b/.ci/scripts/check_release.py index 1bb1f067..0825480e 100755 --- a/.ci/scripts/check_release.py +++ b/.ci/scripts/check_release.py @@ -9,16 +9,16 @@ # /// import argparse -import re import os +import re import sys import tomllib import typing as t from pathlib import Path import yaml -from packaging.version import Version from git import Repo +from packaging.version import Version RELEASE_BRANCH_REGEX = r"^([0-9]+)\.([0-9]+)$" Y_CHANGELOG_EXTS = [".feature"] diff --git a/.ci/scripts/check_requirements.py b/.ci/scripts/check_requirements.py index f38660a9..ca8cd9dd 100755 --- a/.ci/scripts/check_requirements.py +++ b/.ci/scripts/check_requirements.py @@ -7,8 +7,8 @@ import tomllib import warnings -from packaging.requirements import Requirement +from packaging.requirements import Requirement CHECK_MATRIX = [ ("pyproject.toml", True, True, True), diff --git a/.ci/scripts/collect_changes.py b/.ci/scripts/collect_changes.py index c9aeb93c..c319dabc 100755 --- a/.ci/scripts/collect_changes.py +++ b/.ci/scripts/collect_changes.py @@ -25,7 +25,6 @@ from git import GitCommandError, Repo from packaging.version import parse as parse_version - PYPI_PROJECT = "pulp_gem" # Read Towncrier settings diff --git a/.ci/scripts/schema.py b/.ci/scripts/schema.py index 91191c5e..9c8e11b2 100644 --- a/.ci/scripts/schema.py +++ b/.ci/scripts/schema.py @@ -9,6 +9,7 @@ """ import json + from drf_spectacular.validation import JSON_SCHEMA_SPEC_PATH with open(JSON_SCHEMA_SPEC_PATH) as fh: diff --git a/.ci/scripts/skip_tests.py b/.ci/scripts/skip_tests.py index a68d000d..380a3da9 100755 --- a/.ci/scripts/skip_tests.py +++ b/.ci/scripts/skip_tests.py @@ -15,12 +15,13 @@ *: Error """ -import sys +import argparse import os import re -import git +import sys import textwrap -import argparse + +import git DOC_PATTERNS = [ r"^docs/", diff --git a/.ci/scripts/update_github.py b/.ci/scripts/update_github.py index 2b87d8b4..51b65661 100755 --- a/.ci/scripts/update_github.py +++ b/.ci/scripts/update_github.py @@ -6,6 +6,7 @@ # For more info visit https://github.com/pulp/plugin_template import os + from github import Github g = Github(os.environ.get("GITHUB_TOKEN")) diff --git a/.ci/scripts/validate_commit_message.py b/.ci/scripts/validate_commit_message.py index a4dc9004..2aab9085 100644 --- a/.ci/scripts/validate_commit_message.py +++ b/.ci/scripts/validate_commit_message.py @@ -6,9 +6,9 @@ import subprocess import sys import tomllib -import yaml from pathlib import Path +import yaml from github import Github diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e44c10ef..4c74d9da 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -42,11 +42,7 @@ jobs: - name: "Lint code" run: | - ruff check --diff - - - name: "Check for common gettext problems" - run: | - sh .ci/scripts/check_gettext.sh + ruff check - name: "Run extra lint checks" run: | diff --git a/.github/workflows/scripts/stage-changelog-for-default-branch.py b/.github/workflows/scripts/stage-changelog-for-default-branch.py index a66697ac..9676f8c5 100755 --- a/.github/workflows/scripts/stage-changelog-for-default-branch.py +++ b/.github/workflows/scripts/stage-changelog-for-default-branch.py @@ -12,7 +12,6 @@ from git import Repo from git.exc import GitCommandError - helper = textwrap.dedent( """\ Stage the changelog for a release on main branch. diff --git a/.github/workflows/scripts/update_backport_labels.py b/.github/workflows/scripts/update_backport_labels.py index e4566564..c6663d0d 100755 --- a/.github/workflows/scripts/update_backport_labels.py +++ b/.github/workflows/scripts/update_backport_labels.py @@ -5,10 +5,11 @@ # # For more info visit https://github.com/pulp/plugin_template +import os +import random + import requests import yaml -import random -import os def random_color(): diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..c1115493 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by it. Please use +# './plugin-template --ci pulp_gem' to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +.PHONY: format +format: + ruff format + ruff check --select I --fix + +.PHONY: lint +lint: + yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows + bump-my-version bump --dry-run --allow-dirty release + ruff format --check --diff + ruff check + check-manifest + python .ci/scripts/check_requirements.py + sh .ci/scripts/check_pulpcore_imports.sh diff --git a/pulp_gem/app/models.py b/pulp_gem/app/models.py index 3b04980f..38d6b001 100644 --- a/pulp_gem/app/models.py +++ b/pulp_gem/app/models.py @@ -1,15 +1,15 @@ from logging import getLogger - from pathlib import PurePath from tempfile import NamedTemporaryFile + from django.contrib.postgres.fields import HStoreField from django.db import models from pulpcore.plugin.models import ( AutoAddObjPermsMixin, Content, - Publication, Distribution, + Publication, Remote, Repository, ) diff --git a/pulp_gem/app/replica.py b/pulp_gem/app/replica.py index 3d91dba5..2abf169a 100644 --- a/pulp_gem/app/replica.py +++ b/pulp_gem/app/replica.py @@ -1,11 +1,11 @@ -from pulpcore.plugin.replica import Replicator - from pulp_glue.gem.context import ( PulpGemDistributionContext, PulpGemPublicationContext, PulpGemRepositoryContext, ) +from pulpcore.plugin.replica import Replicator + from pulp_gem.app.models import GemDistribution, GemRemote, GemRepository from pulp_gem.app.tasks import synchronize as gem_synchronize diff --git a/pulp_gem/app/serializers.py b/pulp_gem/app/serializers.py index 945e49ee..d1ce4133 100644 --- a/pulp_gem/app/serializers.py +++ b/pulp_gem/app/serializers.py @@ -1,8 +1,7 @@ -from gettext import gettext as _ -import tempfile - import hashlib import os +import tempfile +from gettext import gettext as _ from django.db import DatabaseError from rest_framework.serializers import ( @@ -16,9 +15,9 @@ from pulpcore.plugin.serializers import ( ArtifactSerializer, DetailRelatedField, + DistributionSerializer, MultipleArtifactContentSerializer, PublicationSerializer, - DistributionSerializer, RemoteSerializer, RepositorySerializer, SingleContentArtifactField, @@ -33,7 +32,6 @@ GemRemote, GemRepository, ) - from pulp_gem.specs import analyse_gem diff --git a/pulp_gem/app/tasks/publishing.py b/pulp_gem/app/tasks/publishing.py index 87867752..47411225 100644 --- a/pulp_gem/app/tasks/publishing.py +++ b/pulp_gem/app/tasks/publishing.py @@ -4,24 +4,23 @@ import logging import os import shutil - from gettext import gettext as _ +from pathlib import Path from django.conf import settings from django.core.files import File from django.db import transaction from jinja2 import Template -from pathlib import Path from pulpcore.plugin.models import ( ContentArtifact, - RepositoryVersion, PublishedArtifact, PublishedMetadata, + RepositoryVersion, ) from pulp_gem.app.models import GemContent, GemPublication -from pulp_gem.specs import ruby_ver_cmp, write_specs, GemKey +from pulp_gem.specs import GemKey, ruby_ver_cmp, write_specs log = logging.getLogger(__name__) diff --git a/pulp_gem/app/tasks/synchronizing.py b/pulp_gem/app/tasks/synchronizing.py index 42aa71f4..fc45f9e7 100644 --- a/pulp_gem/app/tasks/synchronizing.py +++ b/pulp_gem/app/tasks/synchronizing.py @@ -1,9 +1,8 @@ import logging - -from aiohttp import ClientConnectionError from gettext import gettext as _ from urllib.parse import urljoin +from aiohttp import ClientConnectionError from django.conf import settings from pulpcore.plugin.models import Artifact, ProgressReport, Remote, Repository @@ -18,8 +17,8 @@ from pulp_gem.specs import ( NAME_REGEX, PRERELEASE_VERSION_REGEX, - read_versions, read_info, + read_versions, ruby_ver_includes, split_ext_version, ) diff --git a/pulp_gem/app/viewsets.py b/pulp_gem/app/viewsets.py index 798fe5a9..19540191 100644 --- a/pulp_gem/app/viewsets.py +++ b/pulp_gem/app/viewsets.py @@ -2,29 +2,29 @@ from rest_framework.decorators import action from pulpcore.plugin.actions import ModifyRepositoryActionMixin +from pulpcore.plugin.serializers import ( + AsyncOperationResponseSerializer, + RepositorySyncURLSerializer, +) +from pulpcore.plugin.tasking import dispatch from pulpcore.plugin.viewsets import ( - DistributionViewSet, ContentFilter, - SingleArtifactContentUploadViewSet, + DistributionViewSet, OperationPostponedResponse, PublicationViewSet, RemoteViewSet, - RepositoryViewSet, RepositoryVersionViewSet, + RepositoryViewSet, RolesMixin, + SingleArtifactContentUploadViewSet, ) -from pulpcore.plugin.serializers import ( - AsyncOperationResponseSerializer, - RepositorySyncURLSerializer, -) -from pulpcore.plugin.tasking import dispatch from pulp_gem.app import tasks from pulp_gem.app.models import ( GemContent, GemDistribution, - GemRemote, GemPublication, + GemRemote, GemRepository, ) from pulp_gem.app.serializers import ( diff --git a/pulp_gem/pytest_plugin.py b/pulp_gem/pytest_plugin.py index d16b0b67..b35e9bf5 100644 --- a/pulp_gem/pytest_plugin.py +++ b/pulp_gem/pytest_plugin.py @@ -1,7 +1,9 @@ import uuid import pytest + from pulpcore.tests.functional.utils import BindingsNamespace + from pulp_gem.tests.functional.constants import GEM_FIXTURE_URL, GEM_URL # Api Bindings fixtures diff --git a/pulp_gem/specs.py b/pulp_gem/specs.py index 16fb5741..76e12743 100644 --- a/pulp_gem/specs.py +++ b/pulp_gem/specs.py @@ -1,18 +1,17 @@ -from collections import namedtuple -from logging import getLogger - -import aiofiles import datetime -import zlib import gzip import re -import yaml +import zlib +from collections import namedtuple from itertools import zip_longest +from logging import getLogger from tarfile import TarFile +import aiofiles import rubymarshal.classes -import rubymarshal.writer import rubymarshal.reader +import rubymarshal.writer +import yaml log = getLogger(__name__) diff --git a/pulp_gem/tests/functional/api/test_crud_remotes.py b/pulp_gem/tests/functional/api/test_crud_remotes.py index ec5634a0..6b01a945 100644 --- a/pulp_gem/tests/functional/api/test_crud_remotes.py +++ b/pulp_gem/tests/functional/api/test_crud_remotes.py @@ -1,11 +1,12 @@ """Tests that CRUD gem remotes.""" -import pytest import uuid from random import choice +import pytest from pulpcore.client.pulp_gem import ApiException + from pulp_gem.tests.functional.constants import DOWNLOAD_POLICIES, GEM_FIXTURE_URL diff --git a/pulp_gem/tests/functional/api/test_download_content.py b/pulp_gem/tests/functional/api/test_download_content.py index b89bcb3f..01ac2974 100644 --- a/pulp_gem/tests/functional/api/test_download_content.py +++ b/pulp_gem/tests/functional/api/test_download_content.py @@ -1,10 +1,11 @@ """Tests that verify download of content served by Pulp.""" -import pytest import hashlib from random import choice from urllib.parse import urljoin +import pytest + from pulp_gem.tests.functional.constants import DOWNLOAD_POLICIES, GEM_FIXTURE_URL diff --git a/pulp_gem/tests/functional/api/test_publish.py b/pulp_gem/tests/functional/api/test_publish.py index 9f871277..bde7f98c 100644 --- a/pulp_gem/tests/functional/api/test_publish.py +++ b/pulp_gem/tests/functional/api/test_publish.py @@ -1,8 +1,9 @@ """Tests that publish gem plugin repositories.""" -import pytest from random import choice +import pytest + @pytest.mark.parallel def test_publish( diff --git a/pulp_gem/tests/functional/api/test_pull_through.py b/pulp_gem/tests/functional/api/test_pull_through.py index 51c55e91..49fe498f 100644 --- a/pulp_gem/tests/functional/api/test_pull_through.py +++ b/pulp_gem/tests/functional/api/test_pull_through.py @@ -1,5 +1,6 @@ -import pytest import subprocess + +import pytest from aiohttp.client_exceptions import ClientResponseError diff --git a/pulp_gem/tests/functional/api/test_replicate.py b/pulp_gem/tests/functional/api/test_replicate.py index 26f74800..28d9947d 100644 --- a/pulp_gem/tests/functional/api/test_replicate.py +++ b/pulp_gem/tests/functional/api/test_replicate.py @@ -1,6 +1,7 @@ -import pytest import uuid +import pytest + @pytest.mark.parallel def test_replication( diff --git a/pulp_gem/tests/functional/api/test_sync.py b/pulp_gem/tests/functional/api/test_sync.py index aa0348e7..566fe482 100644 --- a/pulp_gem/tests/functional/api/test_sync.py +++ b/pulp_gem/tests/functional/api/test_sync.py @@ -2,13 +2,14 @@ import pytest +from pulpcore.tests.functional.utils import PulpTaskError + from pulp_gem.tests.functional.constants import ( DOWNLOAD_POLICIES, GEM_FIXTURE_SUMMARY, - GEM_INVALID_FIXTURE_URL, GEM_FIXTURE_URL, + GEM_INVALID_FIXTURE_URL, ) -from pulpcore.tests.functional.utils import PulpTaskError @pytest.fixture diff --git a/pulp_gem/tests/unit/test_serializers.py b/pulp_gem/tests/unit/test_serializers.py index 39c3798d..ad19ba7b 100644 --- a/pulp_gem/tests/unit/test_serializers.py +++ b/pulp_gem/tests/unit/test_serializers.py @@ -1,12 +1,13 @@ from unittest.mock import patch -from django.test import TestCase + from django.conf import settings from django.core.files.uploadedfile import SimpleUploadedFile - -from pulp_gem.app.serializers import GemContentSerializer +from django.test import TestCase from pulpcore.plugin.models import Artifact +from pulp_gem.app.serializers import GemContentSerializer + CHECKSUM_LEN = { "md5": 32, "sha1": 40, diff --git a/pyproject.toml b/pyproject.toml index 61f57497..e891ba0d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -145,3 +145,21 @@ extend-exclude = [ "docs/**", "**/migrations/*.py", ] + +[tool.ruff.lint] +# This section is managed by the plugin template. Do not edit manually. +extend-select = [ + "I", + "INT", + "TID", + "T10", +] + +[tool.ruff.lint.flake8-tidy-imports.banned-api] +# This section is managed by the plugin template. Do not edit manually. +"pulpcore.app".msg = "The 'pulpcore' apis must only be consumed via 'pulpcore.plugin'." + +[tool.ruff.lint.isort] +# This section is managed by the plugin template. Do not edit manually. +sections = { second-party = ["pulpcore"] } +section-order = ["future", "standard-library", "third-party", "second-party", "first-party", "local-folder"] diff --git a/template_config.yml b/template_config.yml index c80e879e..273cd725 100644 --- a/template_config.yml +++ b/template_config.yml @@ -7,7 +7,6 @@ --- check_commit_message: true -check_gettext: true check_manifest: true check_stray_pulpcore_imports: true ci_base_image: "ghcr.io/pulp/pulp-ci-centos9" @@ -108,4 +107,3 @@ test_performance: false test_s3: true use_issue_template: true ... -