A GitHub Action that guards pull request size and nudges teams to include tests.
- Reads changed files in the pull request using the GitHub REST API.
- Calculates total changed lines and file count, with pagination for large PRs.
- Checks whether any test folders are touched.
- Posts a comment on the PR. Warns or fails based on
mode. - Optional repo config via
.pr_guard.yml.
max_linesdefault400max_filesdefault25test_pathsdefaulttest,tests,__tests__excludedefault empty. Comma separated globs, for example**/package-lock.json,**/*.min.jsmodewarnorfail, defaultwarnretriesdefault2(retries on HTTP 429 and 5xx)
Create a .pr_guard.yml in the repository root to override defaults.
max_lines: 400
max_files: 25
test_paths:
- tests
- __tests__
exclude:
- "**/package-lock.json"
- "**/*.min.js"
mode: warn
retries: 2