Skip to content

refactor: split 4 files exceeding 800-line limit #80

refactor: split 4 files exceeding 800-line limit

refactor: split 4 files exceeding 800-line limit #80

Workflow file for this run

name: PR Hygiene
on:
pull_request:
branches: [main]
types: [opened, synchronize]
permissions:
pull-requests: write
jobs:
size-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Check PR size
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: |
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
per_page: 100,
});
const totalChanges = files.reduce((sum, f) => sum + f.changes, 0);
const fileCount = files.length;
console.log(`PR has ${fileCount} files with ${totalChanges} total line changes`);
if (totalChanges > 500 || fileCount > 30) {
// Check if we already commented
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const alreadyCommented = comments.data.some(c =>
c.body?.includes('Large PR detected')
);
if (alreadyCommented) return;
const body = [
`⚠️ **Large PR detected** — ${fileCount} files, ${totalChanges} lines changed.`,
'',
'Consider splitting into smaller PRs for easier review. Not a blocker, just a signal.',
].join('\n');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}