Skip to content

Commit 639d808

Browse files
pulpbotmdellweg
authored andcommitted
Update CI files
1 parent 523faa7 commit 639d808

22 files changed

+239
-134
lines changed

.bumpversion.cfg

-21
This file was deleted.

.ci/ansible/Containerfile.j2

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ RUN pip3 install --upgrade pip setuptools wheel && \
2828
{{ " " }}-r ./{{ item.name }}/ci_requirements.txt
2929
{%- endif -%}
3030
{%- endfor %}
31-
{{ " " }}-c ./{{ plugins[0].name }}/.ci/assets/ci_constraints.txt \
32-
pipdeptree && \
31+
{{ " " }}-c ./{{ plugins[0].name }}/.ci/assets/ci_constraints.txt && \
3332
rm -rf /root/.cache/pip
3433

3534
{% if pulp_env is defined and pulp_env %}

.ci/assets/ci_constraints.txt

-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,3 @@ pulpcore>=3.21.30,!=3.23.*,!=3.24.*,!=3.25.*,!=3.26.*,!=3.27.*,!=3.29.*,!=3.30.*
55

66
tablib!=3.6.0
77
# 3.6.0: This release introduced a regression removing the "html" optional dependency.
8-
9-
10-
11-
# Newer version seem to have a conflict around packaging, that pip fails to resolve in time. Remove this when this starts to impose an issue.
12-
pipdeptree<=3.23.1

.ci/assets/release_requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
bump2version
1+
bump-my-version
22
gitpython
33
towncrier

.ci/scripts/calc_constraints.py

+33-14
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
from packaging.version import Version
1414
import yaml
1515

16+
try:
17+
import tomllib
18+
except ImportError:
19+
import tomli as tomllib
20+
1621

1722
CORE_TEMPLATE_URL = "https://raw.githubusercontent.com/pulp/pulpcore/main/template_config.yml"
1823

@@ -59,11 +64,11 @@ def to_upper_bound(req):
5964
operator = "~="
6065
version = Version(spec.version)
6166
if version.micro != 0:
62-
max_version = f"{version.major}.{version.minor}.{version.micro-1}"
67+
max_version = f"{version.major}.{version.minor}.{version.micro - 1}"
6368
elif version.minor != 0:
64-
max_version = f"{version.major}.{version.minor-1}"
69+
max_version = f"{version.major}.{version.minor - 1}"
6570
elif version.major != 0:
66-
max_version = f"{version.major-1}.0"
71+
max_version = f"{version.major - 1}.0"
6772
else:
6873
return f"# NO BETTER CONSTRAINT: {req}"
6974
return f"{requirement.name}{operator}{max_version}"
@@ -100,18 +105,32 @@ def main():
100105
parser.add_argument("filename", nargs="*")
101106
args = parser.parse_args()
102107

103-
with fileinput.input(files=args.filename) as req_file:
104-
for line in req_file:
105-
if line.strip().startswith("#"):
106-
# Shortcut comment only lines
107-
print(line.strip())
108-
else:
109-
req, comment = split_comment(line)
110-
if args.upper:
111-
new_req = to_upper_bound(req)
108+
modifier = to_upper_bound if args.upper else to_lower_bound
109+
110+
req_files = [filename for filename in args.filename if not filename.endswith("pyproject.toml")]
111+
pyp_files = [filename for filename in args.filename if filename.endswith("pyproject.toml")]
112+
if req_files:
113+
with fileinput.input(files=req_files) as req_file:
114+
for line in req_file:
115+
if line.strip().startswith("#"):
116+
# Shortcut comment only lines
117+
print(line.strip())
112118
else:
113-
new_req = to_lower_bound(req)
114-
print(new_req + comment)
119+
req, comment = split_comment(line)
120+
new_req = modifier(req)
121+
print(new_req + comment)
122+
for filename in pyp_files:
123+
with open(filename, "rb") as fp:
124+
pyproject = tomllib.load(fp)
125+
for req in pyproject["project"]["dependencies"]:
126+
new_req = modifier(req)
127+
print(new_req)
128+
optional_dependencies = pyproject["project"].get("optional-dependencies")
129+
if optional_dependencies:
130+
for opt in optional_dependencies.values():
131+
for req in opt:
132+
new_req = modifier(req)
133+
print(new_req)
115134

116135

