Skip to content

Commit 810dcbe

Browse files
pulpbotgerrod3
authored andcommitted
Update CI files
1 parent 0921267 commit 810dcbe

File tree

8 files changed

+106
-71
lines changed

8 files changed

+106
-71
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_container' 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_container.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-container-client"
68-
):
65+
if req.name != "pulp-container-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_container/dist/pulp_container-${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_container/.ci/assets/httpie/" >> $GITHUB_ENV
7676
echo ::endgroup::
7777

.github/workflows/update_ci.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
with:
7070
fetch-depth: 0
7171
path: "pulp_container"
72-
ref: "2.22"
72+
ref: "2.14"
7373

7474
- name: "Run update"
7575
working-directory: "pulp_container"
@@ -83,15 +83,15 @@ jobs:
8383
path: "pulp_container"
8484
committer: "pulpbot <[email protected]>"
8585
author: "pulpbot <[email protected]>"
86-
title: "Update CI files for branch 2.22"
87-
branch: "update-ci/2.22"
88-
base: "2.22"
86+
title: "Update CI files for branch 2.14"
87+
branch: "update-ci/2.14"
88+
base: "2.14"
8989
delete-branch: true
9090
- uses: "actions/checkout@v4"
9191
with:
9292
fetch-depth: 0
9393
path: "pulp_container"
94-
ref: "2.14"
94+
ref: "2.15"
9595

9696
- name: "Run update"
9797
working-directory: "pulp_container"
@@ -105,15 +105,15 @@ jobs:
105105
path: "pulp_container"
106106
committer: "pulpbot <[email protected]>"
107107
author: "pulpbot <[email protected]>"
108-
title: "Update CI files for branch 2.14"
109-
branch: "update-ci/2.14"
110-
base: "2.14"
108+
title: "Update CI files for branch 2.15"
109+
branch: "update-ci/2.15"
110+
base: "2.15"
111111
delete-branch: true
112112
- uses: "actions/checkout@v4"
113113
with:
114114
fetch-depth: 0
115115
path: "pulp_container"
116-
ref: "2.15"
116+
ref: "2.16"
117117

118118
- name: "Run update"
119119
working-directory: "pulp_container"
@@ -127,15 +127,15 @@ jobs:
127127
path: "pulp_container"
128128
committer: "pulpbot <[email protected]>"
129129
author: "pulpbot <[email protected]>"
130-
title: "Update CI files for branch 2.15"
131-
branch: "update-ci/2.15"
132-
base: "2.15"
130+
title: "Update CI files for branch 2.16"
131+
branch: "update-ci/2.16"
132+
base: "2.16"
133133
delete-branch: true
134134
- uses: "actions/checkout@v4"
135135
with:
136136
fetch-depth: 0
137137
path: "pulp_container"
138-
ref: "2.16"
138+
ref: "2.20"
139139

140140
- name: "Run update"
141141
working-directory: "pulp_container"
@@ -149,15 +149,15 @@ jobs:
149149
path: "pulp_container"
150150
committer: "pulpbot <[email protected]>"
151151
author: "pulpbot <[email protected]>"
152-
title: "Update CI files for branch 2.16"
153-
branch: "update-ci/2.16"
154-
base: "2.16"
152+
title: "Update CI files for branch 2.20"
153+
branch: "update-ci/2.20"
154+
base: "2.20"
155155
delete-branch: true
156156
- uses: "actions/checkout@v4"
157157
with:
158158
fetch-depth: 0
159159
path: "pulp_container"
160-
ref: "2.20"
160+
ref: "2.22"
161161

162162
- name: "Run update"
163163
working-directory: "pulp_container"
@@ -171,8 +171,8 @@ jobs:
171171
path: "pulp_container"
172172
committer: "pulpbot <[email protected]>"
173173
author: "pulpbot <[email protected]>"
174-
title: "Update CI files for branch 2.20"
175-
branch: "update-ci/2.20"
176-
base: "2.20"
174+
title: "Update CI files for branch 2.22"
175+
branch: "update-ci/2.22"
176+
base: "2.22"
177177
delete-branch: true
178178
...

pyproject.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,34 @@ ignore = [
5151
"lint_requirements.txt",
5252
".flake8",
5353
]
54+
55+
[tool.bumpversion]
56+
# This section is managed by the plugin template. Do not edit manually.
57+
58+
current_version = "2.23.0.dev"
59+
commit = false
60+
tag = false
61+
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(\\.(?P<release>[a-z]+))?"
62+
serialize = [
63+
"{major}.{minor}.{patch}.{release}",
64+
"{major}.{minor}.{patch}",
65+
]
66+
67+
[tool.bumpversion.parts.release]
68+
# This section is managed by the plugin template. Do not edit manually.
69+
70+
optional_value = "prod"
71+
values = [
72+
"dev",
73+
"prod",
74+
]
75+
76+
[[tool.bumpversion.files]]
77+
# This section is managed by the plugin template. Do not edit manually.
78+
79+
filename = "./pulp_container/app/__init__.py"
80+
search = "version = \"{current_version}\""
81+
replace = "version = \"{new_version}\""
82+
83+
[[tool.bumpversion.files]]
84+
filename = "./setup.py"

0 commit comments

Comments
 (0)