🗂️ Attic Dry-Run (Weekly) #33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 🗂️ Attic Dry-Run (Weekly) | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 2 * * 1' # Thứ 2, 02:00 UTC | |
| permissions: | |
| contents: read | |
| jobs: | |
| attic-dryrun: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.11' | |
| - name: Prepare artifacts dir | |
| run: mkdir -p artifacts | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install grimp networkx scikit-learn pytest pytest-cov coverage pyyaml | |
| - name: Run attic sweeper (dry-run) | |
| run: | | |
| echo "🗂️ Running attic sweeper (dry-run)…" | |
| python tools/inventory/attic_sweeper.py --days 30 --dry-run --output artifacts/attic_eviction_candidates.csv || true | |
| # đảm bảo luôn có file để upload | |
| test -f artifacts/attic_eviction_candidates.csv || \ | |
| echo "path,original,days,refs,protected,reason,candidate,timestamp" > artifacts/attic_eviction_candidates.csv | |
| - name: Generate summary | |
| run: | | |
| CANDIDATE_COUNT=$(tail -n +2 artifacts/attic_eviction_candidates.csv 2>/dev/null | wc -l | xargs) | |
| EVICTION_COUNT=$(tail -n +2 artifacts/attic_eviction_candidates.csv 2>/dev/null | grep -c ",true" || echo "0") | |
| { | |
| echo "## 🗂️ Weekly Attic Dry-Run Summary" | |
| echo "" | |
| echo "- **Run Date:** $(date -u) (UTC)" | |
| echo "- **Total files in attic:** ${CANDIDATE_COUNT:-0}" | |
| echo "- **Eviction candidates:** ${EVICTION_COUNT:-0}" | |
| if [ "${EVICTION_COUNT:-0}" -gt 0 ]; then | |
| echo "" | |
| echo "### 🗑️ Ready for Eviction" | |
| echo "| File | Days in Attic | Reason |" | |
| echo "|------|---------------|--------|" | |
| tail -n +2 artifacts/attic_eviction_candidates.csv | grep ",true" | head -10 | awk -F',' '{printf("| `%s` | %s | %s |\n",$1,$3,$6)}' | |
| fi | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| - name: Upload artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: attic-dryrun-artifacts-${{ github.run_number }} | |
| path: | | |
| artifacts/attic_eviction_candidates.csv | |
| artifacts/attic_moves.csv | |
| retention-days: 90 |