117136
if __name__ == "__main__":

.ci/scripts/check_release.py

+58-22
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_npm' 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_npm.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,60 @@ 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+
try:
41+
current_version = pyproject_toml["project"]["version"]
42+
except Exception:
43+
current_version = pyproject_toml["tool"]["bumpversion"]["current_version"]
44+
except Exception:
45+
current_version = repo.git.grep(
46+
"current_version", commitish, "--", ".bumpversion.cfg"
47+
).split("=")[-1]
48+
return Version(current_version)
49+
50+
51+
def check_pyproject_dependencies(repo, from_commit, to_commit):
52+
try:
53+
old_pyproject = tomllib.load(repo.show("{from_commit}:pyproject.toml"))
54+
old_dependencies = set(old_pyproject["project"]["dependencies"])
55+
new_pyproject = tomllib.load(repo.show("{to_commit}:pyproject.toml"))
56+
new_dependencies = set(new_pyproject["project"]["dependencies"])
57+
if old_dependencies != new_dependencies:
58+
return ["dependencies"]
59+
else:
60+
return []
61+
except Exception as e:
62+
print(f"WARNING: Comparing the dependencies in pyproject.toml failed. ({e})")
63+
# Gathering more details failed.
64+
return ["pyproject.toml changed somehow (PLEASE check if dependencies are affected)."]
65+
66+
67+
def main(options, template_config):
3768
with TemporaryDirectory() as d:
3869
# Clone from upstream to ensure we have updated branches & main
70+
GITHUB_ORG = template_config["github_org"]
71+
PLUGIN_NAME = template_config["plugin_name"]
72+
UPSTREAM_REMOTE = f"https://github.com/{GITHUB_ORG}/{PLUGIN_NAME}.git"
73+
DEFAULT_BRANCH = template_config["plugin_default_branch"]
74+
3975
repo = Repo.clone_from(UPSTREAM_REMOTE, d, filter="blob:none")
4076
heads = [h.split("/")[-1] for h in repo.git.ls_remote("--heads").split("\n")]
4177
available_branches = [h for h in heads if re.search(RELEASE_BRANCH_REGEX, h)]
4278
available_branches.sort(key=lambda ver: Version(ver))
4379
available_branches.append(DEFAULT_BRANCH)
4480

45-
branches = opts.branches
81+
branches = options.branches
4682
if branches == "supported":
4783
with open(f"{d}/template_config.yml", mode="r") as f:
4884
tc = yaml.safe_load(f)
@@ -86,6 +122,11 @@ def main():
86122
)
87123
if req_txt_diff:
88124
reasons.append("requirements.txt")
125+
pyproject_diff = repo.git.diff(
126+
f"{last_tag}", f"origin/{branch}", "--name-only", "--", "pyproject.toml"
127+
)
128+
if pyproject_diff:
129+
reasons.extend(check_pyproject_dependencies(repo, last_tag, f"origin/{branch}"))
89130

90131
if reasons:
91132
curr_version = Version(last_tag)
@@ -106,15 +147,10 @@ def main():
106147
for change in changes.split("\n"):
107148
_, ext = os.path.splitext(change)
108149
if ext in Y_CHANGELOG_EXTS:
109-
# We don't put Y release bumps in the commit message, check file instead
110-
# The 'current_version' is always the next version to release
111-
next_version = repo.git.grep(
112-
"current_version", DEFAULT_BRANCH, "--", ".bumpversion.cfg"
113-
).split("=")[-1]
114-
next_version = Version(next_version)
115-
print(
116-
f"A new Y-release is needed! New Version: {next_version.base_version}"
117-
)
150+
# We don't put Y release bumps in the commit message, check file instead.
151+
# The 'current_version' is always the dev of the next version to release.
152+
next_version = current_version(repo, DEFAULT_BRANCH).base_version
153+
print(f"A new Y-release is needed! New Version: {next_version}")
118154
releases.append(next_version)
119155
break
120156

@@ -123,4 +159,4 @@ def main():
123159

124160

125161
if __name__ == "__main__":
126-
main()
162+
main(options(), template_config())

.ci/scripts/check_requirements.py

+35-14
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
#
66
# For more info visit https://github.com/pulp/plugin_template
77

8+
import tomllib
89
import warnings
9-
from pkg_resources import Requirement
10+
from packaging.requirements import Requirement
1011

1112

1213
CHECK_MATRIX = [
14+
("pyproject.toml", True, True, True),
1315
("requirements.txt", True, True, True),
1416
("dev_requirements.txt", False, True, False),
1517
("ci_requirements.txt", False, True, True),
@@ -20,17 +22,33 @@
2022
("clitest_requirements.txt", False, True, True),
2123
]
2224

23-
errors = []
2425

25-
for filename, check_upperbound, check_prereleases, check_r in CHECK_MATRIX:
26-
try:
26+
def iterate_file(filename):
27+
if filename == "pyproject.toml":
28+
with open(filename, "rb") as fd:
29+
pyproject_toml = tomllib.load(fd)
30+
if "project" in pyproject_toml:
31+
for nr, line in enumerate(pyproject_toml["project"]["dependencies"]):
32+
yield nr, line
33+
else:
2734
with open(filename, "r") as fd:
2835
for nr, line in enumerate(fd.readlines()):
2936
line = line.strip()
3037
if not line or line.startswith("#"):
3138
continue
39+
if "#" in line:
40+
line = line.split("#", maxsplit=1)[0]
41+
yield nr, line.strip()
42+
43+
44+
def main():
45+
errors = []
46+
47+
for filename, check_upperbound, check_prereleases, check_r in CHECK_MATRIX:
48+
try:
49+
for nr, line in iterate_file(filename):
3250
try:
33-
req = Requirement.parse(line)
51+
req = Requirement(line)
3452
except ValueError:
3553
if line.startswith("git+"):
3654
# The single exception...
@@ -49,18 +67,21 @@
4967
and req.name != "pulp-npm-client"
5068
):
5169
errors.append(f"{filename}:{nr}: Prerelease versions found in {line}.")
52-
ops = [op for op, ver in req.specs]
53-
spec = str(req.specs)
70+
ops = [spec.operator for spec in req.specifier]
5471
if "~=" in ops:
5572
warnings.warn(f"{filename}:{nr}: Please avoid using ~= on {req.name}!")
5673
elif "<" not in ops and "<=" not in ops and "==" not in ops:
5774
if check_upperbound:
5875
errors.append(f"{filename}:{nr}: Upper bound missing in {line}.")
59-
except FileNotFoundError:
60-
# skip this test for plugins that don't use this requirements.txt
61-
pass
76+
except FileNotFoundError:
77+
# skip this test for plugins that don't use this requirements.txt
78+
pass
79+
80+
if errors:
81+
print("Dependency issues found:")
82+
print("\n".join(errors))
83+
exit(1)
84+
6285

63-
if errors:
64-
print("Dependency issues found:")
65-
print("\n".join(errors))
66-
exit(1)
86+
if __name__ == "__main__":
87+
main()

.github/template_gitref

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2021.08.26-387-ge627e91
1+
2021.08.26-406-g5f397e3

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ jobs:
3434
- name: "Install python dependencies"
3535
run: |
3636
echo ::group::PYDEPS
37-
pip install packaging twine wheel mkdocs jq
37+
pip install build packaging twine wheel mkdocs jq
3838
echo ::endgroup::
3939
- name: "Build package"
4040
run: |
41-
python3 setup.py sdist bdist_wheel --python-tag py3
41+
python3 -m build
4242
twine check dist/*
4343
- name: "Install built packages"
4444
run: |

.github/workflows/ci.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ jobs:
4242
GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}"
4343
run: |
4444
.github/workflows/scripts/check_commit.sh
45-
- name: "Verify requirements files"
46-
run: |
47-
python .ci/scripts/check_requirements.py
4845
4946
lint:
5047
uses: "./.github/workflows/lint.yml"
@@ -56,6 +53,9 @@ jobs:
5653
test:
5754
needs: "build"
5855
uses: "./.github/workflows/test.yml"
56+
with:
57+
matrix_env: |
58+
[{"TEST": "pulp"}, {"TEST": "azure"}, {"TEST": "s3"}, {"TEST": "lowerbounds"}]
5959
6060
deprecations:
6161
runs-on: "ubuntu-latest"
@@ -84,7 +84,6 @@ jobs:
8484
- "check-commits"
8585
- "lint"
8686
- "test"
87-
- "docs"
8887
if: "always()"
8988
steps:
9089
- name: "Collect needed jobs results"

0 commit comments

Comments
 (0)