Skip to content

fix: Implement .cleanup-ignore support in cleanup.yml workflow #424

@d-oit

Description

@d-oit

Problem

The automated cleanup workflow (.github/workflows/cleanup.yml) is incorrectly flagging and removing files that are listed in .cleanup-ignore. The PR body template mentions .cleanup-ignore as a way to exclude files from future scans, but the actual shell script logic never reads this file.

This was observed in PR #422, where scripts/pre-commit-hook.sh was marked for deletion despite being listed in .cleanup-ignore.

Root Cause

In the Detect unused scripts step of cleanup.yml, only two files are hardcoded as explicit exceptions:

if [ "${refs}" -eq 0 ] && \
   [ "${script_name}" != "quality_gate.sh" ] && \
   [ "${script_name}" != "setup-hooks.sh" ]; then
  # marked as unused
fi

There is zero logic to read .cleanup-ignore. The mention of this file in the PR body is misleading documentation that was never implemented.

Expected Behavior

  • If a .cleanup-ignore file exists at the repository root, the workflow should read it line by line.
  • Any file whose basename (or relative path) matches an entry in .cleanup-ignore should be excluded from the unused-file detection.
  • Lines starting with # and empty lines should be treated as comments/ignored.

Proposed Fix

At the top of the Detect unused scripts step, add the following logic:

# Load .cleanup-ignore entries
ignored_files=()
if [ -f ".cleanup-ignore" ]; then
  while IFS= read -r line || [[ -n "$line" ]]; do
    # Skip comments and empty lines
    [[ "$line" =~ ^#.*$ || -z "$line" ]] && continue
    ignored_files+=("$(basename "$line")")
  done < ".cleanup-ignore"
fi

Then inside the for script in scripts/*.sh loop, add a skip check before marking files as unused:

# Check if the file is in .cleanup-ignore
skip=false
for ignored in "${ignored_files[@]}"; do
  [ "$script_name" = "$ignored" ] && skip=true && break
done
[ "$skip" = true ] && continue

Acceptance Criteria

  • .cleanup-ignore file is read at the start of the detection step
  • Files listed in .cleanup-ignore are never added to the unused-files list
  • Comment lines (# ...) and blank lines in .cleanup-ignore are gracefully ignored
  • Workflow still correctly detects genuinely unused files not in .cleanup-ignore
  • PR [Automated] Cleanup: Remove unused files and technical debt #422 should be closed (no files to delete once ignore logic is applied)
  • Add a note in the workflow step summary indicating how many files were skipped due to .cleanup-ignore

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    julesgemini - jules

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions