Skip to content

Commit f3bc1db

Browse files
committed
feat(ci): Regnerate category indexes in stale component removal PRs
Signed-off-by: Giulio Frasca <gfrasca@redhat.com>
1 parent 877f7b0 commit f3bc1db

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

.github/scripts/stale_component_handler/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Handles components approaching or past their verification deadline.
1616
3. For **stale** components:
1717
- Creates a branch `remove-stale-{component-name}`
1818
- Removes the component directory
19+
- Regenerates the category README to update the index
1920
- Opens a PR with `stale-component-removal` label
2021
- Adds component owners as reviewers
2122

.github/scripts/stale_component_handler/removal_pr_body.md.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ This PR removes the component **{{ name }}** which has not been verified in {{ a
88
| Last Verified | {{ last_verified }} |
99
| Days Since Verification | {{ age_days }} |
1010

11+
### Changes
12+
13+
- Removes `{{ path }}/` directory
14+
- Updates category README to remove component from index
15+
1116
### Maintainers
1217

1318
{{ owners_mention }}

.github/scripts/stale_component_handler/stale_component_handler.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"""
66

77
import argparse
8+
import json
89
import os
910
import subprocess
1011
import sys
11-
import json
1212
from datetime import datetime, timezone
1313
from pathlib import Path
1414

@@ -187,6 +187,7 @@ def create_removal_pr(repo: str, component: dict, repo_path: Path, dry_run: bool
187187
print(f"[DRY RUN] Would create removal PR: {title}")
188188
print(f" Branch: {branch_name}")
189189
print(f" Removes: {path}")
190+
print(f" Updates: {Path(path).parent}/README.md (category index)")
190191
print(f" Reviewers: {owners}")
191192
return True
192193

@@ -221,6 +222,18 @@ def create_removal_pr(repo: str, component: dict, repo_path: Path, dry_run: bool
221222
print(f"Component directory not found: {component_dir}", file=sys.stderr)
222223
return False
223224

225+
# Regenerate category README to remove the component from the index
226+
category_dir = component_dir.parent
227+
is_component = "components" in path
228+
try:
229+
index_generator = CategoryIndexGenerator(category_dir, is_component=is_component)
230+
category_readme_content = index_generator.generate()
231+
category_readme_path = category_dir / "README.md"
232+
category_readme_path.write_text(category_readme_content)
233+
subprocess.run(["git", "add", str(category_readme_path)], check=True, capture_output=True)
234+
except Exception as e:
235+
print(f"Warning: Could not regenerate category README: {e}", file=sys.stderr)
236+
224237
# Commit the change
225238
commit_msg = f"Remove stale component: {name}\n\nComponent has not been verified in {component['age_days']} days."
226239
subprocess.run(["git", "commit", "-m", commit_msg], check=True, capture_output=True)
@@ -258,8 +271,7 @@ def create_removal_pr(repo: str, component: dict, repo_path: Path, dry_run: bool
258271

259272

260273
def handle_stale_components(repo: str, token: str | None, dry_run: bool) -> None:
261-
"""Handle stale components: issues for warnable or stale components,
262-
and additionally creates PRs for fully stale components."""
274+
"""Handle stale components: issues for warnings, removal PRs for stale."""
263275
repo_path = REPO_ROOT
264276
results = scan_repo(repo_path)
265277
# Include both warning (270-360 days) and stale (>360 days) components

0 commit comments

Comments
 (0)