Skip to content

Commit 22f2c42

Browse files
authored
Merge pull request #741 from pulp/update-ci/3.11
Update CI files for branch 3.11
2 parents cc58995 + 7427e6c commit 22f2c42

File tree

15 files changed

+139
-57
lines changed

15 files changed

+139
-57
lines changed

.ci/ansible/Containerfile.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ADD ./{{ item.name }} ./{{ item.name }}
1212
# This MUST be the ONLY call to pip install in inside the container.
1313
RUN pip3 install --upgrade pip setuptools wheel && \
1414
rm -rf /root/.cache/pip && \
15-
pip3 install pipdeptree
15+
pip3 install
1616
{%- if s3_test | default(false) -%}
1717
{{ " " }}git+https://github.com/gerrod3/botocore.git@fix-100-continue
1818
{%- endif -%}

.ci/scripts/check_release.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def main():
6464
for branch in branches:
6565
if branch != DEFAULT_BRANCH:
6666
# Check if a Z release is needed
67+
reasons = []
6768
changes = repo.git.ls_tree("-r", "--name-only", f"origin/{branch}", "CHANGES/")
6869
z_changelog = False
6970
for change in changes.split("\n"):
@@ -76,23 +77,27 @@ def main():
7677
)
7778
elif ext in Z_CHANGELOG_EXTS:
7879
z_changelog = True
80+
if z_changelog:
81+
reasons.append("Backports")
7982

8083
last_tag = repo.git.describe("--tags", "--abbrev=0", f"origin/{branch}")
8184
req_txt_diff = repo.git.diff(
8285
f"{last_tag}", f"origin/{branch}", "--name-only", "--", "requirements.txt"
8386
)
84-
if z_changelog or req_txt_diff:
87+
if req_txt_diff:
88+
reasons.append("requirements.txt")
89+
90+
if reasons:
8591
curr_version = Version(last_tag)
8692
assert curr_version.base_version.startswith(
8793
branch
8894
), "Current-version has to belong to the current branch!"
8995
next_version = Version(f"{branch}.{curr_version.micro + 1}")
90-
reason = "CHANGES" if z_changelog else "requirements.txt"
9196
print(
9297
f"A Z-release is needed for {branch}, "
9398
f"Prev: {last_tag}, "
9499
f"Next: {next_version.base_version}, "
95-
f"Reason: {reason}"
100+
f"Reason: {','.join(reasons)}"
96101
)
97102
releases.append(next_version)
98103
else:

.ci/scripts/collect_changes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def main():
103103
for change in main_changes:
104104
fp.write(change[1])
105105

106-
repo.git.commit("-m", "Update Changelog", "-m" "[noissue]", CHANGELOG_FILE)
106+
repo.git.commit("-m", "Update Changelog", CHANGELOG_FILE)
107107

108108

109109
if __name__ == "__main__":

.ci/scripts/pr_labels.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/env python3
2+
3+
# This script is running with elevated privileges from the main branch against pull requests.
4+
5+
import re
6+
import sys
7+
import tomllib
8+
from pathlib import Path
9+
10+
from git import Repo
11+
12+
13+
def main():
14+
assert len(sys.argv) == 3
15+
16+
with open("pyproject.toml", "rb") as fp:
17+
PYPROJECT_TOML = tomllib.load(fp)
18+
BLOCKING_REGEX = re.compile(r"DRAFT|WIP|NO\s*MERGE|DO\s*NOT\s*MERGE|EXPERIMENT")
19+
ISSUE_REGEX = re.compile(r"(?:fixes|closes)[\s:]+#(\d+)")
20+
CHERRY_PICK_REGEX = re.compile(r"^\s*\(cherry picked from commit [0-9a-f]*\)\s*$")
21+
try:
22+
CHANGELOG_EXTS = {
23+
f".{item['directory']}" for item in PYPROJECT_TOML["tool"]["towncrier"]["type"]
24+
}
25+
except KeyError:
26+
CHANGELOG_EXTS = {".feature", ".bugfix", ".doc", ".removal", ".misc"}
27+
28+
repo = Repo(".")
29+
30+
base_commit = repo.commit(sys.argv[1])
31+
head_commit = repo.commit(sys.argv[2])
32+
33+
pr_commits = list(repo.iter_commits(f"{base_commit}..{head_commit}"))
34+
35+
labels = {
36+
"multi-commit": len(pr_commits) > 1,
37+
"cherry-pick": False,
38+
"no-issue": False,
39+
"no-changelog": False,
40+
"wip": False,
41+
}
42+
for commit in pr_commits:
43+
labels["wip"] |= BLOCKING_REGEX.search(commit.summary) is not None
44+
no_issue = ISSUE_REGEX.search(commit.message, re.IGNORECASE) is None
45+
labels["no-issue"] |= no_issue
46+
cherry_pick = CHERRY_PICK_REGEX.search(commit.message) is not None
47+
labels["cherry-pick"] |= cherry_pick
48+
changelog_snippets = [
49+
k
50+
for k in commit.stats.files
51+
if k.startswith("CHANGES/") and Path(k).suffix in CHANGELOG_EXTS
52+
]
53+
labels["no-changelog"] |= not changelog_snippets
54+
55+
print("ADD_LABELS=" + ",".join((k for k, v in labels.items() if v)))
56+
print("REMOVE_LABELS=" + ",".join((k for k, v in labels.items() if not v)))
57+
58+
59+
if __name__ == "__main__":
60+
main()

.ci/scripts/validate_commit_message.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import warnings
1414
from github import Github
1515

16-
NO_ISSUE = "[noissue]"
1716
CHANGELOG_EXTS = [".feature", ".bugfix", ".doc", ".removal", ".misc", ".deprecation"]
1817
KEYWORDS = ["fixes", "closes"]
1918

@@ -60,15 +59,5 @@ def __check_changelog(issue):
6059
for issue in pattern.findall(message):
6160
__check_status(issue)
6261
__check_changelog(issue)
63-
else:
64-
if NO_ISSUE in message:
65-
print("Commit {sha} has no issues but is tagged {tag}.".format(sha=sha[0:7], tag=NO_ISSUE))
66-
elif "Merge" in message and "cherry picked from commit" in message:
67-
pass
68-
else:
69-
sys.exit(
70-
"Error: no attached issues found for {sha}. If this was intentional, add "
71-
" '{tag}' to the commit message.".format(sha=sha[0:7], tag=NO_ISSUE)
72-
)
7362

7463
print("Commit message for {sha} passed.".format(sha=sha[0:7]))

.github/template_gitref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2021.08.26-380-g46e00a5
1+
2021.08.26-388-g624de1a

.github/workflows/create-branch.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,8 @@ jobs:
9393
branch: minor-version-bump
9494
base: main
9595
title: Bump minor version
96-
body: '[noissue]'
9796
commit-message: |
9897
Bump minor version
99-
[noissue]
10098
delete-branch: true
10199

102100
- name: Push release branch

.github/workflows/pr_checks.yml

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,57 +6,62 @@
66
# For more info visit https://github.com/pulp/plugin_template
77

88
---
9-
name: Python PR static checks
9+
name: "Python PR static checks"
1010
on:
1111
pull_request_target:
12-
types: [opened, synchronize, reopened]
12+
types: ["opened", "synchronize", "reopened"]
1313

1414
# This workflow runs with elevated permissions.
1515
# Do not even think about running a single bit of code from the PR.
1616
# Static analysis should be fine however.
1717

1818
concurrency:
19-
group: ${{ github.event.pull_request.number }}-${{ github.workflow }}
19+
group: "${{ github.event.pull_request.number }}-${{ github.workflow }}"
2020
cancel-in-progress: true
2121

