Skip to content

Commit 8bf1cec

Browse files
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/body
1 parent f87b874 commit 8bf1cec

File tree

3 files changed

+104
-2
lines changed

3 files changed

+104
-2
lines changed

.github/PULL_REQUEST_TEMPLATE/task_submission_en.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,42 @@
1-
PR title format (enforced by CI):
1+
PR Title (enforced by CI):
22
- Pattern: [TASK] <Task>-<Variant>. <Last Name> <First Name> <Middle Name>. <Group>. <Task name>.
3+
- Notes: `[TASK]` is optional; <Group> can be any text; there must be a dot and a space after each block.
34
- Example (RU): 2-12. Иванов Иван Иванович. 2341-а234. Вычисление суммы элементов вектора.
45
- Example (EN): 2-12. Ivanov Ivan Ivanovich. 2341-a234. Vector elements sum calculation.
56

7+
PR Body (enforced by CI):
8+
- Use the 12 sections below exactly as titled; do not include HTML comments.
9+
- After each label line (e.g., `Assignment:`), provide non-empty text.
10+
11+
Commit Messages (enforced by CI):
12+
- Subject pattern: <type>(<technology>|<task_folder>): <short_change_summary>
13+
- Allowed types: feat, fix, perf, test, refactor, docs, build, chore
14+
- Allowed technology: seq, omp, mpi, stl, tbb, all; or use your task folder name instead of a technology
15+
- Subject length: ≤ 72 characters, then one blank line
16+
- Required body sections: [What], [Why], [How], Scope: (Task/Variant/Technology/Folder), Tests:, Local runs:
17+
- Example subject: feat(omp|nesterov_a_vector_sum): implement parallel vector sum
18+
- Example body:
19+
[What]
20+
Add OMP reduction for vector sum.
21+
22+
[Why]
23+
Improve performance and parallel coverage.
24+
25+
[How]
26+
Use #pragma omp parallel for reduction(+:sum).
27+
28+
Scope:
29+
- Task: 2
30+
- Variant: 12
31+
- Technology: omp
32+
- Folder: nesterov_a_vector_sum
33+
34+
Tests:
35+
Added unit and perf tests.
36+
37+
Local runs:
38+
make test
39+
640
Please fill in ALL sections below (no HTML comments). Use English headers as given.
741

842
## 1. Full name and group

.github/PULL_REQUEST_TEMPLATE/task_submission_ru.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,42 @@
11
Формат заголовка PR (проверяется CI):
22
- Шаблон: [TASK] <Task>-<Variant>. <Last Name> <First Name> <Middle Name>. <Group>. <Task name>.
3+
- Примечания: `[TASK]` — опционально; <Group> может быть любым текстом; после каждого блока — точка и пробел.
34
- Пример (RU): 2-12. Иванов Иван Иванович. 2341-а234. Вычисление суммы элементов вектора.
45
- Example (EN): 2-12. Ivanov Ivan Ivanovich. 2341-a234. Vector elements sum calculation.
56

7+
Описание PR (проверяется CI):
8+
- Используйте 12 разделов ниже с точными заголовками; не добавляйте HTML-комментарии.
9+
- После каждой метки (например, `Assignment:`) укажите непустой текст.
10+
11+
Описания коммитов (проверяется CI):
12+
- Паттерн заголовка: <type>(<technology>|<task_folder>): <short_change_summary>
13+
- Допустимые type: feat, fix, perf, test, refactor, docs, build, chore
14+
- Допустимые technology: seq, omp, mpi, stl, tbb, all; либо используйте имя папки задачи вместо technology
15+
- Длина первой строки ≤ 72 символа, затем пустая строка
16+
- Обязательные секции тела: [What], [Why], [How], Scope: (Task/Variant/Technology/Folder), Tests:, Local runs:
17+
- Пример subject: feat(omp|nesterov_a_vector_sum): implement parallel vector sum
18+
- Пример тела:
19+
[What]
20+
Add OMP reduction for vector sum.
21+
22+
[Why]
23+
Improve performance and parallel coverage.
24+
25+
[How]
26+
Use #pragma omp parallel for reduction(+:sum).
27+
28+
Scope:
29+
- Task: 2
30+
- Variant: 12
31+
- Technology: omp
32+
- Folder: nesterov_a_vector_sum
33+
34+
Tests:
35+
Added unit and perf tests.
36+
37+
Local runs:
38+
make test
39+
640
Заполните ВСЕ разделы ниже (без HTML-комментариев). Заголовки разделов оставьте на английском, как указано.
741

842
## 1. Full name and group

.github/pull_request_template.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,42 @@
1-
PR title format (enforced by CI):
1+
PR Title (enforced by CI):
22
- Pattern: [TASK] <Task>-<Variant>. <Last Name> <First Name> <Middle Name>. <Group>. <Task name>.
3+
- Notes: `[TASK]` is optional; <Group> can be any text; there must be a dot and a space after each block.
34
- Example (RU): 2-12. Иванов Иван Иванович. 2341-а234. Вычисление суммы элементов вектора.
45
- Example (EN): 2-12. Ivanov Ivan Ivanovich. 2341-a234. Vector elements sum calculation.
56

7+
PR Body (enforced by CI):
8+
- Use the 12 sections below exactly as titled; do not include HTML comments.
9+
- After each label line (e.g., `Assignment:`), provide non-empty text.
10+
11+
Commit Messages (enforced by CI):
12+
- Subject pattern: <type>(<technology>|<task_folder>): <short_change_summary>
13+
- Allowed types: feat, fix, perf, test, refactor, docs, build, chore
14+
- Allowed technology: seq, omp, mpi, stl, tbb, all; or use your task folder name instead of a technology
15+
- Subject length: ≤ 72 characters, then one blank line
16+
- Required body sections: [What], [Why], [How], Scope: (Task/Variant/Technology/Folder), Tests:, Local runs:
17+
- Example subject: feat(omp|nesterov_a_vector_sum): implement parallel vector sum
18+
- Example body:
19+
[What]
20+
Add OMP reduction for vector sum.
21+
22+
[Why]
23+
Improve performance and parallel coverage.
24+
25+
[How]
26+
Use #pragma omp parallel for reduction(+:sum).
27+
28+
Scope:
29+
- Task: 2
30+
- Variant: 12
31+
- Technology: omp
32+
- Folder: nesterov_a_vector_sum
33+
34+
Tests:
35+
Added unit and perf tests.
36+
37+
Local runs:
38+
make test
39+
640
Please fill in ALL sections below (no HTML comments).
741

842
## 1. Full name and group

0 commit comments

Comments
 (0)