Skip to content

Commit a5ed0fc

Browse files
jpayne3506Copilot
andcommitted
Generate conventional-commits PR titles + repo-existing labels
Surfaced during the fix-mode PoC against master/v1.6/v1.7. The agent opened three valid fix PRs (#4442, #4443, #4444) but with generic 'ci-mx: PoC fix CI failures on <branch>' titles and zero labels. The repo convention is 'ci: <description>' with optional '(release/vX.Y)' suffix, plus flat labels like ci/cni/cns/cilium/dependencies. Fix: in the Fix-PR creation section, generate: - Title: ci: <description> [(release/vX.Y) | for #N [(release/vX.Y)]] where <description> is 're-render Dockerfiles', 'resolve govulncheck findings', or 're-render Dockerfiles and resolve govulncheck findings' depending on which playbooks committed. - Labels: always 'ci'; add 'dependencies' when govulncheck ran; add area labels (cni, cns, cilium) by matching paths in the commit's diff against a small known-area map. Filter the final set against 'gh label list' so labels that don't exist in the repo are skipped (no auto-creation). The three existing PoC PRs were retitled and relabeled to match. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ad56b89 commit a5ed0fc

1 file changed

Lines changed: 69 additions & 4 deletions

File tree

.github/agents/ci-mx.md

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,11 +528,75 @@ After the playbooks have made at least one commit on `$fix_branch`:
528528
```bash
529529
cd "$work_dir"
530530
git push -u origin "$fix_branch"
531+
```
532+
533+
### Title generation
534+
535+
Conventional-commits style (`ci: <description>`) to match the repo
536+
convention. Append `(<branch>)` suffix when `$target_branch` is a
537+
release branch:
531538
532-
fix_pr_title="ci-mx: fix CI failures on $target_branch"
539+
```bash
540+
case "$RAN_GOVULNCHECK,$RAN_BASEIMAGES" in
541+
true,true) desc="re-render Dockerfiles and resolve govulncheck findings" ;;
542+
true,false) desc="resolve govulncheck findings" ;;
543+
false,true) desc="re-render Dockerfiles" ;;
544+
*) desc="apply ci-mx fixes" ;;
545+
esac
546+
547+
case "$target_branch" in
548+
release/*) fix_pr_title="ci: $desc ($target_branch)" ;;
549+
*) fix_pr_title="ci: $desc" ;;
550+
esac
551+
552+
# When a source PR exists, prefix with its number so reviewers can
553+
# trace the chain.
533554
[ -n "$source_pr_number" ] && \
534-
fix_pr_title="ci-mx: fix CI failures for #$source_pr_number ($target_branch)"
555+
fix_pr_title="ci: $desc for #$source_pr_number${target_branch:+ ($target_branch)}"
556+
```
557+
558+
### Label generation
559+
560+
Always-on: `ci`. Govulncheck commits add `dependencies`. File-touched
561+
heuristic adds repo-existing area labels (`cni`, `cns`, `cilium`,
562+
etc.) when matching paths appear in the commit's diff. The set is
563+
filtered against `gh label list` to skip any label that doesn't exist
564+
in the repo (no auto-creation).
565+
566+
```bash
567+
labels=("ci")
568+
[ "${RAN_GOVULNCHECK:-false}" = "true" ] && labels+=("dependencies")
569+
570+
# Derive area labels from the commit's diff (HEAD~..HEAD covers both
571+
# possible playbook commits; HEAD~..HEAD covers the single-commit case
572+
# too if the worktree's HEAD~ is the baseline).
573+
touched=$(git diff --name-only "$target_head_sha"..HEAD)
574+
declare -A area_map=(
575+
[cni]="^cni/"
576+
[cns]="^cns/"
577+
[cilium]="^cilium|^bpf-prog/"
578+
)
579+
for label in "${!area_map[@]}"; do
580+
if echo "$touched" | grep -qE "${area_map[$label]}"; then
581+
labels+=("$label")
582+
fi
583+
done
584+
585+
# Filter to labels that actually exist in the repo (no auto-create).
586+
existing=$(gh label list --repo "$GH_NAMEWITHOWNER" \
587+
--limit 200 --json name --jq '.[].name')
588+
final_labels=()
589+
for l in "${labels[@]}"; do
590+
echo "$existing" | grep -qx "$l" && final_labels+=("$l")
591+
done
535592

593+
label_args=()
594+
for l in "${final_labels[@]}"; do label_args+=(--label "$l"); done
595+
```
596+
597+
### Body and create
598+
599+
```bash
536600
fix_pr_body=$(cat <<EOF
537601
Automated fix from \`ci-mx\` for CI failures on \`$target_branch\` at \`$target_head_sha\`.
538602
@@ -545,15 +609,16 @@ templates, or the Go toolchain. Never auto-merged.
545609
EOF
546610
)
547611

548-
# Fix PR targets the SOURCE branch so the diff is just the mechanical fix
612+
# Fix PR targets the source branch so the diff is just the mechanical fix
549613
# (not the full source-PR diff). Dev merges the fix PR into their source
550614
# branch, which adds the fix commits to the source PR. For direct
551615
# master/release failures, $target_branch is the trunk itself.
552616
fix_pr_url=$(gh pr create \
553617
--base "$target_branch" \
554618
--head "$fix_branch" \
555619
--title "$fix_pr_title" \
556-
--body "$fix_pr_body")
620+
--body "$fix_pr_body" \
621+
"${label_args[@]}")
557622

558623
if [ -n "$source_pr_number" ]; then
559624
gh pr comment "$source_pr_number" \

0 commit comments

Comments
 (0)