Skip to content

Commit f895e09

Browse files
authored
Merge pull request #738 from pulp/update-ci/main
Update CI files for branch main
2 parents 21e445a + f115843 commit f895e09

10 files changed

+94
-59
lines changed

.ci/ansible/Containerfile.j2

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ ADD ./{{ item.name }} ./{{ item.name }}
99
# S3 botocore needs to be patched to handle responses from minio during 0-byte uploads
1010
# Hacking botocore (https://github.com/boto/botocore/pull/1990)
1111

12+
# This MUST be the ONLY call to pip install in inside the container.
1213
RUN pip3 install --upgrade pip setuptools wheel && \
1314
rm -rf /root/.cache/pip && \
14-
pip3 install
15+
pip3 install pipdeptree
1516
{%- if s3_test | default(false) -%}
1617
{{ " " }}git+https://github.com/gerrod3/botocore.git@fix-100-continue
1718
{%- endif -%}

.ci/scripts/collect_changes.py

+1-1
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

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
CHANGELOG_EXTS = [
22+
f".{item['directory']}" for item in PYPROJECT_TOML["tool"]["towncrier"]["type"]
23+
]
24+
25+
repo = Repo(".")
26+
27+
base_commit = repo.commit(sys.argv[1])
28+
head_commit = repo.commit(sys.argv[2])
29+
30+
pr_commits = list(repo.iter_commits(f"{base_commit}..{head_commit}"))
31+
32+
labels = {
33+
"multi-commit": len(pr_commits) > 1,
34+
"cherry-pick": False,
35+
"no-issue": False,
36+
"no-changelog": False,
37+
"wip": False,
38+
}
39+
for commit in pr_commits:
40+
labels["wip"] |= BLOCKING_REGEX.search(commit.summary) is not None
41+
no_issue = ISSUE_REGEX.search(commit.message, re.IGNORECASE) is None
42+
labels["no-issue"] |= no_issue
43+
cherry_pick = CHERRY_PICK_REGEX.search(commit.message) is not None
44+
labels["cherry-pick"] |= cherry_pick
45+
changelog_snippets = [
46+
k
47+
for k in commit.stats.files
48+
if k.startswith("CHANGES/") and Path(k).suffix in CHANGELOG_EXTS
49+
]
50+
labels["no-changelog"] |= not changelog_snippets
51+
52+
print("ADD_LABELS=" + ",".join((k for k, v in labels.items() if v)))
53+
print("REMOVE_LABELS=" + ",".join((k for k, v in labels.items() if not v)))
54+
55+
56+
if __name__ == "__main__":
57+
main()

.ci/scripts/validate_commit_message.py

-11
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2021.08.26-379-gece49c9
1+
2021.08.26-382-gc88324b

.github/workflows/create-branch.yml

-2
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

+30-25
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

+1-1
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 && pip3 install pipdeptree && pipdeptree"
159+
cmd_prefix bash -c "pip3 list && pipdeptree"
160160
echo ::endgroup::

.github/workflows/update_ci.yml

+1-15
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,8 @@ jobs:
6262
committer: "pulpbot <[email protected]>"
6363
author: "pulpbot <[email protected]>"
6464
title: "Update CI files for branch main"
65-
body: ""
6665
branch: "update-ci/main"
6766
base: "main"
68-
commit-message: |
69-
Update CI files
70-
71-
[noissue]
7267
delete-branch: true
7368
- uses: "actions/checkout@v4"
7469
with:
@@ -89,13 +84,8 @@ jobs:
8984
committer: "pulpbot <[email protected]>"
9085
author: "pulpbot <[email protected]>"
9186
title: "Update CI files for branch 3.12"
92-
body: ""
9387
branch: "update-ci/3.12"
9488
base: "3.12"
95-
commit-message: |
96-
Update CI files
97-
98-
[noissue]
9989
delete-branch: true
10090
- uses: "actions/checkout@v4"
10191
with:
@@ -116,11 +106,7 @@ jobs:
116106
committer: "pulpbot <[email protected]>"
117107
author: "pulpbot <[email protected]>"
118108
title: "Update CI files for branch 3.11"
119-
body: ""
120109
branch: "update-ci/3.11"
121110
base: "3.11"
122-
commit-message: |
123-
Update CI files
124-
125-
[noissue]
126111
delete-branch: true
112+
...

template_config.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This config represents the latest values used when running the plugin-template. Any settings that
22
# were not present before running plugin-template have been added with their default values.
33

4-
# generated with [email protected]378-g72f4b38
4+
# generated with [email protected]382-gc88324b
55

66
api_root: /pulp/
77
black: false
@@ -25,7 +25,6 @@ flake8_ignore: []
2525
github_org: pulp
2626
latest_release_branch: '3.12'
2727
lint_requirements: true
28-
noissue_marker: '[noissue]'
2928
os_required_packages: []
3029
parallel_test_workers: 8
3130
plugin_app_label: python

0 commit comments

Comments
 (0)