Skip to content

Commit

Permalink
Update CI files
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
pulpbot committed Jul 16, 2023
1 parent 934ed82 commit 9237fe8
Show file tree
Hide file tree
Showing 27 changed files with 523 additions and 355 deletions.
20 changes: 15 additions & 5 deletions .ci/ansible/Containerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ FROM {{ ci_base | default("ghcr.io/pulp/pulp-ci-centos:" + pulp_container_tag) }

# Add source directories to container
{% for item in plugins %}
{% if item.source.startswith("./") %}
ADD {{ item.source }} {{ item.source }}
{% if item.source.startswith("./") or item.ci_requirements | default(false) %}
ADD ./{{ item.name }} ./{{ item.name }}
{% endif %}
{% endfor %}

# Install python packages
# Hacking botocore (https://github.com/boto/botocore/pull/1990)

RUN pip3 install \
RUN pip3 install
{%- if stream_test | default(false) -%}
{{ " " }}django-storages[sftp]
{%- endif -%}
Expand All @@ -20,14 +20,24 @@ RUN pip3 install \
{%- if azure_test | default(false) -%}
{{ " " }}django-storages[azure]>=1.12.2
{%- endif -%}
{%- if gcp_test | default(false) -%}
{{ " " }}django-storages[google]>=1.13.2
{%- endif -%}
{%- for item in plugins -%}
{%- if item.name == "pulp-certguard" -%}
{{ " " }}python-dateutil rhsm
{%- endif -%}
{{ " " }}"{{ item.source }}"
{{ " " }}{{ item.source }}
{%- if item.ci_requirements | default(false) -%}
{{ " " }}-r ./{{ item.name }}/ci_requirements.txt
{%- endif -%}
{%- endfor %}

RUN mkdir -p /etc/nginx/pulp/
USER pulp:pulp
RUN PULP_STATIC_ROOT=/var/lib/operator/static/ PULP_CONTENT_ORIGIN=localhost \
/usr/local/bin/pulpcore-manager collectstatic --clear --noinput --link
USER root:root

{% for item in plugins %}
RUN export plugin_path="$(pip3 show {{ item.name }} | sed -n -e 's/Location: //p')/{{ item.name }}" && \
ln $plugin_path/app/webserver_snippets/nginx.conf /etc/nginx/pulp/{{ item.name }}.conf || true
Expand Down
9 changes: 8 additions & 1 deletion .ci/ansible/settings.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TOKEN_SIGNATURE_ALGORITHM = "ES256"
CACHE_ENABLED = True
REDIS_HOST = "localhost"
REDIS_PORT = 6379
TELEMETRY = False
ANALYTICS = False

{% if api_root is defined %}
API_ROOT = {{ api_root | repr }}
Expand Down Expand Up @@ -63,3 +63,10 @@ AZURE_OVERWRITE_FILES = True
AZURE_URL_EXPIRATION_SECS = 120
AZURE_CONNECTION_STRING = 'DefaultEndpointsProtocol={{ pulp_scheme }};AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint={{ pulp_scheme }}://ci-azurite:10000/devstoreaccount1;'
{% endif %}

{% if gcp_test | default(false) %}
DEFAULT_FILE_STORAGE = "storages.backends.gcloud.GoogleCloudStorage"
MEDIA_ROOT = ""
GS_BUCKET_NAME = "gcppulp"
GS_CUSTOM_ENDPOINT = "http://ci-gcp:4443"
{% endif %}
1 change: 0 additions & 1 deletion .ci/assets/release_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
bump2version
gitpython
python-redmine
towncrier
34 changes: 34 additions & 0 deletions .ci/scripts/calc_deps_lowerbounds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github pulp_cookbook' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template

from packaging.requirements import Requirement


def main():
"""Calculate the lower bound of dependencies where possible."""
with open("requirements.txt") as req_file:
for line in req_file:
try:
requirement = Requirement(line)
except ValueError:
print(line.strip())
else:
for spec in requirement.specifier:
if spec.operator == ">=":
if requirement.name == "pulpcore":
operator = "~="
else:
operator = "=="
min_version = str(spec)[2:]
print(f"{requirement.name}{operator}{min_version}")
break
else:
print(line.strip())


if __name__ == "__main__":
main()
4 changes: 3 additions & 1 deletion .ci/scripts/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def get_changelog_releases(changelog):
Get all versions in changelog.
"""
versions = re.findall(r"([0-9]+)\.([0-9]+)\.([0-9]+) \(", changelog)
versions = re.findall(
r"([0-9]+)\.([0-9]+)\.([0-9][0-9ab]*) \([0-9]{4}-[0-9]{2}-[0-9]{2}\)", changelog
)
return {".".join(v) for v in versions}


Expand Down
1 change: 0 additions & 1 deletion .ci/scripts/check_gettext.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ cd "$(dirname "$(realpath -e "$0")")"/../..

set -uv

# check for imports not from pulpcore.plugin. exclude tests
MATCHES=$(grep -n -r --include \*.py "_(f")

if [ $? -ne 1 ]; then
Expand Down
112 changes: 112 additions & 0 deletions .ci/scripts/check_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/env python

# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github pulp_cookbook' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template

import argparse
import re
import os
import yaml
from tempfile import TemporaryDirectory
from packaging.version import Version
from git import Repo

UPSTREAM_REMOTE = "https://github.com/pulp/pulp_cookbook.git"
DEFAULT_BRANCH = "main"
RELEASE_BRANCH_REGEX = r"^([0-9]+)\.([0-9]+)$"
Y_CHANGELOG_EXTS = [".feature", ".removal", ".deprecation"]
Z_CHANGELOG_EXTS = [".bugfix", ".doc", ".misc"]


def main():
"""Check which branches need a release."""
parser = argparse.ArgumentParser()
parser.add_argument(
"--branches",
default="supported",
help="A comma separated list of branches to check for releases. Can also use keyword: "
"'supported'. Defaults to 'supported', see `ci_update_branches` in "
"`plugin_template.yml`.",
)
opts = parser.parse_args()

with TemporaryDirectory() as d:
# Clone from upstream to ensure we have updated branches & main
repo = Repo.clone_from(UPSTREAM_REMOTE, d, filter="blob:none")
heads = [h.split("/")[-1] for h in repo.git.ls_remote("--heads").split("\n")]
available_branches = [h for h in heads if re.search(RELEASE_BRANCH_REGEX, h)]
available_branches.sort(key=lambda ver: Version(ver))
available_branches.append(DEFAULT_BRANCH)

branches = opts.branches
if branches == "supported":
with open(f"{d}/template_config.yml", mode="r") as f:
tc = yaml.safe_load(f)
branches = tc["ci_update_branches"]
branches.append(DEFAULT_BRANCH)
else:
branches = branches.split(",")

if diff := set(branches) - set(available_branches):
print(f"Supplied branches contains non-existent branches! {diff}")
exit(1)

print(f"Checking for releases on branches: {branches}")

releases = []
for branch in branches:
if branch != DEFAULT_BRANCH:
# Check if a Z release is needed
changes = repo.git.ls_tree("-r", "--name-only", f"origin/{branch}", "CHANGES/")
z_release = False
for change in changes.split("\n"):
# Check each changelog file to make sure everything checks out
_, ext = os.path.splitext(change)
if ext in Y_CHANGELOG_EXTS:
print(
f"Warning: A non-backported changelog ({change}) is present in the "
f"{branch} release branch!"
)
elif ext in Z_CHANGELOG_EXTS:
z_release = True
if z_release:
# Blobless clone does not have file contents for Z branches,
# check commit message for last Z bump
git_branch = f"origin/{branch}"
next_version = repo.git.log(
"--oneline", "--grep=Bump to", "-n 1", git_branch, "--", ".bumpversion.cfg"
).split("to")[-1]
next_version = Version(next_version)
print(
f"A Z-release is needed for {branch}, "
f"New Version: {next_version.base_version}"
)
releases.append(next_version)
else:
# Check if a Y release is needed
changes = repo.git.ls_tree("-r", "--name-only", DEFAULT_BRANCH, "CHANGES/")
for change in changes.split("\n"):
_, ext = os.path.splitext(change)
if ext in Y_CHANGELOG_EXTS:
# We don't put Y release bumps in the commit message, check file instead
# The 'current_version' is always the next version to release
next_version = repo.git.grep(
"current_version", DEFAULT_BRANCH, "--", ".bumpversion.cfg"
).split("=")[-1]
next_version = Version(next_version)
print(
f"A new Y-release is needed! New Version: {next_version.base_version}"
)
releases.append(next_version)
break

if len(releases) == 0:
print("No new releases to perform.")


if __name__ == "__main__":
main()
66 changes: 66 additions & 0 deletions .ci/scripts/check_requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github pulp_cookbook' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template

import warnings
from pkg_resources import Requirement


CHECK_MATRIX = [
("requirements.txt", True, True, True),
("dev_requirements.txt", False, True, False),
("ci_requirements.txt", False, True, True),
("doc_requirements.txt", False, True, False),
("lint_requirements.txt", False, True, True),
("unittest_requirements.txt", False, True, True),
("functest_requirements.txt", False, True, True),
("clitest_requirements.txt", False, True, True),
]

errors = []

for filename, check_upperbound, check_prereleases, check_r in CHECK_MATRIX:
try:
with open(filename, "r") as fd:
for nr, line in enumerate(fd.readlines()):
line = line.strip()
if not line or line.startswith("#"):
continue
try:
req = Requirement.parse(line)
except ValueError:
if line.startswith("git+"):
# The single exception...
if "pulp-smash" not in line:
errors.append(f"{filename}:{nr}: Invalid source requirement: {line}")
elif line.startswith("-r "):
if check_r:
errors.append(f"{filename}:{nr}: Invalid deferred requirement: {line}")
else:
errors.append(f"{filename}:{nr}: Unreadable requirement {line}")
else:
if check_prereleases and req.specifier.prereleases:
# Do not even think about begging for more exceptions!
if (
not req.name.startswith("opentelemetry")
and req.name != "pulp-cookbook-client"
):
errors.append(f"{filename}:{nr}: Prerelease versions found in {line}.")
ops = [op for op, ver in req.specs]
spec = str(req.specs)
if "~=" in ops:
warnings.warn(f"{filename}:{nr}: Please avoid using ~= on {req.name}!")
elif "<" not in ops and "<=" not in ops and "==" not in ops:
if check_upperbound:
errors.append(f"{filename}:{nr}: Upper bound missing in {line}.")
except FileNotFoundError:
# skip this test for plugins that don't use this requirements.txt
pass

if errors:
print("Dependency issues found:")
print("\n".join(errors))
exit(1)
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# For more info visit https://github.com/pulp/plugin_template
[flake8]
exclude = ./docs/*,*/migrations/*
per-file-ignores = */__init__.py: F401

ignore = E203,W503,Q000,Q003,D100,D104,D106,D200,D205,D400,D401,D402
max-line-length = 100

Expand Down
2 changes: 1 addition & 1 deletion .github/template_gitref
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2021.08.26-179-g8af2847
2021.08.26-232-g10acbaa
4 changes: 1 addition & 3 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
# by default, it uses a depth of 1
# this fetches all history so that we can read each commit
fetch-depth: 0
fetch-depth: 1

- uses: actions/setup-python@v3
with:
Expand Down
Loading

0 comments on commit 9237fe8

Please sign in to comment.