Skip to content

Commit 9afd90b

Browse files
authored
Merge pull request #765 from pulp/update-ci/main
Update CI files for branch main
2 parents e4d1145 + ccc2ab6 commit 9afd90b

File tree

8 files changed

+94
-59
lines changed

8 files changed

+94
-59
lines changed

.bumpversion.cfg

Lines changed: 0 additions & 19 deletions
This file was deleted.

.ci/scripts/check_release.py

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
#!/usr/bin/env python
22

3-
# WARNING: DO NOT EDIT!
4-
#
5-
# This file was generated by plugin_template, and is managed by it. Please use
6-
# './plugin-template --github pulp_python' to update this file.
7-
#
8-
# For more info visit https://github.com/pulp/plugin_template
9-
103
import argparse
114
import re
125
import os
6+
import tomllib
137
import yaml
8+
from pathlib import Path
149
from tempfile import TemporaryDirectory
1510
from packaging.version import Version
1611
from git import Repo
1712

18-
UPSTREAM_REMOTE = "https://github.com/pulp/pulp_python.git"
19-
DEFAULT_BRANCH = "main"
2013
RELEASE_BRANCH_REGEX = r"^([0-9]+)\.([0-9]+)$"
2114
Y_CHANGELOG_EXTS = [".feature", ".removal", ".deprecation"]
2215
Z_CHANGELOG_EXTS = [".bugfix", ".doc", ".misc"]
2316

2417

25-
def main():
18+
def options():
2619
"""Check which branches need a release."""
2720
parser = argparse.ArgumentParser()
2821
parser.add_argument(
@@ -32,17 +25,57 @@ def main():
3225
"'supported'. Defaults to 'supported', see `supported_release_branches` in "
3326
"`plugin_template.yml`.",
3427
)
35-
opts = parser.parse_args()
28+
return parser.parse_args()
29+
30+
31+
def template_config():
32+
# Assume this script lies in .ci/scripts
33+
path = Path(__file__).absolute().parent.parent.parent / "template_config.yml"
34+
return yaml.safe_load(path.read_text())
35+
3636

37+
def current_version(repo, commitish):
38+
try:
39+
pyproject_toml = tomllib.loads(repo.git.show(f"{commitish}:pyproject.toml"))
40+
current_version = pyproject_toml["project"]["version"]
41+
except Exception:
42+
current_version = repo.git.grep(
43+
"current_version", commitish, "--", ".bumpversion.cfg"
44+
).split("=")[-1]
45+
return Version(current_version)
46+
47+
48+
def check_pyproject_dependencies(repo, from_commit, to_commit):
49+
try:
50+
old_pyproject = tomllib.load(repo.show("{from_commit}:pyproject.toml"))
51+
old_dependencies = set(old_pyproject["project"]["dependencies"])
52+
new_pyproject = tomllib.load(repo.show("{to_commit}:pyproject.toml"))
53+
new_dependencies = set(new_pyproject["project"]["dependencies"])
54+
if old_dependencies != new_dependencies:
55+
return ["dependencies"]
56+
else:
57+
return []
58+
except Exception as e:
59+
print(f"WARNING: Comparing the dependencies in pyproject.toml failed. ({e})")
60+
# Gathering more details failed.
61+
return ["pyproject.toml changed somehow (PLEASE check if dependencies are affected)."]
62+
63+
64+
def main(options, template_config):
3765
with TemporaryDirectory() as d:
3866
# Clone from upstream to ensure we have updated branches & main
67+
GITHUB_ORG = template_config["github_org"]
68+
PLUGIN_NAME = template_config["plugin_name"]
69+
UPSTREAM_REMOTE = f"https://github.com/{GITHUB_ORG}/{PLUGIN_NAME}.git"
70+
DEFAULT_BRANCH = template_config["plugin_default_branch"]
71+
3972
repo = Repo.clone_from(UPSTREAM_REMOTE, d, filter="blob:none")
4073
heads = [h.split("/")[-1] for h in repo.git.ls_remote("--heads").split("\n")]
4174
available_branches = [h for h in heads if re.search(RELEASE_BRANCH_REGEX, h)]
4275
available_branches.sort(key=lambda ver: Version(ver))
4376
available_branches.append(DEFAULT_BRANCH)
4477

45-
branches = opts.branches
78+
branches = options.branches
4679
if branches == "supported":
4780
with open(f"{d}/template_config.yml", mode="r") as f:
4881
tc = yaml.safe_load(f)
@@ -90,9 +123,7 @@ def main():
90123
f"{last_tag}", f"origin/{branch}", "--name-only", "--", "pyproject.toml"
91124
)
92125
if pyproject_diff:
93-
reasons.append(
94-
"pyproject.toml changed (PLEASE check if dependencies are affected."
95-
)
126+
reasons.extend(check_pyproject_dependencies(repo, last_tag, f"origin/{branch}"))
96127

