Skip to content

Phase 1: Add org-wide PR template, labels, and reusable workflows#1

Closed
bryanbeverly wants to merge 3 commits into
mainfrom
feat/pr-labeling-org-infra
Closed

Phase 1: Add org-wide PR template, labels, and reusable workflows#1
bryanbeverly wants to merge 3 commits into
mainfrom
feat/pr-labeling-org-infra

Conversation

@bryanbeverly

@bryanbeverly bryanbeverly commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Summary

This is Phase 1 of the PR Labeling & Hygiene plan -- it populates trufflesecurity/.github with the building blocks the other 7 private repos will call.

What this PR adds:

File Purpose
.github/PULL_REQUEST_TEMPLATE.md Default PR template inherited by every repo without its own
labels.yml Single source of truth for the 11-label taxonomy (size/*, risk/*, review/urgent, status/stale, complexity/high)
.github/workflows/pr-labeler-reusable.yml Reusable workflow: applies size/risk/checkbox labels
.github/workflows/label-sync-reusable.yml Reusable workflow: syncs labels.yml into a caller repo
.github/workflows/stale-reusable.yml Reusable workflow: wraps actions/stale@v9 (14d stale, 16d close, exempts review/urgent and drafts)
.github/scripts/pr_labeler.py Labeler logic: size buckets, Bugbot risk parsing, checkbox state
.github/scripts/label_sync.py Label sync logic via gh label create --force (additive)
.github/scripts/test_pr_labeler.py 35 unit tests for labeler logic
.github/workflows/test-scripts.yml Runs unit tests on PRs and pushes
README.md Documents what lives here, perms model, how to add a label

Permissions model: No reusable workflow declares its own `permissions:` block -- they inherit from callers. Each consumer caller declares the minimum its reusable needs (documented in README and the plan).

Versioning: Caller workflows reference these reusables at `@main`. Pushes to this branch immediately affect every consumer once they merge their callers (Phase 2). Branch protection on `main` requires PR review.

Required follow-up after merge (manual UI steps)

Both must be done by an org admin in the GitHub web UI:

  1. Enable Actions access for org repos: `Settings > Actions > General` for this repo -> "Access" section -> "Accessible from repositories in the 'trufflesecurity' organization." Without this, callers in other repos cannot reference these reusable workflows.
  2. Set org default labels: `Organization settings > Repository defaults > Repository labels` -> replace GitHub's defaults with the 11 labels from `labels.yml`. This applies only to future repos in the org; existing repos are populated by the sync workflow in Phase 2.

Test plan

  • All 35 unit tests pass locally (covering size buckets, Bugbot risk regex incl. unmapped levels, three-state checkbox parsing, label reconciliation that doesn't strip manual labels)
  • All YAML files parse cleanly
  • Test-scripts CI workflow runs green on this PR
  • (Post-merge) Phase 2 caller PRs successfully reference these reusables

Phase 2 preview

Once this merges + the two UI steps are done, separate PRs will land per repo to:

  1. Add a thog-specific PR template extension; delete integrations' empty template
  2. Add sync-labels.yml caller in each of 7 repos, then trigger sync to populate the 11 labels
  3. Add pr-labeler.yml caller in each of 7 repos
  4. Backfill labels on all 239 open PRs
  5. After Slack announcement, add stale.yml caller in each of 7 repos

Plan reference: `/Users/bryan.beverly/.cursor/plans/pr_labeling_and_hygiene_5b9ac6e6.plan.md`

Made with Cursor


Note

Medium Risk
Introduces org-wide GitHub Actions that can mutate labels and auto-close PRs across consumer repos; misconfiguration or regex/threshold mistakes could cause incorrect labeling or unintended staling once adopted org-wide.

Overview
Adds org-level PR hygiene building blocks: a default PULL_REQUEST_TEMPLATE.md, a centralized labels.yml taxonomy, and reusable workflows to sync labels, auto-label PRs, and mark/close stale PRs.

Implements Python automation to (1) sync labels into a target repo via gh label create --force (additive) and (2) label PRs based on diff size, Bugbot CURSOR_SUMMARY risk parsing, and PR-template checkboxes, with unit tests plus CI workflows for pytest, ruff, and actionlint.

Reviewed by Cursor Bugbot for commit a191d1f. Bugbot is set up for automated code reviews on this repo. Configure here.

This is Phase 1 of the PR Labeling & Hygiene rollout. It populates this repo
with the building blocks that consumer repos in the org will call:

* `.github/PULL_REQUEST_TEMPLATE.md` — default template for repos without one
* `labels.yml` — single source of truth for the 11-label taxonomy
* `.github/workflows/pr-labeler-reusable.yml` — size/risk/checkbox labeling
* `.github/workflows/label-sync-reusable.yml` — sync labels.yml into callers
* `.github/workflows/stale-reusable.yml` — wraps actions/stale (14d/16d)
* `.github/scripts/{pr_labeler,label_sync}.py` — labeler/sync logic
* `.github/scripts/test_pr_labeler.py` — 35 unit tests for labeler logic
* `.github/workflows/test-scripts.yml` — runs unit tests on PRs and pushes

No reusable workflow declares `permissions:` — they inherit from callers, so
each consumer must grant the minimum needed (documented in README).

Phase 2 (per-repo caller workflows) follows in separate PRs once this merges
and the org-level UI settings are configured (see plan: PR Labeling & Hygiene).

Made-with: Cursor
@bryanbeverly bryanbeverly self-assigned this Apr 20, 2026
…eration

- PR template: replace internal-looking example path with a generic placeholder
- README: stop enumerating internal repo names in the manual-sync example

These files live in a public repo (trufflesecurity/.github), so we avoid
publicly listing the names of private/internal consumer repos.

Made-with: Cursor
Establishes formatting/linting consistent with the org's lint.yml convention
(triggers, permissions, naming) while picking checkers appropriate to this
repo's file types:

* ruff check + format --check for the Python scripts in .github/scripts
* actionlint for the workflow YAML \u2014 especially valuable here since this
  repo provides reusable workflows to 7 consumers; a typo blasts everywhere

Existing scripts were reformatted in this commit to make ruff format pass.
No logic changes; all 35 unit tests still pass.

Made-with: Cursor
@bryanbeverly

Copy link
Copy Markdown
Contributor Author

Reopening as a fresh PR with clean (single-commit) history -- the original branch's intermediate commit publicly enumerated the 7 internal consumer repo names in the README diff. Replacement PR coming next with identical final state.

@bryanbeverly bryanbeverly deleted the feat/pr-labeling-org-infra branch April 20, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant