Skip to content

Commit b68e010

Browse files
committed
Update CI files
1 parent 626256d commit b68e010

17 files changed

+176
-99
lines changed

.ci/ansible/Containerfile.j2

Lines changed: 2 additions & 1 deletion
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

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: 57 additions & 0 deletions
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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,16 @@
99
import sys
1010
from pathlib import Path
1111
import subprocess
12-
13-
1412
import os
1513
import warnings
1614
from github import Github
1715

18-
19-
NO_ISSUE = "[noissue]"
2016
CHANGELOG_EXTS = [".feature", ".bugfix", ".doc", ".removal", ".misc", ".deprecation"]
17+
KEYWORDS = ["fixes", "closes"]
18+
2119
sha = sys.argv[1]
2220
message = subprocess.check_output(["git", "log", "--format=%B", "-n 1", sha]).decode("utf-8")
2321

24-
25-
KEYWORDS = ["fixes", "closes"]
26-
2722
g = Github(os.environ.get("GITHUB_TOKEN"))
2823
repo = g.get_repo("pulp/pulp-certguard")
2924

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

7863
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-364-g6f9579c
1+
2021.08.26-382-gc88324b

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ jobs:
6464
- "check-commits"
6565
- "lint"
6666
- "test"
67+
- "docs"
6768
if: "always()"
6869
steps:
6970
- name: "Collect needed jobs results"

.github/workflows/create-branch.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,20 @@ jobs:
2626
fetch-depth: 0
2727
path: "pulp-certguard"
2828

29+
- uses: "actions/checkout@v4"
30+
with:
31+
fetch-depth: 1
32+
repository: "pulp/plugin_template"
33+
path: "plugin_template"
34+
2935
- uses: "actions/setup-python@v5"
3036
with:
3137
python-version: "3.11"
3238

3339
- name: "Install python dependencies"
3440
run: |
3541
echo ::group::PYDEPS
36-
pip install bump2version jinja2 pyyaml packaging
42+
pip install bump2version packaging -r plugin_template/requirements.txt
3743
echo ::endgroup::
3844
3945
- name: "Setting secrets"
@@ -71,13 +77,6 @@ jobs:
7177
run: |
7278
find CHANGES -type f -regex ".*\.\(bugfix\|doc\|feature\|misc\|deprecation\|removal\)" -exec git rm {} +
7379
74-
- name: Checkout plugin template
75-
uses: actions/checkout@v4
76-
with:
77-
repository: pulp/plugin_template
78-
path: plugin_template
79-
fetch-depth: 0
80-
8180
- name: Update CI branches in template_config
8281
working-directory: plugin_template
8382
run: |
@@ -94,10 +93,8 @@ jobs:
9493
branch: minor-version-bump
9594
base: main
9695
title: Bump minor version
97-
body: '[noissue]'
9896
commit-message: |
9997
Bump minor version
100-
[noissue]
10198
delete-branch: true
10299

103100
- name: Push release branch

.github/workflows/docs.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# WARNING: DO NOT EDIT!
2+
#
3+
# This file was generated by plugin_template, and is managed by it. Please use
4+
# './plugin-template --github pulp_certguard' to update this file.
5+
#
6+
# For more info visit https://github.com/pulp/plugin_template
7+
8+
---
9+
name: "Docs"
10+
on:
11+
workflow_call:
12+
13+
jobs:
14+
test:
15+
if: "endsWith(github.base_ref, 'main')"
16+
runs-on: "ubuntu-20.04"
17+
defaults:
18+
run:
19+
working-directory: "pulp-certguard"
20+
steps:
21+
- uses: "actions/checkout@v4"
22+
with:
23+
fetch-depth: 1
24+
path: "pulp-certguard"
25+
- uses: "actions/setup-python@v5"
26+
with:
27+
python-version: "3.11"
28+
- name: "Setup cache key"
29+
run: |
30+
git ls-remote https://github.com/pulp/pulp-docs main | tee pulp-docs-main-sha
31+
- uses: "actions/cache@v4"
32+
with:
33+
path: "~/.cache/pip"
34+
key: ${{ runner.os }}-pip-${{ hashFiles('pulp-docs-main-sha') }}
35+
restore-keys: |
36+
${{ runner.os }}-pip-
37+
- name: "Install python dependencies"
38+
run: |
39+
echo ::group::PYDEPS
40+
pip install -r doc_requirements.txt
41+
echo ::endgroup::
42+
- name: "Build changelog"
43+
run: |
44+
towncrier build --yes --version 4.0.0.ci
45+
- name: "Build docs"
46+
run: |
47+
pulp-docs build
48+
49+
no-test:
50+
if: "!endsWith(github.base_ref, 'main')"
51+
runs-on: "ubuntu-20.04"
52+
steps:
53+
- run: |
54+
echo "Skip docs testing on non-main branches."

.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: Certguard PR static checks
9+
name: "Certguard 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/before_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fi
5757

5858
for i in {1..3}
5959
do
60-
ansible-galaxy collection install "amazon.aws:1.5.0" && s=0 && break || s=$? && sleep 3
60+
ansible-galaxy collection install "amazon.aws:8.1.0" && s=0 && break || s=$? && sleep 3
6161
done
6262
if [[ $s -gt 0 ]]
6363
then

0 commit comments

Comments
 (0)