Skip to content

Commit d6a4a11

Browse files
committed
Update CI files
1 parent d297bc4 commit d6a4a11

15 files changed

Lines changed: 305 additions & 234 deletions

.ci/assets/ci_constraints.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Pulpcore versions without the openapi command do no longer work in the CI
2-
pulpcore>=3.21.30,!=3.23.*,!=3.24.*,!=3.25.*,!=3.26.*,!=3.27.*,!=3.29.*,!=3.30.*,!=3.31.*,!=3.32.*,!=3.33.*,!=3.34.*,!=3.35.*,!=3.36.*,!=3.37.*,!=3.38.*,!=3.40.*,!=3.41.*,!=3.42.*,!=3.43.*,!=3.44.*,!=3.45.*,!=3.46.*,!=3.47.*,!=3.48.*,!=3.50.*,!=3.51.*,!=3.52.*,!=3.53.*,!=3.54.*
2+
# Pulpcore versions without the django 5 storage compatibility will fail, >3.63,<3.70
3+
pulpcore>=3.21.30,!=3.23.*,!=3.24.*,!=3.25.*,!=3.26.*,!=3.27.*,!=3.29.*,!=3.30.*,!=3.31.*,!=3.32.*,!=3.33.*,!=3.34.*,!=3.35.*,!=3.36.*,!=3.37.*,!=3.38.*,!=3.40.*,!=3.41.*,!=3.42.*,!=3.43.*,!=3.44.*,!=3.45.*,!=3.46.*,!=3.47.*,!=3.48.*,!=3.50.*,!=3.51.*,!=3.52.*,!=3.53.*,!=3.54.*,!=3.64.*,!=3.65.*,!=3.66.*,!=3.67.*,!=3.68.*,!=3.69.*
34

45

56
tablib!=3.6.0
@@ -8,3 +9,11 @@ tablib!=3.6.0
89

910
multidict!=6.3.0
1011
# This release failed the lower bounds test for some case sensitivity in CIMultiDict.
12+
13+
14+
azure-storage-blob!=12.28.*
15+
# Apparently does not work with current azurite.
16+
17+
18+
pycares<5
19+
# older aiodns versions don't pin pycares UB, and are broken by pycares>=5

.ci/scripts/check_release.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
#!/usr/bin/env python
2+
# /// script
3+
# requires-python = ">=3.13"
4+
# dependencies = [
5+
# "gitpython>=3.1.46,<3.2.0",
6+
# "packaging>=26.0,<26.1",
7+
# "pyyaml>=6.0.3,<6.1.0",
8+
# ]
9+
# ///
210

311
import argparse
412
import re
513
import os
14+
import sys
615
import tomllib
7-
import yaml
16+
import typing as t
817
from pathlib import Path
18+
19+
import yaml
920
from packaging.version import Version
1021
from git import Repo
1122

@@ -14,7 +25,7 @@
1425
Z_CHANGELOG_EXTS = [".bugfix", ".misc"]
1526

1627