2222
jobs:
23-
single_commit:
24-
runs-on: ubuntu-latest
25-
name: Label multiple commit PR
23+
apply_labels:
24+
runs-on: "ubuntu-latest"
25+
name: "Label PR"
2626
permissions:
27-
pull-requests: write
27+
pull-requests: "write"
2828
steps:
2929
- uses: "actions/checkout@v4"
3030
with:
3131
fetch-depth: 0
32-
- name: Commit Count Check
32+
- uses: "actions/setup-python@v5"
33+
with:
34+
python-version: "3.11"
35+
- name: "Determine PR labels"
3336
run: |
37+
pip install GitPython==3.1.42
3438
git fetch origin ${{ github.event.pull_request.head.sha }}
35-
echo "COMMIT_COUNT=$(git log --oneline --no-merges origin/${{ github.base_ref }}..${{ github.event.pull_request.head.sha }} | wc -l)" >> "$GITHUB_ENV"
36-
- uses: actions/github-script@v7
39+
python .ci/scripts/pr_labels.py "origin/${{ github.base_ref }}" "${{ github.event.pull_request.head.sha }}" >> "$GITHUB_ENV"
40+
- uses: "actions/github-script@v7"
41+
name: "Apply PR Labels"
3742
with:
3843
script: |
39-
const labelName = "multi-commit";
40-
const { COMMIT_COUNT } = process.env;
44+
const { ADD_LABELS, REMOVE_LABELS } = process.env;
4145
42-
if (COMMIT_COUNT == 1)
43-
{
44-
try {
45-
await github.rest.issues.removeLabel({
46-
issue_number: context.issue.number,
47-
owner: context.repo.owner,
48-
repo: context.repo.repo,
49-
name: labelName,
50-
});
51-
} catch(err) {
46+
if (REMOVE_LABELS.length) {
47+
for await (const labelName of REMOVE_LABELS.split(",")) {
48+
try {
49+
await github.rest.issues.removeLabel({
50+
issue_number: context.issue.number,
51+
owner: context.repo.owner,
52+
repo: context.repo.repo,
53+
name: labelName,
54+
});
55+
} catch(err) {
56+
}
5257
}
5358
}
54-
else
55-
{
59+
if (ADD_LABELS.length) {
5660
await github.rest.issues.addLabels({
5761
issue_number: context.issue.number,
5862
owner: context.repo.owner,
5963
repo: context.repo.repo,
60-
labels: [labelName],
64+
labels: ADD_LABELS.split(","),
6165
});
6266
}
67+
...

.github/workflows/scripts/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,5 @@ if [[ "$TEST" = "azure" ]]; then
156156
fi
157157

158158
echo ::group::PIP_LIST
159-
cmd_prefix bash -c "pip3 list && pipdeptree"
159+
cmd_prefix bash -c "pip3 list"
160160
echo ::endgroup::

.github/workflows/scripts/script.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ pushd ../pulp-openapi-generator
4646

4747
# Workaround: Domains are not supported by the published bindings.
4848
# Sadly: Different pulpcore-versions aren't either...
49-
# So we exclude the prebuilt ones only for domains disabled.
50-
if [ "$(jq -r '.domain_enabled' <<<"${REPORTED_STATUS}")" = "true" ] || [ "$(jq -r '.online_workers[0].pulp_href|startswith("/pulp/api/v3/")' <<< "${REPORTED_STATUS}")" = "false" ]
49+
# * In the 'pulp' scenario we use the published/prebuilt bindings, so we can test it.
50+
# * In other scenarios we generate new bindings from server spec, so we have a more
51+
# reliable client.
52+
if [ "$TEST" = "pulp" ]
5153
then
52-
BUILT_CLIENTS=""
53-
else
5454
BUILT_CLIENTS=" python "
55+
else
56+
BUILT_CLIENTS=""
5557
fi
5658

5759
for ITEM in $(jq -r '.versions[] | tojson' <<<"${REPORTED_STATUS}")

0 commit comments

Comments
 (0)