Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump the pulp-cli requirement #95

Merged
merged 2 commits into from
Apr 30, 2024
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
21 changes: 0 additions & 21 deletions .bumpversion.cfg

This file was deleted.

20 changes: 16 additions & 4 deletions .ci/scripts/collect_changes.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/bin/env python3

import itertools
import os
import re
import tomllib

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

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

CHANGELOG_FILE = tc_settings.get("filename", "NEWS.rst")
START_STRING = tc_settings.get(
Expand All @@ -21,23 +24,32 @@
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 = (
"("
+ re.escape(
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)
+ ")"
)


def get_changelog(repo, branch):
return repo.git.show(f"{branch}:{CHANGELOG_FILE}") + "\n"
branch_tc_settings = tomllib.loads(repo.git.show(f"{branch}:pyproject.toml"))["tool"][
"towncrier"
]
branch_changelog_file = branch_tc_settings.get("filename", "NEWS.rst")
return repo.git.show(f"{branch}:{branch_changelog_file}") + "\n"


def _tokenize_changes(splits):
Expand Down
4 changes: 2 additions & 2 deletions .ci/scripts/create_release_branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ then
exit 1
fi

NEW_BRANCH="$(bump2version --dry-run --list release | sed -Ene 's/^new_version=([[:digit:]]+\.[[:digit:]]+)\..*$/\1/p')"
NEW_BRANCH="$(bump-my-version show new_version --increment release | sed -Ene 's/^([[:digit:]]+\.[[:digit:]]+)\.[[:digit:]]+$/\1/p')"

if [[ -z "${NEW_BRANCH}" ]]
then
Expand All @@ -23,6 +23,6 @@ git branch "${NEW_BRANCH}"
# Clean changelog snippets.
find CHANGES/ \( -name "*.feature" -o -name "*.bugfix" -o -name "*.removal" -o -name "*.doc" -o -name "*.translation" -o -name "*.devel" -o -name "*.misc" \) -exec git rm -f \{\} +

bump2version minor --commit --message $'Bump version to {new_version}\n\n[noissue]' --allow-dirty
bump-my-version bump minor --commit --message $'Bump version to {new_version}\n\n[noissue]' --allow-dirty

git push origin "${NEW_BRANCH}"
6 changes: 3 additions & 3 deletions .ci/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ then
exit 1
fi

NEW_VERSION="$(bump2version --dry-run --list release | sed -ne 's/^new_version=//p')"
NEW_VERSION="$(bump-my-version show new_version --increment release)"
echo "Release ${NEW_VERSION}"

if ! [[ "${NEW_VERSION}" == "${BRANCH}"* ]]
Expand All @@ -20,7 +20,7 @@ then
fi

towncrier build --yes --version "${NEW_VERSION}"
bump2version release --commit --message "Release {new_version}" --tag --tag-name "{new_version}" --tag-message "Release {new_version}" --allow-dirty
bump2version patch --commit
bump-my-version bump release --commit --message "Release {new_version}" --tag --tag-name "{new_version}" --tag-message "Release {new_version}" --allow-dirty
bump-my-version bump patch --commit

git push origin "${BRANCH}" "${NEW_VERSION}"
8 changes: 4 additions & 4 deletions .ci/scripts/validate_commit_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import re
import subprocess
import sys
import tomllib
from pathlib import Path

import toml
from github import Github

with open("pyproject.toml", "rb") as fp:
PYPROJECT_TOML = tomllib.load(fp)
KEYWORDS = ["fixes", "closes"]
BLOCKING_REGEX = [
"DRAFT",
Expand All @@ -16,9 +18,7 @@
"EXPERIMENT",
]
NO_ISSUE = "[noissue]"
CHANGELOG_EXTS = [
f".{item['directory']}" for item in toml.load("pyproject.toml")["tool"]["towncrier"]["type"]
]
CHANGELOG_EXTS = [f".{item['directory']}" for item in PYPROJECT_TOML["tool"]["towncrier"]["type"]]

sha = sys.argv[1]
message = subprocess.check_output(["git", "log", "--format=%B", "-n 1", sha]).decode("utf-8")
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/collect_changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
git config user.email [email protected]
- name: "Collect changes"
run: |
pip install GitPython packaging toml
pip install GitPython packaging
python3 .ci/scripts/collect_changes.py
- name: "Create Pull Request"
uses: "peter-evans/create-pull-request@v6"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install bump2version towncrier~=23.11.0
pip install bump-my-version~=0.20.0 towncrier~=23.11.0
- name: "Setup git"
run: |
git config user.name pulpbot
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
git config user.email [email protected]
- name: "Install python dependencies"
run: |
pip install bump2version
pip install bump-my-version~=0.20.0
- name: "Create Release Branch"
run: |
.ci/scripts/create_release_branch.sh
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ jobs:
fail-fast: false
matrix:
include:
- python: "3.11"
image_tag: "nightly"
- image_tag: "nightly"
pulp_api_root: "/relocated/djnd/"
- python: "3.8"
image_tag: "3.28"
python: "3.11"
- image_tag: "3.28"
lower_bounds: true
- python: "3.12"
image_tag: "3.26"
- python: "3.8"
image_tag: "3.25"
- python: "3.9"
image_tag: "3.24"
python: "3.8"
- image_tag: "3.26"
python: "3.12"
- image_tag: "3.25"
python: "3.8"
- image_tag: "3.24"
pulp_api_root: "/relocated/djnd/"
- python: "3.10"
image_tag: "3.35"
- python: "3.11"
image_tag: "latest"
python: "3.9"
- image_tag: "3.35"
python: "3.10"
- image_tag: "latest"
lower_bounds: true
python: "3.11"
Comment on lines -19 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right dictionaries sorted by keys for stability...
(should be the same as before otherwise.)

steps:
- uses: "actions/checkout@v4"
- uses: "actions/cache@v4"
Expand Down
7 changes: 5 additions & 2 deletions CHANGES/.TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@

{# TOWNCRIER TEMPLATE #}
{% for section, _ in sections.items() %}
{% if section %}### {{section}}
{%- set section_slug = "-" + section|replace(" ", "-")|replace("_", "-")|lower %}
{% if section %}### {{section}} {: #{{versiondata.version}}{{section_slug}} }

{% else %}
{%- set section_slug = "" %}
{% endif %}

{% if sections[section] %}
{% for category, val in definitions.items() if category in sections[section]%}
#### {{ definitions[category]['name'] }}
#### {{ definitions[category]['name'] }} {: #{{versiondata.version}}{{section_slug}}-{{category}} }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While being a good change, this may or may not lead to a one time hickup when collecting changelogs from previous branches.
At this time, just something to keep an eye on.


{% if definitions[category]['showcontent'] %}
{% for text, values in sections[section][category].items() %}
Expand Down
4 changes: 2 additions & 2 deletions lower_bounds_constraints.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pulp-cli==0.20.0
pulp-glue==0.20.0
pulp-cli==0.23.1
pulp-glue==0.23.1
click==8.0.0
2 changes: 1 addition & 1 deletion pulp-glue-ostree/pulp_glue/ostree/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.0.dev"
__version__ = "0.4.0.dev"
38 changes: 24 additions & 14 deletions pulp-glue-ostree/pulp_glue/ostree/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,50 @@
PulpRemoteContext,
PulpRepositoryContext,
PulpRepositoryVersionContext,
registered_repository_contexts,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

)


class PulpOstreeCommitContentContext(PulpContentContext):
PLUGIN = "ostree"
RESOURCE_TYPE = "commit"
Comment on lines +16 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

ENTITY = _("commit content")
ENTITIES = _("commit content")
HREF = "ostree_ostree_commit_href"
ID_PREFIX = "content_ostree_commits"
NEEDS_PLUGINS = [PluginRequirement("ostree", min="2.0.0")]
NEEDS_PLUGINS = [PluginRequirement("ostree", specifier=">=2.0.0")]
Comment on lines -21 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍



class PulpOstreeRefContentContext(PulpContentContext):
PLUGIN = "ostree"
RESOURCE_TYPE = "ref"
ENTITY = _("ref content")
ENTITIES = _("ref content")
HREF = "ostree_ostree_ref_href"
ID_PREFIX = "content_ostree_refs"
NEEDS_PLUGINS = [PluginRequirement("ostree", min="2.0.0")]
NEEDS_PLUGINS = [PluginRequirement("ostree", specifier=">=2.0.0")]


class PulpOstreeConfigContentContext(PulpContentContext):
PLUGIN = "ostree"
RESOURCE_TYPE = "config"
ENTITY = _("config content")
ENTITIES = _("config content")
HREF = "ostree_ostree_config_href"
ID_PREFIX = "content_ostree_configs"
NEEDS_PLUGINS = [PluginRequirement("ostree", min="2.0.0")]
NEEDS_PLUGINS = [PluginRequirement("ostree", specifier=">=2.0.0")]


class PulpOstreeDistributionContext(PulpEntityContext):
PLUGIN = "ostree"
RESOURCE_TYPE = "ostree"
ENTITY = _("ostree distribution")
ENTITIES = _("ostree distributions")
HREF = "ostree_ostree_distribution_href"
ID_PREFIX = "distributions_ostree_ostree"
NEEDS_PLUGINS = [PluginRequirement("ostree", min="2.0.0")]
NEEDS_PLUGINS = [PluginRequirement("ostree", specifier=">=2.0.0")]

def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:
body = super().preprocess_body(body)
def preprocess_entity(self, body: EntityDefinition, partial: bool = False) -> EntityDefinition:
body = super().preprocess_entity(body, partial)
Comment on lines +54 to +55
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

version = body.pop("version", None)
if version is not None:
repository_href = body.pop("repository")
Expand All @@ -54,29 +61,35 @@ def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:


class PulpOstreeRemoteContext(PulpRemoteContext):
PLUGIN = "ostree"
RESOURCE_TYPE = "ostree"
ENTITY = _("ostree remote")
ENTITIES = _("ostree remotes")
HREF = "ostree_ostree_remote_href"
ID_PREFIX = "remotes_ostree_ostree"
NEEDS_PLUGINS = [PluginRequirement("ostree", min="2.0.0")]
NEEDS_PLUGINS = [PluginRequirement("ostree", specifier=">=2.0.0")]


class PulpOstreeRepositoryVersionContext(PulpRepositoryVersionContext):
PLUGIN = "ostree"
RESOURCE_TYPE = "ostree"
HREF = "ostree_ostree_repository_version_href"
ID_PREFIX = "repositories_ostree_ostree_versions"
NEEDS_PLUGINS = [PluginRequirement("ostree", min="2.0.0")]
NEEDS_PLUGINS = [PluginRequirement("ostree", specifier=">=2.0.0")]


class PulpOstreeRepositoryContext(PulpRepositoryContext):
PLUGIN = "ostree"
RESOURCE_TYPE = "ostree"
HREF = "ostree_ostree_repository_href"
ID_PREFIX = "repositories_ostree_ostree"
IMPORT_ALL_ID: ClassVar[str] = "repositories_ostree_ostree_import_all"
IMPORT_COMMITS_ID: ClassVar[str] = "repositories_ostree_ostree_import_commits"
VERSION_CONTEXT = PulpOstreeRepositoryVersionContext
NEEDS_PLUGINS = [PluginRequirement("ostree", min="2.0.0")]
NEEDS_PLUGINS = [PluginRequirement("ostree", specifier=">=2.0.0")]
CAPABILITIES = {
"sync": [PluginRequirement("ostree")],
"import_all": [PluginRequirement("ostree", min="2.0.0")],
"import_all": [PluginRequirement("ostree", specifier=">=2.0.0")],
"import_commits": [PluginRequirement("ostree")],
}

Expand Down Expand Up @@ -110,6 +123,3 @@ def import_commits(
parameters={self.HREF: href},
body=body,
)


registered_repository_contexts["ostree:ostree"] = PulpOstreeRepositoryContext
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

2 changes: 1 addition & 1 deletion pulp-glue-ostree/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [
"Typing :: Typed",
]
dependencies = [
"pulp-glue>=0.20.0,<0.26",
"pulp-glue>=0.23.1,<0.26",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change. Make sure you do not backport, but release a new y with this.

]

[project.urls]
Expand Down
4 changes: 4 additions & 0 deletions pulpcore/cli/ostree/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from typing import Any

import click
from pulp_glue.common.i18n import get_translation
from pulpcore.cli.common.generic import pulp_group

from pulpcore.cli.ostree.distribution import distribution
from pulpcore.cli.ostree.remote import remote
from pulpcore.cli.ostree.repository import repository

translation = get_translation(__package__)
_ = translation.gettext
Comment on lines +11 to +12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically not needed, but I'm looking forward to the slovakian translation files. ;)


__version__ = "0.4.0.dev"


Expand Down
Loading
Loading