Commit 8bf1cec
committed
feat(all|pr_compliance): add PR/commit validator, tests, and CI gating
[What]
Add PR/commit compliance validator script, unit tests with 100% coverage, and a
PR Compliance workflow split into separate jobs. Gate other PR workflows to run
only after PR Compliance succeeds. Update PR templates to match validator rules
and add clear RU/EN title and commit guidelines.
[Why]
- Enforce consistent PR titles, bodies, and commit messages.
- Provide clear, actionable feedback to contributors.
- Prevent non-compliant changes from triggering expensive CI.
- Improve maintainability with tested validation logic.
[How]
- Validator (.github/scripts/validate_pr.py):
- Title: strict regex with optional [TASK], flexible Group, RU/EN examples.
- Body: 12 required sections with exact headers; ensure non-empty values; no H
TML comments.
- Commits: subject pattern/type set, length ≤ 72, required body sections, Scop
e fields.
- Fetch PR commits via GitHub REST API using GITHUB_TOKEN.
- Clear sectioned output and exit codes (0/1/2).
- Workflow (.github/workflows/pr-compliance.yml):
- Jobs: Unit Tests → Title → Body → Commits, with needs ordering.
- Unit tests run under coverage (fail-under=100%).
- Workflow gating:
- pre-commit, static-analysis-pr, and docker workflows run on workflow_run of
“PR Compliance” and only if it succeeded.
- PR templates:
- Converted to 12-section skeleton with labels matching validator.
- Added visible guidance for PR title/body/commits (RU/EN examples).
- Tests:
- tests/test_validate_pr.py and tests/test_validate_pr_main.py cover helpers,
CLI paths, API fetch (mocked), internal-error branch, and self-tests under __mai
n__.
Scope:
- Task: 0
- Variant: 0
- Technology: all
- Folder: pr_compliance
Tests:
- Local: python -m unittest -v tests/test_validate_pr.py tests/test_validate_pr_
main.py
- Coverage: coverage run -m unittest -v tests/test_validate_pr.py tests/test_val
idate_pr_main.py && coverage report -m .github/scripts/validate_pr.py (100% on v
alidator)
- CI: PR Compliance enforces coverage, then validates PR title/body/commits.
Local runs:
- Validator (against a real PR): GITHUB_TOKEN=<token> python .github/scripts/val
idate_pr.py --repo <owner>/<repo> --pr <number> --checks all --verbose
- Simulated payload (title/body): set GITHUB_EVENT_PATH=<path_to_payload.json> a
nd run with --checks title/body1 parent f87b874 commit 8bf1cec
File tree
3 files changed
+104
-2
lines changed- .github
- PULL_REQUEST_TEMPLATE
3 files changed
+104
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
6 | 40 | | |
7 | 41 | | |
8 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
6 | 40 | | |
7 | 41 | | |
8 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
6 | 40 | | |
7 | 41 | | |
8 | 42 | | |
| |||
0 commit comments