Skip to content

Commit c0b77f2

Browse files
committed
chore(ci): add Dependabot grouping, PR auto-labeler, and PR size warning
- Group Dependabot Go module updates: k8s.io/* together, remaining minor/patch together. Group all GitHub Actions updates into a single PR. Reduces weekly Dependabot PR noise from ~13 individual PRs to ~3. - Add actions/labeler workflow to auto-label PRs by changed paths (area/api, area/controller, area/helm, area/ci, area/docs, area/e2e, area/cli). - Add PR size labeler (xs/s/m/l/xl) with a warning comment on XL PRs (500+ lines) suggesting a split. Closes #65 Closes #62 Closes #73 Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent de76adc commit c0b77f2

4 files changed

Lines changed: 128 additions & 0 deletions

File tree

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ updates:
99
open-pull-requests-limit: 5
1010
commit-message:
1111
prefix: "chore(deps)"
12+
groups:
13+
k8s:
14+
patterns:
15+
- "k8s.io/*"
16+
- "sigs.k8s.io/*"
17+
go-minor:
18+
update-types:
19+
- "minor"
20+
- "patch"
21+
exclude-patterns:
22+
- "k8s.io/*"
23+
- "sigs.k8s.io/*"
1224

1325
- package-ecosystem: github-actions
1426
directory: /
@@ -19,6 +31,10 @@ updates:
1931
open-pull-requests-limit: 5
2032
commit-message:
2133
prefix: "chore(deps)"
34+
groups:
35+
actions:
36+
patterns:
37+
- "*"
2238

2339
- package-ecosystem: docker
2440
directory: /

.github/labeler.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
area/api:
2+
- changed-files:
3+
- any-glob-to-any-file: "api/**"
4+
5+
area/controller:
6+
- changed-files:
7+
- any-glob-to-any-file: "internal/**"
8+
9+
area/helm:
10+
- changed-files:
11+
- any-glob-to-any-file: "charts/**"
12+
13+
area/ci:
14+
- changed-files:
15+
- any-glob-to-any-file:
16+
- ".github/**"
17+
- "Makefile"
18+
19+
area/docs:
20+
- changed-files:
21+
- any-glob-to-any-file:
22+
- "docs/**"
23+
- "*.md"
24+
25+
area/e2e:
26+
- changed-files:
27+
- any-glob-to-any-file:
28+
- "test/**"
29+
- ".chainsaw.yaml"
30+
31+
area/cli:
32+
- changed-files:
33+
- any-glob-to-any-file: "cmd/kubectl-attune/**"

.github/workflows/labeler.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: PR Labeler
2+
on:
3+
pull_request_target:
4+
types: [opened, synchronize]
5+
6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
10+
jobs:
11+
label:
12+
name: Auto-label PR
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
steps:
16+
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
17+
with:
18+
egress-policy: audit
19+
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
20+
with:
21+
configuration-path: .github/labeler.yml
22+
sync-labels: true

.github/workflows/pr-size.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: PR Size
2+
on:
3+
pull_request_target:
4+
types: [opened, synchronize]
5+
6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
10+
jobs:
11+
size-label:
12+
name: Label PR size
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
steps:
16+
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
17+
with:
18+
egress-policy: audit
19+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
20+
with:
21+
fetch-depth: 0
22+
ref: ${{ github.event.pull_request.head.sha }}
23+
- name: Calculate diff size and apply label
24+
env:
25+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
PR_NUMBER: ${{ github.event.pull_request.number }}
27+
run: |
28+
ADDITIONS=${{ github.event.pull_request.additions }}
29+
DELETIONS=${{ github.event.pull_request.deletions }}
30+
TOTAL=$((ADDITIONS + DELETIONS))
31+
32+
if [ "$TOTAL" -lt 10 ]; then
33+
SIZE="size/xs"
34+
elif [ "$TOTAL" -lt 50 ]; then
35+
SIZE="size/s"
36+
elif [ "$TOTAL" -lt 250 ]; then
37+
SIZE="size/m"
38+
elif [ "$TOTAL" -lt 500 ]; then
39+
SIZE="size/l"
40+
else
41+
SIZE="size/xl"
42+
fi
43+
44+
echo "PR #${PR_NUMBER}: +${ADDITIONS} -${DELETIONS} = ${TOTAL} lines -> ${SIZE}"
45+
46+
# Remove any existing size labels, then add the correct one
47+
for label in size/xs size/s size/m size/l size/xl; do
48+
gh pr edit "$PR_NUMBER" --repo "${{ github.repository }}" --remove-label "$label" 2>/dev/null || true
49+
done
50+
gh pr edit "$PR_NUMBER" --repo "${{ github.repository }}" --add-label "$SIZE"
51+
52+
# Post a warning comment for XL PRs
53+
if [ "$SIZE" = "size/xl" ]; then
54+
gh pr comment "$PR_NUMBER" --repo "${{ github.repository }}" \
55+
--body "> **Large PR** (+${ADDITIONS} -${DELETIONS} = ${TOTAL} lines). Consider splitting into smaller, focused PRs for easier review." \
56+
2>/dev/null || true
57+
fi

0 commit comments

Comments
 (0)