17-
def options():
28+
def options() -> argparse.Namespace:
1829
"""Check which branches need a release."""
1930
parser = argparse.ArgumentParser()
2031
parser.add_argument(
@@ -33,13 +44,13 @@ def options():
3344
return parser.parse_args()
3445

3546

36-
def template_config():
47+
def template_config() -> dict[str, t.Any]:
3748
# Assume this script lies in .ci/scripts
3849
path = Path(__file__).absolute().parent.parent.parent / "template_config.yml"
3950
return yaml.safe_load(path.read_text())
4051

4152

42-
def current_version(repo, commitish):
53+
def current_version(repo: Repo, commitish: str) -> Version:
4354
try:
4455
pyproject_toml = tomllib.loads(repo.git.show(f"{commitish}:pyproject.toml"))
4556
try:
@@ -53,7 +64,7 @@ def current_version(repo, commitish):
5364
return Version(current_version)
5465

5566

56-
def check_pyproject_dependencies(repo, from_commit, to_commit):
67+
def check_pyproject_dependencies(repo: Repo, from_commit: str, to_commit: str) -> list[str]:
5768
try:
5869
new_pyproject = tomllib.loads(repo.git.show(f"{to_commit}:pyproject.toml"))
5970
try:
@@ -74,8 +85,8 @@ def check_pyproject_dependencies(repo, from_commit, to_commit):
7485
return ["pyproject.toml changed somehow (PLEASE check if dependencies are affected)."]
7586

7687

77-
def main(options, template_config):
78-
DEFAULT_BRANCH = template_config["plugin_default_branch"]
88+
def main(options: argparse.Namespace, template_config: dict[str, t.Any]) -> int:
89+
DEFAULT_BRANCH: str = template_config["plugin_default_branch"]
7990

8091
repo = Repo()
8192

@@ -88,7 +99,7 @@ def main(options, template_config):
8899

89100
# Warning: This will not work if branch names contain "/" but we don't really care here.
90101
heads = [h.split("/")[-1] for h in repo.git.branch("--remote").split("\n")]
91-
available_branches = [h for h in heads if re.search(RELEASE_BRANCH_REGEX, h)]
102+
available_branches = [h for h in heads if re.fullmatch(RELEASE_BRANCH_REGEX, h)]
92103
available_branches.sort(key=lambda ver: Version(ver))
93104
available_branches.append(DEFAULT_BRANCH)
94105

@@ -105,7 +116,10 @@ def main(options, template_config):
105116

106117
if diff := branches - set(available_branches):
107118
print(f"Supplied branches contains non-existent branches! {diff}")
108-
exit(1)
119+
return 1
120+
121+
branches = [branch for branch in available_branches if branch in branches]
122+
branches.reverse()
109123

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

@@ -170,6 +184,8 @@ def main(options, template_config):
170184
if len(releases) == 0:
171185
print("No new releases to perform.")
172186

187+
return 0
188+
173189

174190
if __name__ == "__main__":
175-
main(options(), template_config())
191+
sys.exit(main(options(), template_config()))
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python3
2+
# This script is running with elevated privileges from the main branch against pull requests.
3+
#
4+
# It cleans the input from artifacts which are used by the pulp documentation internally,
5+
# but clutter for GitHub releases
6+
7+
import sys
8+
9+
NOTE = """
10+
> [!NOTE]
11+
> Official changes are available on [Pulp docs]({docs_url})\
12+
"""
13+
14+
15+
def main():
16+
plugin_name = sys.argv[1]
17+
version_str = sys.argv[2]
18+
docs_url = f"https://pulpproject.org/{plugin_name}/changes/#{version_str}"
19+
note_added = False
20+
for line in sys.stdin:
21+
if line.endswith("\n"):
22+
line = line[:-1]
23+
if line.startswith("#"):
24+
print(line.split(" {: #")[0])
25+
if not note_added and version_str in line:
26+
print(NOTE.format(docs_url=docs_url))
27+
note_added = True
28+
else:
29+
print(line)
30+
31+
32+
if __name__ == "__main__":
33+
main()

.ci/scripts/collect_changes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
#!/bin/env python3
2+
# /// script
3+
# requires-python = ">=3.13"
4+
# dependencies = [
5+
# "gitpython>=3.1.46,<3.2.0",
6+
# "packaging>=26.0,<26.1",
7+
# ]
8+
# ///
9+
210
# WARNING: DO NOT EDIT!
311
#
412
# This file was generated by plugin_template, and is managed by it. Please use

.github/pull_request_template.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!---
2+
Thank you for submitting a PR to the Pulp Project!
3+
4+
If this is your first time contributing, please read the Pull Request Walkthrough documentation
5+
(https://pulpproject.org/pulpcore/docs/dev/guides/pull-request-walkthrough/).
6+
-->
7+
8+
### 📜 Checklist
9+
10+
- [ ] Commits are cleanly separated with meaningful messages (simple features and bug fixes should be [squashed](https://pulpproject.org/pulpcore/docs/dev/guides/git/#rebasing-and-squashing) to one commit)
11+
- [ ] A [changelog entry](https://pulpproject.org/pulpcore/docs/dev/guides/git/#changelog-update) or entries has been added for any significant changes
12+
- [ ] Follows the [Pulp policy on AI Usage](https://pulpproject.org/help/more/governance/ai_policy/)
13+
- [ ] (For new features) - User documentation and test coverage has been added
14+
15+
See: [Pull Request Walkthrough](https://pulpproject.org/pulpcore/docs/dev/guides/pull-request-walkthrough/)

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ jobs:
9494
run_docs: ${{ needs.check-changes.outputs.run_docs }}
9595

9696
lint:
97-
needs:
98-
- "check-changes"
99-
if: needs.check-changes.outputs.run_tests == '1'
10097
uses: "./.github/workflows/lint.yml"
10198

10299
build:
103-
needs: "lint"
100+
needs:
101+
- "check-changes"
102+
- "lint"
103+
if: needs.check-changes.outputs.run_tests == '1'
104104
uses: "./.github/workflows/build.yml"
105105

106106
test:

.github/workflows/nightly.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,20 @@ jobs:
6161

6262
- name: Create Pull Request
6363
uses: peter-evans/create-pull-request@v6
64+
id: "create_pr_changelog"
6465
with:
6566
token: ${{ secrets.RELEASE_TOKEN }}
6667
title: "Update Changelog"
6768
body: ""
6869
branch: "changelog/update"
6970
delete-branch: true
7071
path: "pulp_container"
72+
- name: "Mark PR automerge"
73+
working-directory: "pulp_container"
74+
run: |
75+
gh pr merge --rebase --auto "${{ steps.create_pr_changelog.outputs.pull-request-number }}"
76+
if: "steps.create_pr_changelog.outputs.pull-request-number"
77+
env:
78+
GH_TOKEN: "${{ secrets.RELEASE_TOKEN }}"
79+
continue-on-error: true
7180
...

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
run: |
137137
# The last commit before the release commit contains the release CHANGES fragments
138138
git checkout "${TAG_NAME}~"
139-
NOTES=$(towncrier build --draft --version $TAG_NAME)
139+
NOTES=$(towncrier build --draft --version $TAG_NAME | .ci/scripts/clean_gh_release_notes.py pulp_container $TAG_NAME)
140140
echo "body<<EOF" >> $GITHUB_OUTPUT
141141
echo "$NOTES" >> $GITHUB_OUTPUT
142142
echo "EOF" >> $GITHUB_OUTPUT

.github/workflows/scripts/before_install.sh

Lines changed: 102 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,66 +7,124 @@
77
#
88
# For more info visit https://github.com/pulp/plugin_template
99

10+
# This script prepares the scenario definition in the .ci/ansible/vars/main.yaml file.
11+
#
12+
# It requires the following environment:
13+
# TEST - The name of the scenario to prepare.
14+
#
15+
# It may also dump the {lower,upper}bounds_constraints.txt for the specific scenario.
16+
17+
set -eu -o pipefail
18+
1019
# make sure this script runs at the repo root
1120
cd "$(dirname "$(realpath -e "$0")")"/../../..
1221

13-
set -mveuo pipefail
22+
if [ -f .github/workflows/scripts/pre_before_install.sh ]; then
23+
source .github/workflows/scripts/pre_before_install.sh
24+
fi
1425

15-
if [ "${GITHUB_REF##refs/heads/}" = "${GITHUB_REF}" ]
16-
then
17-
BRANCH_BUILD=0
18-
else
19-
BRANCH_BUILD=1
20-
BRANCH="${GITHUB_REF##refs/heads/}"
26+
COMPONENT_VERSION="$(bump-my-version show current_version | tail -n -1 | python -c 'from packaging.version import Version; print(Version(input()))')"
27+
COMPONENT_SOURCE="./pulp_container/dist/pulp_container-${COMPONENT_VERSION}-py3-none-any.whl"
28+
if [ "$TEST" = "s3" ]; then
29+
COMPONENT_SOURCE="${COMPONENT_SOURCE} pulpcore[s3]"
2130
fi
22-
if [ "${GITHUB_REF##refs/tags/}" = "${GITHUB_REF}" ]
23-
then
24-
TAG_BUILD=0
25-
else
26-
TAG_BUILD=1
27-
BRANCH="${GITHUB_REF##refs/tags/}"
31+
if [ "$TEST" = "azure" ]; then
32+
COMPONENT_SOURCE="${COMPONENT_SOURCE} pulpcore[azure]"
2833
fi
2934

30-
COMMIT_MSG=$(git log --format=%B --no-merges -1)
31-
export COMMIT_MSG
35+
if [[ "$TEST" = "pulp" ]]; then
36+
python3 .ci/scripts/calc_constraints.py -u requirements.txt > upperbounds_constraints.txt
37+
fi
38+
if [[ "$TEST" = "lowerbounds" ]]; then
39+
python3 .ci/scripts/calc_constraints.py requirements.txt > lowerbounds_constraints.txt
40+
fi
41+
export PULP_API_ROOT=$(test "${TEST}" = "s3" && echo "/rerouted/djnd/" || echo "/pulp/")
3242

33-
COMPONENT_VERSION=$(sed -ne "s/\s*version.*=.*['\"]\(.*\)['\"][\s,]*/\1/p" setup.py)
43+
echo "PULP_API_ROOT=${PULP_API_ROOT}" >> "$GITHUB_ENV"
3444

35-
mkdir .ci/ansible/vars || true
36-
echo "---" > .ci/ansible/vars/main.yaml
37-
echo "legacy_component_name: pulp_container" >> .ci/ansible/vars/main.yaml
38-
echo "component_name: container" >> .ci/ansible/vars/main.yaml
39-
echo "component_version: '${COMPONENT_VERSION}'" >> .ci/ansible/vars/main.yaml
45+
# Compose the scenario definition.
46+
mkdir -p .ci/ansible/vars
4047

41-
export PRE_BEFORE_INSTALL=$PWD/.github/workflows/scripts/pre_before_install.sh
42-
export POST_BEFORE_INSTALL=$PWD/.github/workflows/scripts/post_before_install.sh
48+
cat > .ci/ansible/vars/main.yaml << VARSYAML
49+
---
50+
scenario: "${TEST}"
51+
legacy_component_name: "pulp_container"
52+
component_name: "container"
53+
component_version: "${COMPONENT_VERSION}"
54+
pulp_env: {}
55+
pulp_settings: {"allowed_content_checksums": ["sha1", "sha224", "sha256", "sha384", "sha512"], "allowed_export_paths": ["/tmp"], "allowed_import_paths": ["/tmp"]}
56+
pulp_scheme: "https"
57+
pulp_default_container: "ghcr.io/pulp/pulp-ci-centos:latest"
58+
api_root: "${PULP_API_ROOT}"
59+
image:
60+
name: "pulp"
61+
tag: "ci_build"
62+
plugins:
63+
- name: "pulp_container"
64+
source: "${COMPONENT_SOURCE}"
65+
ci_requirements: $(test -f ci_requirements.txt && echo -n true || echo -n false)
66+
upperbounds: $(test "${TEST}" = "pulp" && echo -n true || echo -n false)
67+
lowerbounds: $(test "${TEST}" = "lowerbounds" && echo -n true || echo -n false)
68+
services:
69+
- name: "pulp"
70+
image: "pulp:ci_build"
71+
volumes:
72+
- "./settings:/etc/pulp"
73+
- "./ssh:/keys/"
74+
- "~/.config:/var/lib/pulp/.config"
75+
- "../../../pulp-openapi-generator:/root/pulp-openapi-generator"
76+
env:
77+
PULP_WORKERS: "4"
78+
PULP_HTTPS: "true"
79+
VARSYAML
4380

44-
if [ -f $PRE_BEFORE_INSTALL ]; then
45-
source $PRE_BEFORE_INSTALL
81+
if [ "$TEST" = "s3" ]; then
82+
MINIO_ACCESS_KEY=AKIAIT2Z5TDYPX3ARJBA
83+
MINIO_SECRET_KEY=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
84+
cat >> .ci/ansible/vars/main.yaml << VARSYAML
85+
- name: "minio"
86+
image: "minio/minio"
87+
env:
88+
MINIO_ACCESS_KEY: "${MINIO_ACCESS_KEY}"
89+
MINIO_SECRET_KEY: "${MINIO_SECRET_KEY}"
90+
command: "server /data"
91+
s3_test: true
92+
minio_access_key: "${MINIO_ACCESS_KEY}"
93+
minio_secret_key: "${MINIO_SECRET_KEY}"
94+
pulp_scenario_settings: {"AWS_ACCESS_KEY_ID": "AKIAIT2Z5TDYPX3ARJBA", "AWS_DEFAULT_ACL": "@none None", "AWS_S3_ADDRESSING_STYLE": "path", "AWS_S3_ENDPOINT_URL": "http://minio:9000", "AWS_S3_REGION_NAME": "eu-central-1", "AWS_S3_SIGNATURE_VERSION": "s3v4", "AWS_SECRET_ACCESS_KEY": "fqRvjWaPU5o0fCqQuUWbj9Fainj2pVZtBCiDiieS", "AWS_STORAGE_BUCKET_NAME": "pulp3", "DEFAULT_FILE_STORAGE": "storages.backends.s3boto3.S3Boto3Storage", "MEDIA_ROOT": ""}
95+
pulp_scenario_env: {}
96+
VARSYAML
4697
fi
4798

48-
if [ "$GITHUB_EVENT_NAME" = "pull_request" ] || [ "${BRANCH_BUILD}" = "1" -a "${BRANCH}" != "main" ]
49-
then
50-
echo $COMMIT_MSG | sed -n -e 's/.*CI Base Image:\s*\([-_/[:alnum:]]*:[-_[:alnum:]]*\).*/ci_base: "\1"/p' >> .ci/ansible/vars/main.yaml
99+
if [ "$TEST" = "azure" ]; then
100+
cat >> .ci/ansible/vars/main.yaml << VARSYAML
101+
- name: "ci-azurite"
102+
image: "mcr.microsoft.com/azure-storage/azurite"
103+
command: "azurite-blob --skipApiVersionCheck --blobHost 0.0.0.0"
104+
azure_test: true
105+
pulp_scenario_settings: {"AZURE_ACCOUNT_KEY": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==", "AZURE_ACCOUNT_NAME": "devstoreaccount1", "AZURE_CONNECTION_STRING": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://ci-azurite:10000/devstoreaccount1;", "AZURE_CONTAINER": "pulp-test", "AZURE_LOCATION": "pulp3", "AZURE_OVERWRITE_FILES": true, "AZURE_URL_EXPIRATION_SECS": 120, "DEFAULT_FILE_STORAGE": "storages.backends.azure_storage.AzureStorage", "MEDIA_ROOT": ""}
106+
pulp_scenario_env: {}
107+
VARSYAML
51108
fi
52109

53-
for i in {1..3}
54-
do
55-
ansible-galaxy collection install "amazon.aws:8.1.0" && s=0 && break || s=$? && sleep 3
56-
done
57-
if [[ $s -gt 0 ]]
58-
then
59-
echo "Failed to install amazon.aws"
60-
exit $s
110+
if [ "$TEST" = "gcp" ]; then
111+
cat >> .ci/ansible/vars/main.yaml << VARSYAML
112+
- name: "ci-gcp"
113+
image: "fsouza/fake-gcs-server"
114+
volumes:
115+
- "storage_data:/etc/pulp"
116+
command: " -scheme http"
117+
gcp_test: true
118+
pulp_scenario_settings: null
119+
pulp_scenario_env: {}
120+
VARSYAML
61121
fi
62122

63-
if [[ "$TEST" = "pulp" ]]; then
64-
python3 .ci/scripts/calc_constraints.py -u requirements.txt > upperbounds_constraints.txt
65-
fi
66-
if [[ "$TEST" = "lowerbounds" ]]; then
67-
python3 .ci/scripts/calc_constraints.py requirements.txt > lowerbounds_constraints.txt
68-
fi
123+
cat >> .ci/ansible/vars/main.yaml << VARSYAML
124+
...
125+
VARSYAML
126+
cat .ci/ansible/vars/main.yaml
69127

70-
if [ -f $POST_BEFORE_INSTALL ]; then
71-
source $POST_BEFORE_INSTALL
128+
if [ -f .github/workflows/scripts/post_before_install.sh ]; then
129+
source .github/workflows/scripts/post_before_install.sh
72130
fi

0 commit comments

Comments
 (0)