Skip to content

Commit

Permalink
Apply plugin-template --github manually
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
pedro-psb authored and ggainey committed Jul 24, 2024
1 parent f59ad1a commit 7302950
Show file tree
Hide file tree
Showing 19 changed files with 169 additions and 684 deletions.
10 changes: 8 additions & 2 deletions .ci/ansible/Containerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,26 @@ ADD ./{{ item.name }} ./{{ item.name }}
# S3 botocore needs to be patched to handle responses from minio during 0-byte uploads
# Hacking botocore (https://github.com/boto/botocore/pull/1990)

RUN pip3 install
RUN pip3 install --upgrade pip setuptools wheel && \
rm -rf /root/.cache/pip && \
pip3 install
{%- if s3_test | default(false) -%}
{{ " " }}git+https://github.com/gerrod3/botocore.git@fix-100-continue
{%- endif -%}
{%- for item in plugins -%}
{{ " " }}{{ item.source }}
{%- if item.upperbounds | default(false) -%}
{{ " " }}-c ./{{ item.name }}/upperbounds_constraints.txt
{%- endif -%}
{%- if item.lowerbounds | default(false) -%}
{{ " " }}-c ./{{ item.name }}/lowerbounds_constraints.txt
{%- endif -%}
{%- if item.ci_requirements | default(false) -%}
{{ " " }}-r ./{{ item.name }}/ci_requirements.txt
{%- endif -%}
{%- endfor %}
{{ " " }}-c ./{{ plugins[0].name }}/.ci/assets/ci_constraints.txt
{{ " " }}-c ./{{ plugins[0].name }}/.ci/assets/ci_constraints.txt && \
rm -rf /root/.cache/pip

{% if pulp_env is defined and pulp_env %}
{% for key, value in pulp_env.items() %}
Expand Down
118 changes: 118 additions & 0 deletions .ci/scripts/calc_constraints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github pulp_rpm' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template

import argparse
import fileinput
import urllib.request
import sys
from packaging.requirements import Requirement
from packaging.version import Version
import yaml


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


def fetch_pulpcore_upper_bound(requirement):
with urllib.request.urlopen(CORE_TEMPLATE_URL) as f:
template = yaml.safe_load(f.read())
supported_versions = template["supported_release_branches"]
supported_versions.append(template["latest_release_branch"])
applicable_versions = sorted(
requirement.specifier.filter((Version(v) for v in supported_versions))
)
if len(applicable_versions) == 0:
raise Exception("No supported pulpcore version in required range.")
return f"{requirement.name}~={applicable_versions[-1]}"


def split_comment(line):
split_line = line.split("#", maxsplit=1)
try:
comment = " # " + split_line[1].strip()
except IndexError:
comment = ""
return split_line[0].strip(), comment


def to_upper_bound(req):
try:
requirement = Requirement(req)
except ValueError:
return f"# UNPARSABLE: {req}"
else:
if requirement.name == "pulpcore":
# An exception to allow for pulpcore deprecation policy.
return fetch_pulpcore_upper_bound(requirement)
for spec in requirement.specifier:
if spec.operator == "~=":
return f"# NO BETTER CONSTRAINT: {req}"
if spec.operator == "<=":
operator = "=="
max_version = spec.version
return f"{requirement.name}{operator}{max_version}"
if spec.operator == "<":
operator = "~="
version = Version(spec.version)
if version.micro != 0:
max_version = f"{version.major}.{version.minor}.{version.micro-1}"
elif version.minor != 0:
max_version = f"{version.major}.{version.minor-1}"
elif version.major != 0:
max_version = f"{version.major-1}.0"
else:
return f"# NO BETTER CONSTRAINT: {req}"
return f"{requirement.name}{operator}{max_version}"
return f"# NO UPPER BOUND: {req}"


def to_lower_bound(req):
try:
requirement = Requirement(req)
except ValueError:
return f"# UNPARSABLE: {req}"
else:
for spec in requirement.specifier:
if spec.operator == ">=":
if requirement.name == "pulpcore":
# Currently an exception to allow for pulpcore bugfix releases.
# TODO Semver libraries should be allowed too.
operator = "~="
else:
operator = "=="
min_version = spec.version
return f"{requirement.name}{operator}{min_version}"
return f"# NO LOWER BOUND: {req}"


def main():
"""Calculate constraints for the lower bound of dependencies where possible."""
parser = argparse.ArgumentParser(
prog=sys.argv[0],
description="Calculate constraints for the lower or upper bound of dependencies where "
"possible.",
)
parser.add_argument("-u", "--upper", action="store_true")
parser.add_argument("filename", nargs="*")
args = parser.parse_args()

with fileinput.input(files=args.filename) as req_file:
for line in req_file:
if line.strip().startswith("#"):
# Shortcut comment only lines
print(line.strip())
else:
req, comment = split_comment(line)
if args.upper:
new_req = to_upper_bound(req)
else:
new_req = to_lower_bound(req)
print(new_req + comment)


if __name__ == "__main__":
main()
34 changes: 0 additions & 34 deletions .ci/scripts/calc_deps_lowerbounds.py

This file was deleted.

2 changes: 1 addition & 1 deletion .github/template_gitref
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2021.08.26-348-gb87ed3b
2021.08.26-363-g00b480b
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
echo ::group::PYDEPS
pip install packaging twine wheel mkdocs jq
echo ::endgroup::
- name: "Install OS packages"
run: |
sudo apt-get install -y libgirepository1.0-dev gir1.2-modulemd-2.0
- name: "Build package"
run: |
python3 setup.py sdist bdist_wheel --python-tag py3
Expand Down
58 changes: 0 additions & 58 deletions .github/workflows/changelog.yml

This file was deleted.

77 changes: 20 additions & 57 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,58 +66,6 @@ jobs:
delete-branch: true
path: "pulp_rpm"

publish:
runs-on: ubuntu-latest
needs: test

steps:
- uses: "actions/checkout@v4"
with:
fetch-depth: 1
path: "pulp_rpm"

- uses: actions/download-artifact@v4
with:
name: "plugin_package"
path: "pulp_rpm/dist/"

- uses: "actions/setup-python@v5"
with:
python-version: "3.11"

- name: "Install python dependencies"
run: |
echo ::group::PYDEPS
pip install requests 'packaging~=21.3' mkdocs pymdown-extensions 'Jinja2<3.1'
echo ::endgroup::
- name: "Set environment variables"
run: |
echo "TEST=${{ matrix.env.TEST }}" >> $GITHUB_ENV
- name: Download built docs
uses: actions/download-artifact@v4
with:
name: "docs.tar"
path: "pulp_rpm"

- name: Download Python client docs
uses: actions/download-artifact@v4
with:
name: "python-client-docs.tar"
path: "pulp_rpm"

- name: "Setting secrets"
run: |
python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT"
env:
SECRETS_CONTEXT: "${{ toJson(secrets) }}"

- name: Publish docs to pulpproject.org
run: |
tar -xvf docs.tar -C ./docs
.github/workflows/scripts/publish_docs.sh nightly ${GITHUB_REF##*/}
performance:
runs-on: ubuntu-latest
needs: test
Expand Down Expand Up @@ -150,6 +98,26 @@ jobs:
name: "plugin_package"
path: "pulp_rpm/dist/"

- name: "Download API specs"
uses: "actions/download-artifact@v4"
with:
name: "api_spec"
path: "pulp_rpm/"

- name: "Download client packages"
uses: "actions/download-artifact@v4"
with:
name: "python-client.tar"
path: "pulp_rpm"

- name: "Unpack client packages"
working-directory: "pulp-openapi-generator"
run: |
mkdir -p "pulp_rpm-client"
pushd "pulp_rpm-client"
tar xvf "../../pulp_rpm/rpm-python-client.tar"
popd
- uses: "actions/setup-python@v5"
with:
python-version: "3.11"
Expand Down Expand Up @@ -186,11 +154,6 @@ jobs:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}"

- name: "Install Python client"
run: |
.github/workflows/scripts/install_python_client.sh
shell: "bash"

- name: "Before Script"
run: |
.github/workflows/scripts/before_script.sh
Expand Down
Loading

0 comments on commit 7302950

Please sign in to comment.