hyperdx/.github/workflows/pr-triage.yml
Tom Alexander 71e1441257
chore: Refactor PR classification + add tests (#2129)
## Summary
- Refactor for readability + add tests
- Allow small agent-branch PRs to reach Tier 2 (< 50 prod lines, ≤ 3 files)
- Add cross-layer detection to keep multi-package changes at Tier 3+
- Raise Tier 2 ceiling from 100 → 150 production lines
- Exclude test and changeset files from line counts used for tier decisions
- Extract pure classification logic into .github/scripts/ for testability
- Gate classify job on tests passing in pr-triage.yml
- Only CI changes to main.yaml and release.yaml are tier 4
- Test changes in critical paths don't count toward tiering decisions
2026-04-16 15:25:06 +00:00

55 lines
1.4 KiB
YAML

name: PR Triage
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
inputs:
pr_number:
description:
PR number to classify (leave blank to classify all open PRs)
required: false
type: string
permissions:
contents: read
pull-requests: write
issues: write
concurrency:
group:
${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id
}}
cancel-in-progress: true
jobs:
test:
name: Test triage logic
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- run: node --test .github/scripts/__tests__/pr-triage-classify.test.js
classify:
name: Classify PR risk tier
needs: test
runs-on: ubuntu-24.04
timeout-minutes: 8
# For pull_request events skip drafts; workflow_dispatch always runs
if:
${{ github.event_name == 'workflow_dispatch' ||
!github.event.pull_request.draft }}
steps:
- uses: actions/checkout@v4
- name: Classify and label PR(s)
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const path = require('path');
const run = require(path.join(process.env.GITHUB_WORKSPACE, '.github/scripts/pr-triage.js'));
await run({ github, context });