Skip to content

Commit 716efe0

Browse files
pulpbotmdellweg
authored andcommitted
Update CI files
1 parent 56401c6 commit 716efe0

14 files changed

+115
-63
lines changed

.bumpversion.cfg

-2
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,3 @@ values =
1717
[bumpversion:file:./pulp_python/app/__init__.py]
1818

1919
[bumpversion:file:./setup.py]
20-
21-
[bumpversion:file:./docs/conf.py]

.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

+7
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ def main():
8686
)
8787
if req_txt_diff:
8888
reasons.append("requirements.txt")
89+
pyproject_diff = repo.git.diff(
90+
f"{last_tag}", f"origin/{branch}", "--name-only", "--", "pyproject.toml"
91+
)
92+
if pyproject_diff:
93+
reasons.append(
94+
"pyproject.toml changed (PLEASE check if dependencies are affected."
95+
)
8996

9097
if reasons:
9198
curr_version = Version(last_tag)

.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-python-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-389-g444ab6c
1+
2021.08.26-393-g0e700c1

.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
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
docs:
5047
uses: "./.github/workflows/docs.yml"

.github/workflows/create-branch.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: "Install python dependencies"
4040
run: |
4141
echo ::group::PYDEPS
42-
pip install bump2version packaging -r plugin_template/requirements.txt
42+
pip install bump-my-version packaging -r plugin_template/requirements.txt
4343
echo ::endgroup::
4444
4545
- name: "Setting secrets"
@@ -54,7 +54,7 @@ jobs:
5454
run: |
5555
# Just to be sure...
5656
git checkout main
57-
NEW_BRANCH="$(bump2version --dry-run --list release | sed -Ene 's/^new_version=([[:digit:]]+\.[[:digit:]]+)\..*$/\1/p')"
57+
NEW_BRANCH="$(bump-my-version show new_version --increment release | sed -Ene 's/^([[:digit:]]+\.[[:digit:]]+)\.[[:digit:]]+$/\1/p')"
5858
if [ -z "$NEW_BRANCH" ]
5959
then
6060
echo Could not determine the new branch name.
@@ -70,7 +70,7 @@ jobs:
7070
- name: Bump version on main branch
7171
working-directory: pulp_python
7272
run: |
73-
bump2version --no-commit minor
73+
bump-my-version bump --no-commit minor
7474
7575
- name: Remove entries from CHANGES directory
7676
working-directory: pulp_python

.github/workflows/lint.yml

+26-13
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ defaults:
1616

1717
jobs:
1818
lint:
19-
runs-on: ubuntu-latest
19+
runs-on: "ubuntu-latest"
2020

2121
steps:
2222
- uses: "actions/checkout@v4"
@@ -34,23 +34,36 @@ jobs:
3434
pip install -r lint_requirements.txt
3535
echo ::endgroup::
3636
37-
- name: Lint workflow files
37+
- name: "Lint workflow files"
3838
run: |
3939
yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows
4040
41+
- name: "Verify bump version config"
42+
run: |
43+
bump-my-version bump --dry-run release
44+
bump-my-version show-bump
45+
4146
# Lint code.
42-
- name: Run flake8
43-
run: flake8
47+
- name: "Run flake8"
48+
run: |
49+
flake8
4450
45-
- name: Run extra lint checks
46-
run: "[ ! -x .ci/scripts/extra_linting.sh ] || .ci/scripts/extra_linting.sh"
51+
- name: "Run extra lint checks"
52+
run: |
53+
[ ! -x .ci/scripts/extra_linting.sh ] || .ci/scripts/extra_linting.sh
4754
48-
# check for any files unintentionally left out of MANIFEST.in
49-
- name: Check manifest
50-
run: check-manifest
55+
- name: "Check for any files unintentionally left out of MANIFEST.in"
56+
run: |
57+
check-manifest
5158
52-
- name: Check for pulpcore imports outside of pulpcore.plugin
53-
run: sh .ci/scripts/check_pulpcore_imports.sh
59+
- name: "Verify requirements files"
60+
run: |
61+
python .ci/scripts/check_requirements.py
62+
63+
- name: "Check for pulpcore imports outside of pulpcore.plugin"
64+
run: |
65+
sh .ci/scripts/check_pulpcore_imports.sh
5466
55-
- name: Check for gettext problems
56-
run: sh .ci/scripts/check_gettext.sh
67+
- name: "Check for common gettext problems"
68+
run: |
69+
sh .ci/scripts/check_gettext.sh

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: "Install python dependencies"
3636
run: |
3737
echo ::group::PYDEPS
38-
pip install bump2version towncrier
38+
pip install bump-my-version towncrier
3939
echo ::endgroup::
4040
4141
- name: "Configure Git with pulpbot name and email"

.github/workflows/scripts/before_install.sh

-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ if [ -f $PRE_BEFORE_INSTALL ]; then
4545
source $PRE_BEFORE_INSTALL
4646
fi
4747

48-
if [[ -n $(echo -e $COMMIT_MSG | grep -P "Required PR:.*") ]]; then
49-
echo "The Required PR mechanism has been removed. Consider adding a scm requirement to requirements.txt."
50-
exit 1
51-
fi
52-
5348
if [ "$GITHUB_EVENT_NAME" = "pull_request" ] || [ "${BRANCH_BUILD}" = "1" -a "${BRANCH}" != "main" ]
5449
then
5550
echo $COMMIT_MSG | sed -n -e 's/.*CI Base Image:\s*\([-_/[:alnum:]]*:[-_[:alnum:]]*\).*/ci_base: "\1"/p' >> .ci/ansible/vars/main.yaml

.github/workflows/scripts/release.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ then
1010
exit 1
1111
fi
1212

13-
NEW_VERSION="$(bump2version --dry-run --list release | sed -ne 's/^new_version=//p')"
13+
# The tail is a necessary workaround to remove the warning from the output.
14+
NEW_VERSION="$(bump-my-version show new_version --increment release | tail -n -1)"
1415
echo "Release ${NEW_VERSION}"
1516

1617
if ! [[ "${NEW_VERSION}" == "${BRANCH}"* ]]
@@ -20,7 +21,7 @@ then
2021
fi
2122

2223
towncrier build --yes --version "${NEW_VERSION}"
23-
bump2version release --commit --message "Release {new_version}" --tag --tag-name "{new_version}" --tag-message "Release {new_version}" --allow-dirty
24-
bump2version patch --commit
24+
bump-my-version bump release --commit --message "Release {new_version}" --tag --tag-name "{new_version}" --tag-message "Release {new_version}" --allow-dirty
25+
bump-my-version bump patch --commit
2526

2627
git push origin "${BRANCH}" "${NEW_VERSION}"

lint_requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#
66
# For more info visit https://github.com/pulp/plugin_template
77

8-
# python packages handy for developers, but not required by pulp
8+
bump-my-version
99
check-manifest
1010
flake8
11+
packaging
1112
yamllint

0 commit comments

Comments
 (0)