CI: gate heavy reviews on self-review (Doc consistency); comment-trigger; disable TTL heavy reviews #159

Closed
rodin wants to merge 8 commits from ci-selfreview-gate into main
Showing only changes of commit 951aa5d584 - Show all commits
+42
View File
@@ -0,0 +1,42 @@
name: Workflow Lint
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize]
jobs:
workflow-sanity:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Sanity check ci.yml triggers and gates
run: |
set -euo pipefail
python3 - <<'PY'
import sys, yaml, re
Review

[NIT] import sys, yaml, resys and re are imported but re is unused (the regex is done via jq, not Python) and sys is unused too. This is harmless but slightly messy.

**[NIT]** `import sys, yaml, re` — `sys` and `re` are imported but `re` is unused (the regex is done via jq, not Python) and `sys` is unused too. This is harmless but slightly messy.
Review

[NIT] import sys, yaml, resys and re are imported but never used in the script. Harmless, but slightly misleading.

**[NIT]** `import sys, yaml, re` — `sys` and `re` are imported but never used in the script. Harmless, but slightly misleading.
Review

[NIT] The Python script imports 're' but does not use it. Remove the unused import to reduce lint noise.

**[NIT]** The Python script imports 're' but does not use it. Remove the unused import to reduce lint noise.
from pathlib import Path
p = Path('.gitea/workflows/ci.yml')
Review

[MINOR] The lint step relies on import yaml (PyYAML) but does not install it. On many runners PyYAML is not preinstalled, risking sporadic failures. Add an installation step (e.g., sudo apt-get install -y python3-yaml or pip install pyyaml) or avoid the dependency.

**[MINOR]** The lint step relies on `import yaml` (PyYAML) but does not install it. On many runners PyYAML is not preinstalled, risking sporadic failures. Add an installation step (e.g., `sudo apt-get install -y python3-yaml` or `pip install pyyaml`) or avoid the dependency.
w = yaml.safe_load(p.read_text())
Review

[MAJOR] The lint step imports PyYAML (import yaml) but the job does not install it. Many runners do not have PyYAML preinstalled, so this job will fail with ModuleNotFoundError. Add an installation step (e.g., apt-get install -y python3-yaml or pip install pyyaml) before running the script.

**[MAJOR]** The lint step imports PyYAML (import yaml) but the job does not install it. Many runners do not have PyYAML preinstalled, so this job will fail with ModuleNotFoundError. Add an installation step (e.g., apt-get install -y python3-yaml or pip install pyyaml) before running the script.
# 1) Top-level 'on' must exist and include pull_request + issue_comment
on = w.get('on')
assert isinstance(on, dict), "ci.yml: top-level 'on' must be a mapping"
assert 'pull_request' in on, "ci.yml: missing on.pull_request"
assert 'issue_comment' in on, "ci.yml: missing on.issue_comment (self-review trigger)"
pr_types = on['pull_request'].get('types', []) if isinstance(on['pull_request'], dict) else []
ic_types = on['issue_comment'].get('types', []) if isinstance(on['issue_comment'], dict) else []
for t in ['opened','synchronize']:
assert t in pr_types, f"ci.yml: pull_request.types must include '{t}'"
for t in ['created','edited']:
assert t in ic_types, f"ci.yml: issue_comment.types must include '{t}'"
# 2) review-gate must run on both PR and issue_comment (if condition string)
rg_if = w['jobs']['review-gate'].get('if','')
assert 'github.event_name == ' in rg_if and 'issue_comment' in rg_if and 'pull_request' in rg_if, \
"ci.yml: review-gate.if must include both pull_request and issue_comment"
# 3) review job must require self-review reason
rev_if = w['jobs']['review'].get('if','')
assert "needs.review-gate.outputs.reason == 'self-review'" in rev_if, \
"ci.yml: review.if must require reason=='self-review'"
print('OK: ci.yml triggers and gates look sane')
PY