From e546cc95f14ba5a7f1fd3636f418beb2ecf78deb Mon Sep 17 00:00:00 2001 From: pulpbot Date: Sun, 7 Apr 2024 02:35:03 +0000 Subject: [PATCH 1/2] Update CI files [noissue] --- .ci/scripts/check_release.py | 44 ++++++++++++++++++++++++----- .ci/scripts/collect_changes.py | 9 ++++-- .github/template_gitref | 2 +- .github/workflows/nightly.yml | 2 +- .github/workflows/scripts/script.sh | 1 + doc_requirements.txt | 5 +++- docs/template_gitref | 2 +- lint_requirements.txt | 2 +- template_config.yml | 4 ++- 9 files changed, 56 insertions(+), 15 deletions(-) diff --git a/.ci/scripts/check_release.py b/.ci/scripts/check_release.py index a5dd8966..36052674 100755 --- a/.ci/scripts/check_release.py +++ b/.ci/scripts/check_release.py @@ -65,7 +65,7 @@ def main(): if branch != DEFAULT_BRANCH: # Check if a Z release is needed changes = repo.git.ls_tree("-r", "--name-only", f"origin/{branch}", "CHANGES/") - z_release = False + z_changelog = False for change in changes.split("\n"): # Check each changelog file to make sure everything checks out _, ext = os.path.splitext(change) @@ -75,18 +75,48 @@ def main(): f"{branch} release branch!" ) elif ext in Z_CHANGELOG_EXTS: - z_release = True - if z_release: + z_changelog = True + + last_tag = repo.git.describe("--tags", "--abbrev=0", f"origin/{branch}") + req_txt_diff = repo.git.diff( + f"{last_tag}", f"origin/{branch}", "--name-only", "--", "requirements.txt" + ) + if z_changelog or req_txt_diff: # Blobless clone does not have file contents for Z branches, # check commit message for last Z bump git_branch = f"origin/{branch}" - next_version = repo.git.log( - "--oneline", "--grep=Bump to", "-n 1", git_branch, "--", ".bumpversion.cfg" - ).split("to")[-1] + next_version = None + bump_commit = repo.git.log( + "--oneline", + "--grep=Bump version", + "-n 1", + git_branch, + "--", + ".bumpversion.cfg", + ) + if bump_commit: + next_version = bump_commit.split("→ ")[-1] + # If not found - try old-commit-msg + if not next_version: + bump_commit = repo.git.log( + "--oneline", + "--grep=Bump to", + "-n 1", + git_branch, + "--", + ".bumpversion.cfg", + ) + next_version = bump_commit.split("to ")[-1] if bump_commit else None + + # You could, theoretically, be next_vers==None here - but that's always + # been true for this script. next_version = Version(next_version) + reason = "CHANGES" if z_changelog else "requirements.txt" print( f"A Z-release is needed for {branch}, " - f"New Version: {next_version.base_version}" + f"Prev: {last_tag}, " + f"Next: {next_version.base_version}, " + f"Reason: {reason}" ) releases.append(next_version) else: diff --git a/.ci/scripts/collect_changes.py b/.ci/scripts/collect_changes.py index c2e4843a..39dcc6d2 100755 --- a/.ci/scripts/collect_changes.py +++ b/.ci/scripts/collect_changes.py @@ -11,7 +11,7 @@ import toml from git import GitCommandError, Repo -from pkg_resources import parse_version +from packaging.version import parse as parse_version # Read Towncrier settings tc_settings = toml.load("pyproject.toml")["tool"]["towncrier"] @@ -28,8 +28,12 @@ TITLE_FORMAT = tc_settings.get("title_format", "{name} {version} ({project_date})") +# Build a regex to find the header of a changelog section. +# It must have a single capture group to single out the version. +# see help(re.split) for more info. NAME_REGEX = r".*" -VERSION_REGEX = r"([0-9]+\.[0-9]+\.[0-9][0-9ab]*)" +VERSION_REGEX = r"[0-9]+\.[0-9]+\.[0-9][0-9ab]*" +VERSION_CAPTURE_REGEX = rf"({VERSION_REGEX})" DATE_REGEX = r"[0-9]{4}-[0-9]{2}-[0-9]{2}" TITLE_REGEX = ( "(" @@ -37,6 +41,7 @@ TITLE_FORMAT.format(name="NAME_REGEX", version="VERSION_REGEX", project_date="DATE_REGEX") ) .replace("NAME_REGEX", NAME_REGEX) + .replace("VERSION_REGEX", VERSION_CAPTURE_REGEX, 1) .replace("VERSION_REGEX", VERSION_REGEX) .replace("DATE_REGEX", DATE_REGEX) + ")" diff --git a/.github/template_gitref b/.github/template_gitref index 8b7135e4..9ec4e6fe 100644 --- a/.github/template_gitref +++ b/.github/template_gitref @@ -1 +1 @@ -2021.08.26-320-g4fd782b +2021.08.26-326-ge5addc7 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 11a96593..4872ae88 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -45,7 +45,7 @@ jobs: - name: "Install python dependencies" run: | echo ::group::PYDEPS - pip install gitpython toml + pip install gitpython packaging toml echo ::endgroup:: - name: "Configure Git with pulpbot name and email" diff --git a/.github/workflows/scripts/script.sh b/.github/workflows/scripts/script.sh index b3aca2cd..430ef0e6 100755 --- a/.github/workflows/scripts/script.sh +++ b/.github/workflows/scripts/script.sh @@ -31,6 +31,7 @@ if [[ "$TEST" = "docs" ]]; then if [[ "$GITHUB_WORKFLOW" == "Gem CI" ]]; then towncrier build --yes --version 4.0.0.ci fi + # Legacy Docs Build cd docs make PULP_URL="$PULP_URL" diagrams html tar -cvf docs.tar ./_build diff --git a/doc_requirements.txt b/doc_requirements.txt index a1002dba..5904df57 100644 --- a/doc_requirements.txt +++ b/doc_requirements.txt @@ -5,11 +5,14 @@ # # For more info visit https://github.com/pulp/plugin_template -r requirements.txt +towncrier + +# Legacy docs plantuml sphinx~=7.1.2 sphinx-rtd-theme==1.3.0 sphinxcontrib-jquery sphinxcontrib-openapi -towncrier mistune<4.0.0 Jinja2<3.2 +# Extra requirements diff --git a/docs/template_gitref b/docs/template_gitref index 8b7135e4..9ec4e6fe 100644 --- a/docs/template_gitref +++ b/docs/template_gitref @@ -1 +1 @@ -2021.08.26-320-g4fd782b +2021.08.26-326-ge5addc7 diff --git a/lint_requirements.txt b/lint_requirements.txt index 82422c2d..3c8129e7 100644 --- a/lint_requirements.txt +++ b/lint_requirements.txt @@ -6,7 +6,7 @@ # For more info visit https://github.com/pulp/plugin_template # python packages handy for developers, but not required by pulp -black==23.12.1 +black==24.3.0 check-manifest flake8 flake8-black diff --git a/template_config.yml b/template_config.yml index 51e32cf8..dbdde79c 100644 --- a/template_config.yml +++ b/template_config.yml @@ -1,7 +1,7 @@ # This config represents the latest values used when running the plugin-template. Any settings that # were not present before running plugin-template have been added with their default values. -# generated with plugin_template@2021.08.26-319-ga283c28 +# generated with plugin_template@2021.08.26-326-ge5addc7 api_root: /pulp/ black: true @@ -78,4 +78,6 @@ test_performance: false test_reroute: true test_s3: true use_issue_template: true +use_legacy_docs: true +use_unified_docs: false From cb4e7a25d30085b248b9085d1331753587c00b00 Mon Sep 17 00:00:00 2001 From: pulpbot Date: Sun, 7 Apr 2024 02:35:05 +0000 Subject: [PATCH 2/2] Reformat with black [noissue] --- .ci/scripts/schema.py | 1 + pulp_gem/tests/functional/api/test_crud_content_unit.py | 1 + pulp_gem/tests/functional/api/test_crud_remotes.py | 1 + pulp_gem/tests/functional/api/test_download_content.py | 1 + pulp_gem/tests/functional/api/test_publish.py | 1 + pulp_gem/tests/functional/api/test_sync.py | 1 + 6 files changed, 6 insertions(+) diff --git a/.ci/scripts/schema.py b/.ci/scripts/schema.py index 9f56caa6..91191c5e 100644 --- a/.ci/scripts/schema.py +++ b/.ci/scripts/schema.py @@ -7,6 +7,7 @@ But some pulp paths start with curly brackets e.g. {artifact_href} This script modifies drf-spectacular schema validation to accept slashes and curly brackets. """ + import json from drf_spectacular.validation import JSON_SCHEMA_SPEC_PATH diff --git a/pulp_gem/tests/functional/api/test_crud_content_unit.py b/pulp_gem/tests/functional/api/test_crud_content_unit.py index 0fb9ae4f..120a4e4b 100644 --- a/pulp_gem/tests/functional/api/test_crud_content_unit.py +++ b/pulp_gem/tests/functional/api/test_crud_content_unit.py @@ -1,4 +1,5 @@ """Tests that perform actions over content unit.""" + import pytest diff --git a/pulp_gem/tests/functional/api/test_crud_remotes.py b/pulp_gem/tests/functional/api/test_crud_remotes.py index 626daa66..58599cff 100644 --- a/pulp_gem/tests/functional/api/test_crud_remotes.py +++ b/pulp_gem/tests/functional/api/test_crud_remotes.py @@ -1,4 +1,5 @@ """Tests that CRUD gem remotes.""" + import pytest import uuid from random import choice diff --git a/pulp_gem/tests/functional/api/test_download_content.py b/pulp_gem/tests/functional/api/test_download_content.py index d256a8ee..0ff850e6 100644 --- a/pulp_gem/tests/functional/api/test_download_content.py +++ b/pulp_gem/tests/functional/api/test_download_content.py @@ -1,4 +1,5 @@ """Tests that verify download of content served by Pulp.""" + import pytest import hashlib from random import choice diff --git a/pulp_gem/tests/functional/api/test_publish.py b/pulp_gem/tests/functional/api/test_publish.py index 263ce2fb..22b05be1 100644 --- a/pulp_gem/tests/functional/api/test_publish.py +++ b/pulp_gem/tests/functional/api/test_publish.py @@ -1,4 +1,5 @@ """Tests that publish gem plugin repositories.""" + import pytest from random import choice diff --git a/pulp_gem/tests/functional/api/test_sync.py b/pulp_gem/tests/functional/api/test_sync.py index 15526695..81130180 100644 --- a/pulp_gem/tests/functional/api/test_sync.py +++ b/pulp_gem/tests/functional/api/test_sync.py @@ -1,4 +1,5 @@ """Tests that sync gem plugin repositories.""" + import pytest from pulp_gem.tests.functional.constants import (