Fix reusable GitHub housekeeping action#229
Conversation
PR Review: Fix reusable GitHub housekeeping actionOverall this is a focused, well-reasoned bug fix. The path corrections are clearly necessary, the regression test is a good addition, and the README improvements are helpful. Correctness — Path depth fix ✅The core fix ( Code quality —
|
| Area | Status |
|---|---|
| Path depth fix (core bug) | ✅ Correct |
AddRange workaround |
✅ Works; minor style note |
Hardcoded net10.0 |
|
| Regression test | ✅ Good addition; minor redundancy |
| Documentation | ✅ Improved |
No blocking issues. The hardcoded framework and the redundant assertion are worth a follow-up but do not prevent merging.
|
PR Review: Fix reusable GitHub housekeeping action. The core bug fixes look correct and well-scoped. See detailed feedback below. |
|
PR Review: Fix reusable GitHub housekeeping action Overall this is a solid set of targeted fixes. The root cause (wrong relative depth) is correctly identified and consistently fixed in both action.yml and the PS1 script. Correctness Path depth fix - The depth correction from ../.. to ../../.. is correct. From .github/actions/github-housekeeping/, three levels are needed to reach the repo root. The fix is consistent across action.yml and Invoke-PowerForgeHousekeeping.ps1. AddRange to foreach fix - This is the right fix. PowerShell array literals produce object[], which is not assignable to IEnumerable[string] in a .NET generic context, so List[string].AddRange() would throw at runtime. The typed [string] cast in the foreach loop is correct. Potential Issues
Test The magic number 12 in FindRepoRoot() works in practice but is arbitrary. A more robust stop condition would compare against Path.GetPathRoot(current.FullName) to stop at the filesystem root rather than after a fixed number of iterations. The test itself is a reasonable regression guard - it confirms the relative depth resolves to real files in the actual repo layout, directly validating the fixed paths. Good addition. Documentation The README additions are helpful. The minimal JSON config example and the SHA pinning guidance are both valuable for new adopters. Adding powerforge-ref: main makes the reusable workflow example self-contained. Summary: The core bug fixes are correct and consistent. The main thing worth addressing before merge is the hardcoded net10.0 string - even a comment noting where it must stay in sync would reduce future maintenance risk. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
test comment from agent - pending file write permission |
|
test2 |
|
test line with ## heading |
|
short test |
|
short test with -e flag |
|
line1 line2 line3 |
1 similar comment
|
line1 line2 line3 |
|
PR Review - full content test single line |
|
PR Review - Updated |
|
test base64 |
PR ReviewOverall this is a well-structured improvement. The path-depth bug fix is clear and the richer reporting output is a good addition. A few issues worth addressing before merge: Bugs / Correctness1. In both the 2. The simple Design / Quality3. The function is named generically ( 4. Duplicated The 5.
Tests6. Path assertions in These assertions check only that 7. Using Looks Good
Summary: Items 1 and 3 are the most impactful to fix before merge. Items 2 and 4 are low-risk cleanup. Items 5-7 are minor style/robustness notes. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
PR Review: Fix reusable GitHub housekeeping actionOverall this is a solid improvement — moving the report generation into the C# CLI and fixing the incorrect 🔴 Critical:
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
PR Review: Fix reusable GitHub housekeeping actionOverall this is a solid improvement — the path-resolution bug fix is correct, the move to structured reports is well-designed, and the test coverage is a nice addition. I found a few issues ranging from a potential silent bug to minor nits. Bugs / Correctness1. In $args = @('run', '--project', $project, ...)
& dotnet @args
2. The old script explicitly did: $null = $arguments.Add('--token-env')
$null = $arguments.Add('POWERFORGE_GITHUB_TOKEN')The new inline script does not pass 3. Missing The old $ErrorActionPreference = 'Stop'
# ... run dotnet ...
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }4. Config-file existence check removed The old script validated the config before running: if (-not (Test-Path -LiteralPath $configPath)) {
throw "Housekeeping config not found: $configPath"
}Without this, a missing config file produces a generic CLI error rather than a clear, actionable message. Consider re-adding this guard. 5. Wrong filename in regression test assertion In Assert.DoesNotContain("Invoke-GitHubHousekeeping.ps1", actionYaml, StringComparison.Ordinal);The deleted file was named Assert.DoesNotContain("Invoke-PowerForgeHousekeeping.ps1", actionYaml, StringComparison.Ordinal);Behavioral Change (breaking for existing callers)6. Old: apply: ${{ github.event_name == 'workflow_dispatch' && inputs.apply == 'true' || github.event_name != 'workflow_dispatch' }}New: apply: ${{ github.event_name == 'workflow_dispatch' && inputs.apply == 'true' || github.event_name != 'workflow_dispatch' && vars.POWERFORGE_GITHUB_HOUSEKEEPING_APPLY == 'true' }}Previously scheduled/push runs always applied changes. Now they default to dry-run unless Code Quality7. Redundant null-coalescing in if (string.IsNullOrWhiteSpace(value))
return "-";
var text = value ?? string.Empty; // value cannot be null here
8. Assert.Contains("PowerForge GitHub Housekeeping", actionYaml, StringComparison.Ordinal);"PowerForge GitHub Housekeeping" is the name of the reusable workflow ( Minor / Docs9. Minimal config In the README "dryRun": falseThe actual dry-run/apply mode is controlled by the 10. The architectural shift from the Summary
The path-fix, report service, and test structure are all good. The main items to address before merging are the |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
PR Review: Fix reusable GitHub housekeeping actionOverall this is a solid set of changes. The core path-resolution bug fix (from Bug: In Behavioral breaking change: scheduled runs are now permanently dry-run In Breaking change: workflow rename without deprecation path Renaming Minor: In Minor: Redundant null-coalescing in In Observation: token env var rename may break existing configs The action now sets Positives
Action items:
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
PR Review: Fix reusable GitHub housekeeping actionOverall this is a solid refactor — moving output generation into the CLI itself (instead of the PowerShell wrapper parsing JSON stdout) is cleaner and more testable. The path-depth fix ( Bug: Token is no longer forwarded to the CLICritical. The old if (-not [string]::IsNullOrWhiteSpace($env:POWERFORGE_GITHUB_TOKEN)) {
$null = $arguments.Add('--token-env')
$null = $arguments.Add('POWERFORGE_GITHUB_TOKEN')
}The new inline script sets # action.yml - current (missing token arg)
$args = @('run', ... '--', 'github', 'housekeeping', '--config', $env:INPUT_CONFIG_PATH)
if ($env:INPUT_APPLY -eq 'true') { $args += '--apply' } else { $args += '--dry-run' }
& dotnet @argsPlease verify the CLI behavior and add Bug:
|
| Area | Severity | Item |
|---|---|---|
| Token forwarding | High | --token-env not passed to CLI |
$args variable |
Medium | Shadows PS automatic variable |
| Config validation | Medium | Empty/missing path not caught early |
EscapeCell |
Low | Redundant ?? string.Empty |
| Duplicate write logic | Low | No comment explaining the distinction |
| Scheduled apply change | Medium | Breaking default behavior change, needs docs |
| Test brittleness | Low | String-match on YAML content |
The report service and model are clean and well-structured. The test coverage for GitHubHousekeepingReportServiceTests is solid. Please address the token-forwarding issue before merging.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
PR Review: Fix reusable GitHub housekeeping actionOverall this is a well-structured fix with good test coverage. The core path-depth correction ( Bug:
|
| Severity | Issue |
|---|---|
| 🔴 Medium | $args reserved variable — rename to $arguments |
| 🟡 Low | Token forwarding behavior change — confirm CLI reads GITHUB_TOKEN by default |
| 🟡 Low | Behaviour change for scheduled auto-apply — document migration path |
| ⚪ Nit | Dead ?? string.Empty in EscapeCell |
| ⚪ Nit | Hardcoded --framework net10.0 |
| ⚪ Nit | Misleading test assertion crosses file boundary |
The path-depth fix and the new reporting layer are both clean. Addressing the $args rename and confirming the token flow would make this merge-ready.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
PR Review: Fix reusable GitHub housekeeping actionOverall this is a solid, well-motivated refactor. The core path fix is correct and the new 🔴 Potential Breaking Change — Scheduled runs may silently stop cleaning up
The # Old: non-dispatch events always applied
apply: ${{ github.event_name == 'workflow_dispatch' && inputs.apply == 'true' || github.event_name != 'workflow_dispatch' }}to: # New: non-dispatch events require a repo variable
apply: ${{ (github.event_name == 'workflow_dispatch' && inputs.apply == 'true') || (github.event_name != 'workflow_dispatch' && vars.POWERFORGE_GITHUB_HOUSEKEEPING_APPLY == 'true') }}Any repo running this on a schedule (cron) will now silently enter dry-run mode until 🟡 Missing
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
PR Review: Fix reusable GitHub housekeeping action |
PR Review: Fix reusable GitHub housekeeping actionOverall this is a well-structured refactor. The core path fix (from Potential Bug: Token not passed to CLI The old script passed Behavioral Change: Scheduled runs now default to dry-run
Minor: Redundant null-coalescing in In Duplication:
Breaking Change: Workflow rename Renaming Hardcoded framework version in
Test quality: Action test checks hardcoded strings
Security: Report path traversal (low risk)
The core fixes (path resolution, inlined PS, typed arg list, report artifacts, new runner workflow) look correct and are a clear improvement. The token-passing change is the item I would confirm before merging. |
Code Review: Fix reusable GitHub housekeeping actionOverall this is a clean, well-structured refactor. Moving JSON parsing and report generation from the PowerShell wrapper into the C# CLI is a better long-term design. Here are some observations: Potential bugs / functional regressions1. Token is no longer passed to the CLI (action.yml - Run GitHub housekeeping step) The old Invoke-PowerForgeHousekeeping.ps1 explicitly added --token-env POWERFORGE_GITHUB_TOKEN to the CLI args. The new inlined script omits any --token-env argument and renames the env var to GITHUB_TOKEN. Unless the CLI was updated to auto-detect GITHUB_TOKEN (not visible in this diff), the housekeeping command may fail to authenticate. Worth confirming this is intentional and the CLI picks up the new env var name. 2. --output json flag is no longer passed The old script always appended --output json so it could parse the result envelope. The new script omits it. If the CLI console output is now irrelevant since reports go to files/GITHUB_OUTPUT, this is fine, but any callers consuming stdout JSON will silently break. 3. powerforge-github-runner-housekeeping.yml missing actions: write The runner housekeeping workflow only declares contents: read. The shared composite action can also manage caches and artifacts; if a caller config accidentally enables those sections, the job will fail with permission errors at runtime. Consider documenting that actions: write is required when cache or artifact sections are enabled. Breaking change worth calling out4. Scheduled runs no longer apply by default (github-housekeeping.yml) Old condition: apply when event is not workflow_dispatch (scheduled runs always applied). New condition: scheduled runs only apply when vars.POWERFORGE_GITHUB_HOUSEKEEPING_APPLY is true. Any repository relying on scheduled cleanup will silently stop deleting after merging this PR unless that variable is set. A migration note would prevent surprise. Minor code quality observations5. EscapeCell CRLF handling (GitHubHousekeepingReportService.cs) The method replaces carriage-return with a space and newline with br. A CRLF sequence becomes space+br because CR is replaced first. Replacing CRLF as a unit before individual replacements would be cleaner, but this is cosmetic. 6. StorageStatus parameter name vs intent The parameter named eligible is passed PlannedDeletes at the call sites. The name mismatch makes the method signature harder to read; plannedDeletes would match callers. 7. Fragile snapshot assertions in GitHubHousekeepingActionTests.cs Assertions testing literal YAML text will break the test on any formatting change to action.yml without any functional regression. The path-resolution assertions (verifying resolved files actually exist on disk) are genuinely useful; the string-contains ones less so. What is well done
The core bug fix and new report/artifact plumbing look solid. The main things worth addressing before merge are the token passthrough question (point 1) and the silent dry-run regression for scheduled runs (point 4). |
Summary
Testing
GitHubHousekeepingActionTests|FullyQualifiedNameGitHubHousekeepingServiceTests"