Skip to content

Commit 2c02cf3

Browse files
authored
Merge pull request #705 from pulp/update-ci/3.12
Update CI files for branch 3.12
2 parents 56f6aca + 5078521 commit 2c02cf3

16 files changed

+131
-539
lines changed

.ci/ansible/Containerfile.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ RUN pip3 install
1515
{%- endif -%}
1616
{%- for item in plugins -%}
1717
{{ " " }}{{ item.source }}
18+
{%- if item.upperbounds | default(false) -%}
19+
{{ " " }}-c ./{{ item.name }}/upperbounds_constraints.txt
20+
{%- endif -%}
1821
{%- if item.lowerbounds | default(false) -%}
1922
{{ " " }}-c ./{{ item.name }}/lowerbounds_constraints.txt
2023
{%- endif -%}

.ci/scripts/calc_constraints.py

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# WARNING: DO NOT EDIT!
2+
#
3+
# This file was generated by plugin_template, and is managed by it. Please use
4+
# './plugin-template --github pulp_python' to update this file.
5+
#
6+
# For more info visit https://github.com/pulp/plugin_template
7+
8+
import argparse
9+
import fileinput
10+
import urllib.request
11+
import sys
12+
from packaging.requirements import Requirement
13+
from packaging.version import Version
14+
import yaml
15+
16+
17+
CORE_TEMPLATE_URL = "https://raw.githubusercontent.com/pulp/pulpcore/main/template_config.yml"
18+
19+
20+
def fetch_pulpcore_upper_bound(requirement):
21+
with urllib.request.urlopen(CORE_TEMPLATE_URL) as f:
22+
template = yaml.safe_load(f.read())
23+
supported_versions = template["supported_release_branches"]
24+
supported_versions.append(template["latest_release_branch"])
25+
applicable_versions = sorted(
26+
requirement.specifier.filter((Version(v) for v in supported_versions))
27+
)
28+
if len(applicable_versions) == 0:
29+
raise Exception("No supported pulpcore version in required range.")
30+
return f"{requirement.name}~={applicable_versions[-1]}"
31+
32+
33+
def split_comment(line):
34+
split_line = line.split("#", maxsplit=1)
35+
try:
36+
comment = " # " + split_line[1].strip()
37+
except IndexError:
38+
comment = ""
39+
return split_line[0].strip(), comment
40+
41+
42+
def to_upper_bound(req):
43+
try:
44+
requirement = Requirement(req)
45+
except ValueError:
46+
return f"# UNPARSABLE: {req}"
47+
else:
48+
if requirement.name == "pulpcore":
49+
# An exception to allow for pulpcore deprecation policy.
50+
return fetch_pulpcore_upper_bound(requirement)
51+
for spec in requirement.specifier:
52+
if spec.operator == "~=":
53+
return f"# NO BETTER CONSTRAINT: {req}"
54+
if spec.operator == "<=":
55+
operator = "=="
56+
max_version = spec.version
57+
return f"{requirement.name}{operator}{max_version}"
58+
if spec.operator == "<":
59+
operator = "~="
60+
version = Version(spec.version)
61+
if version.micro != 0:
62+
max_version = f"{version.major}.{version.minor}.{version.micro-1}"
63+
elif version.minor != 0:
64+
max_version = f"{version.major}.{version.minor-1}"
65+
else:
66+
return f"# NO BETTER CONSTRAINT: {req}"
67+
return f"{requirement.name}{operator}{max_version}"
68+
return f"# NO UPPER BOUND: {req}"
69+
70+
71+
def to_lower_bound(req):
72+
try:
73+
requirement = Requirement(req)
74+
except ValueError:
75+
return f"# UNPARSABLE: {req}"
76+
else:
77+
for spec in requirement.specifier:
78+
if spec.operator == ">=":
79+
if requirement.name == "pulpcore":
80+
# Currently an exception to allow for pulpcore bugfix releases.
81+
# TODO Semver libraries should be allowed too.
82+
operator = "~="
83+
else:
84+
operator = "=="
85+
min_version = spec.version
86+
return f"{requirement.name}{operator}{min_version}"
87+
return f"# NO LOWER BOUND: {req}"
88+
89+
90+
def main():
91+
"""Calculate constraints for the lower bound of dependencies where possible."""
92+
parser = argparse.ArgumentParser(
93+
prog=sys.argv[0],
94+
description="Calculate constraints for the lower or upper bound of dependencies where "
95+
"possible.",
96+
)
97+
parser.add_argument("-u", "--upper", action="store_true")
98+
parser.add_argument("filename", nargs="*")
99+
args = parser.parse_args()
100+
101+
with fileinput.input(files=args.filename) as req_file:
102+
for line in req_file:
103+
if line.strip().startswith("#"):
104+
# Shortcut comment only lines
105+
print(line.strip())
106+
else:
107+
req, comment = split_comment(line)
108+
if args.upper:
109+
new_req = to_upper_bound(req)
110+
else:
111+
new_req = to_lower_bound(req)
112+
print(new_req + comment)
113+
114+
115+
if __name__ == "__main__":
116+
main()

.ci/scripts/calc_deps_lowerbounds.py

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

.github/template_gitref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2021.08.26-349-gba81617
1+
2021.08.26-354-g82d22de

.github/workflows/changelog.yml

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

.github/workflows/nightly.yml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -65,55 +65,3 @@ jobs:
6565
branch: "changelog/update"
6666
delete-branch: true
6767
path: "pulp_python"
68-
69-
publish:
70-
runs-on: ubuntu-latest
71-
needs: test
72-
73-
steps:
74-
- uses: "actions/checkout@v4"
75-
with:
76-
fetch-depth: 1
77-
path: "pulp_python"
78-
79-
- uses: actions/download-artifact@v4
80-
with:
81-
name: "plugin_package"
82-
path: "pulp_python/dist/"
83-
84-
- uses: "actions/setup-python@v5"
85-
with:
86-
python-version: "3.11"
87-
88-
- name: "Install python dependencies"
89-
run: |
90-
echo ::group::PYDEPS
91-
pip install requests 'packaging~=21.3' mkdocs pymdown-extensions 'Jinja2<3.1'
92-
echo ::endgroup::
93-
94-
- name: "Set environment variables"
95-
run: |
96-
echo "TEST=${{ matrix.env.TEST }}" >> $GITHUB_ENV
97-
98-
- name: Download built docs
99-
uses: actions/download-artifact@v4
100-
with:
101-
name: "docs.tar"
102-
path: "pulp_python"
103-
104-
- name: Download Python client docs
105-
uses: actions/download-artifact@v4
106-
with:
107-
name: "python-client-docs.tar"
108-
path: "pulp_python"
109-
110-
- name: "Setting secrets"
111-
run: |
112-
python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT"
113-
env:
114-
SECRETS_CONTEXT: "${{ toJson(secrets) }}"
115-
116-
- name: Publish docs to pulpproject.org
117-
run: |
118-
tar -xvf docs.tar -C ./docs
119-
.github/workflows/scripts/publish_docs.sh nightly ${GITHUB_REF##*/}

.github/workflows/publish.yml

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -137,52 +137,6 @@ jobs:
137137
- name: "Publish client to rubygems"
138138
run: |
139139
bash .github/workflows/scripts/publish_client_gem.sh ${{ github.ref_name }}
140-
publish-docs:
141-
runs-on: "ubuntu-latest"
142-
needs:
143-
- "build"
144-
145-
env:
146-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
147-
148-
steps:
149-
- uses: "actions/checkout@v4"
150-
with:
151-
fetch-depth: 1
152-
path: "pulp_python"
153-
154-
- uses: "actions/setup-python@v5"
155-
with:
156-
python-version: "3.11"
157-
158-
- name: "Install python dependencies"
159-
run: |
160-
echo ::group::PYDEPS
161-
pip install 'packaging~=21.3' requests
162-
echo ::endgroup::
163-
164-
- name: "Setting secrets"
165-
run: |
166-
python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT"
167-
env:
168-
SECRETS_CONTEXT: "${{ toJson(secrets) }}"
169-
170-
- name: "Download built docs"
171-
uses: "actions/download-artifact@v4"
172-
with:
173-
name: "docs.tar"
174-
path: "pulp_python/"
175-
176-
- name: "Download Python client docs"
177-
uses: "actions/download-artifact@v4"
178-
with:
179-
name: "python-client-docs.tar"
180-
path: "pulp_python/"
181-
182-
- name: "Publish docs to pulpproject.org"
183-
run: |
184-
tar -xvf docs.tar
185-
.github/workflows/scripts/publish_docs.sh tag ${{ github.ref_name }}
186140
187141
create-gh-release:
188142
runs-on: "ubuntu-latest"
@@ -191,7 +145,6 @@ jobs:
191145
- "publish-package"
192146
- "publish-python-bindings"
193147
- "publish-ruby-bindings"
194-
- "publish-docs"
195148

196149
steps:
197150
- name: "Create release on GitHub"

.github/workflows/scripts/before_install.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ then
6565
exit $s
6666
fi
6767

68+
if [[ "$TEST" = "pulp" ]]; then
69+
python3 .ci/scripts/calc_constraints.py -u requirements.txt > upperbounds_constraints.txt
70+
fi
6871
if [[ "$TEST" = "lowerbounds" ]]; then
69-
python3 .ci/scripts/calc_deps_lowerbounds.py > lowerbounds_constraints.txt
70-
sed -i 's/\[.*\]//g' lowerbounds_constraints.txt
72+
python3 .ci/scripts/calc_constraints.py requirements.txt > lowerbounds_constraints.txt
7173
fi
7274

7375
if [ -f $POST_BEFORE_INSTALL ]; then

0 commit comments

Comments
 (0)