97128
if reasons:
98129
curr_version = Version(last_tag)
@@ -113,15 +144,10 @@ def main():
113144
for change in changes.split("\n"):
114145
_, ext = os.path.splitext(change)
115146
if ext in Y_CHANGELOG_EXTS:
116-
# We don't put Y release bumps in the commit message, check file instead
117-
# The 'current_version' is always the next version to release
118-
next_version = repo.git.grep(
119-
"current_version", DEFAULT_BRANCH, "--", ".bumpversion.cfg"
120-
).split("=")[-1]
121-
next_version = Version(next_version)
122-
print(
123-
f"A new Y-release is needed! New Version: {next_version.base_version}"
124-
)
147+
# We don't put Y release bumps in the commit message, check file instead.
148+
# The 'current_version' is always the dev of the next version to release.
149+
next_version = current_version(repo, DEFAULT_BRANCH).base_version
150+
print(f"A new Y-release is needed! New Version: {next_version}")
125151
releases.append(next_version)
126152
break
127153

@@ -130,4 +156,4 @@ def main():
130156

131157

132158
if __name__ == "__main__":
133-
main()
159+
main(options(), template_config())

.ci/scripts/check_requirements.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ def main():
6262
else:
6363
if check_prereleases and req.specifier.prereleases:
6464
# Do not even think about begging for more exceptions!
65-
if (
66-
not req.name.startswith("opentelemetry")
67-
and req.name != "pulp-python-client"
68-
):
65+
if req.name != "pulp-python-client":
6966
errors.append(f"{filename}:{nr}: Prerelease versions found in {line}.")
7067
ops = [spec.operator for spec in req.specifier]
7168
if "~=" in ops:

.github/template_gitref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2021.08.26-393-g0e700c1
1+
2021.08.26-399-g78ad960

.github/workflows/scripts/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set -euv
1515

1616
source .github/workflows/scripts/utils.sh
1717

18-
PLUGIN_VERSION="$(sed -n -e 's/^\s*current_version\s*=\s*//p' .bumpversion.cfg | python -c 'from packaging.version import Version; print(Version(input()))')"
18+
PLUGIN_VERSION="$(bump-my-version show current_version | tail -n -1 | python -c 'from packaging.version import Version; print(Version(input()))')"
1919
PLUGIN_SOURCE="./pulp_python/dist/pulp_python-${PLUGIN_VERSION}-py3-none-any.whl"
2020

2121
export PULP_API_ROOT="/pulp/"

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
- name: "Install python dependencies"
7272
run: |
7373
echo ::group::PYDEPS
74-
pip install towncrier twine wheel httpie docker netaddr boto3 'ansible~=10.3.0' mkdocs jq jsonpatch
74+
pip install towncrier twine wheel httpie docker netaddr boto3 'ansible~=10.3.0' mkdocs jq jsonpatch bump-my-version
7575
echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/pulp_python/.ci/assets/httpie/" >> $GITHUB_ENV
7676
echo ::endgroup::
7777

.github/workflows/update_ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
with:
7070
fetch-depth: 0
7171
path: "pulp_python"
72-
ref: "3.12"
72+
ref: "3.11"
7373

7474
- name: "Run update"
7575
working-directory: "pulp_python"
@@ -83,15 +83,15 @@ jobs:
8383
path: "pulp_python"
8484
committer: "pulpbot <pulp-infra@redhat.com>"
8585
author: "pulpbot <pulp-infra@redhat.com>"
86-
title: "Update CI files for branch 3.12"
87-
branch: "update-ci/3.12"
88-
base: "3.12"
86+
title: "Update CI files for branch 3.11"
87+
branch: "update-ci/3.11"
88+
base: "3.11"
8989
delete-branch: true
9090
- uses: "actions/checkout@v4"
9191
with:
9292
fetch-depth: 0
9393
path: "pulp_python"
94-
ref: "3.11"
94+
ref: "3.12"
9595

9696
- name: "Run update"
9797
working-directory: "pulp_python"
@@ -105,8 +105,8 @@ jobs:
105105
path: "pulp_python"
106106
committer: "pulpbot <pulp-infra@redhat.com>"
107107
author: "pulpbot <pulp-infra@redhat.com>"
108-
title: "Update CI files for branch 3.11"
109-
branch: "update-ci/3.11"
110-
base: "3.11"
108+
title: "Update CI files for branch 3.12"
109+
branch: "update-ci/3.12"
110+
base: "3.12"
111111
delete-branch: true
112112
...

pyproject.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,34 @@ ignore = [
2828
"lint_requirements.txt",
2929
".flake8",
3030
]
31+
32+
[tool.bumpversion]
33+
# This section is managed by the plugin template. Do not edit manually.
34+
35+
current_version = "3.13.0.dev"
36+
commit = false
37+
tag = false
38+
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(\\.(?P<release>[a-z]+))?"
39+
serialize = [
40+
"{major}.{minor}.{patch}.{release}",
41+
"{major}.{minor}.{patch}",
42+
]
43+
44+
[tool.bumpversion.parts.release]
45+
# This section is managed by the plugin template. Do not edit manually.
46+
47+
optional_value = "prod"
48+
values = [
49+
"dev",
50+
"prod",
51+
]
52+
53+
[[tool.bumpversion.files]]
54+
# This section is managed by the plugin template. Do not edit manually.
55+
56+
filename = "./pulp_python/app/__init__.py"
57+
search = "version = \"{current_version}\""
58+
replace = "version = \"{new_version}\""
59+
60+
[[tool.bumpversion.files]]
61+
filename = "./setup.py"

0 commit comments

Comments
 (0)