Skip to content

Conversation

@allnes
Copy link
Member

@allnes allnes commented Sep 9, 2025

1. Full name and group

Name and group: Anesterov A., 2341-a234

2. Assignment / Topic / Task

Assignment: Add PR/commit compliance validator, tests, and CI gating

3. Technology / Platform used

Technology: Python 3.11, GitHub Actions, GitHub REST API

4. Goals of the work

Goals: Enforce strict PR title/body/commit formats; provide clear error messages
with EN+RU examples; enable local and CI usage; achieve 100% test coverage; gat
e other PR workflows on compliance

5. Solution description and structure

Description: Implemented .github/scripts/validate_pr.py for title/body/commit va
lidation; added .github/workflows/pr-compliance.yml split into four jobs (unit t
ests first, then title/body/commits); introduced unit tests covering helpers, CL
I flows, and edges; enforced 100% coverage; updated PR templates to match valida
tor (12 sections, no HTML comments) and added visible EN/RU title examples; rela
xed PR title “group” field to allow any text before “. ”

6. System requirements and build instructions

Build & Run:

  • Local validator: GITHUB_TOKEN= python .github/scripts/validate_pr.py --
    repo / --pr --checks all --verbose
  • Unit tests: python -m unittest -v tests/test_validate_pr.py tests/test_validat
    e_pr_main.py
  • Coverage (locally): coverage run -m unittest -v tests/test_validate_pr.py test
    s/test_validate_pr_main.py && coverage report -m .github/scripts/validate_pr.py

7. Testing and verification

Testing: Added comprehensive unittests for title/body/commit validation, helpers
(_trim, payload loading), API fetch (mocked), and CLI code paths including inte
rnal-error branch; verified local runs with valid/invalid payloads; CI enforces
coverage == 100%

8. Results

Results: Validator outputs clear sections and summaries; CI workflow runs tests
first, then validates title/body/commits; failing checks stop downstream workflo
ws; PR templates now guide authors to pass checks on first try

9. Performance analysis

Analysis: Validator uses stdlib only; API calls limited to PR commits list; runt
ime negligible relative to overall CI; coverage steps add minimal overhead

10. Conclusions and possible improvements

Conclusions: The pipeline is now robust and transparent; quality gates prevent n
on-compliant PRs early; future improvements could add GitHub annotations or path
-based filtering for workflow_run-triggered jobs

11. Limitations / known issues

Limitations: Commit validation requires GITHUB_TOKEN; body checks require exact
headers/labels; “Performance:” section in commits is optional unless perf change
s are made; current workflow_run triggers don’t apply file path filters (can be
emulated if needed)

12. CI / static analysis / code style

CI & Style: PR Compliance gates other PR workflows via workflow_run; unit tests
run with coverage fail-under=100; pre-commit/static analysis/Docker PR jobs run
only after PR Compliance succeeds

@allnes allnes marked this pull request as draft September 9, 2025 20:36
@allnes allnes changed the title An/check pr info 0-0. Иванов Иван Иванович. 1234567890а. Проверка имени, описание и коммитов реквестоов Sep 11, 2025
@allnes allnes changed the title 0-0. Иванов Иван Иванович. 1234567890а. Проверка имени, описание и коммитов реквестоов 0-0. Иванов Иван Иванович. 1234567890а. Проверка имени, описание и коммитов реквеста Sep 11, 2025
[What]
Add PR/commit compliance validator script, unit tests with 100% coverage, a reusable PR Compliance workflow, and updated PR templates (12 required sections + RU/EN guidance). Wire main workflow to depend on PR Compliance via needs.

[Why]
- Enforce consistent PR titles, bodies, and commit messages.
- Provide clear, actionable CI feedback and stop early on non-compliance.
- Ensure local/CI parity and maintainable validation with tests.

[How]
- .github/scripts/validate_pr.py: strict title/body/commit checks; flexible Group in title; clear EN messages with RU/EN examples; GitHub API for commits; robust output + exit codes.
- tests/: add tests for title/body/commit + CLI paths; reach 100% coverage.
- .github/workflows/pr-compliance.yml: split jobs (unit tests → title → body → commits) and expose as workflow_call.
- .github/workflows/main.yml: add pr_compliance job and make downstream jobs depend on it via needs.
- .github/*templates*: replace with 12-section skeleton and visible title/body/commit instructions.
- setup.cfg: align flake8 (E203) with formatter; long lines wrapped in tests.

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_validate_pr_main.py && coverage report -m .github/scripts/validate_pr.py (100%)
- Pre-commit: pre-commit run --all-files (all hooks pass)

Local runs:
- Validator: GITHUB_TOKEN=<token> python .github/scripts/validate_pr.py --repo <owner>/<repo> --pr <number> --checks all --verbose
[What]
Remove duplicated pre-commit invocation from main workflow and make platform jobs depend directly on PR Compliance via needs.

[Why]
Avoid running pre-commit twice on PRs and ensure all jobs are strictly gated by PR Compliance.

[How]
- .github/workflows/main.yml: drop pre-commit job; set ubuntu/mac/windows to needs: [pr_compliance].

Scope:
- Task: 0
- Variant: 0
- Technology: all
- Folder: pr_compliance

Tests:
- CI: workflow graph shows no duplicate pre-commit; downstream jobs start only after pr_compliance.

Local runs:
- N/A (workflow change only)
@allnes allnes marked this pull request as ready for review September 11, 2025 13:54
@allnes allnes requested a review from aobolensk September 11, 2025 13:54
@allnes
Copy link
Member Author

allnes commented Sep 11, 2025

@aobolensk prepared full check of PR

@codecov
Copy link

codecov bot commented Sep 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.35%. Comparing base (e5ccec0) to head (7e32f9e).
⚠️ Report is 16 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #636   +/-   ##
=======================================
  Coverage   95.35%   95.35%           
=======================================
  Files          11       11           
  Lines         366      366           
  Branches      133      133           
=======================================
  Hits          349      349           
  Partials       17       17           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Contributor

This pull request is stale for 2 weeks and is going to be closed in a week

@github-actions github-actions bot added the stale label Sep 26, 2025
@allnes allnes removed the stale label Sep 26, 2025
@github-actions
Copy link
Contributor

This pull request is stale for 2 weeks and is going to be closed in a week

@github-actions github-actions bot added the stale label Oct 11, 2025
@github-actions github-actions bot closed this Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants