mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-11-16 12:05:12 -06:00
The toolchain folder is now binder/, and the root ./binder symlink is gone. The command is ./binder/binder: a plain path to the script, with no link and no install step. Every invocation moved with it: pre-commit entries, workflow steps, the VS Code extension's command palette, help text, and docs. - bindery/ paths and bindery.* imports, including the chapter code cells that import binder.tools.figures, now name binder/. - Binder (mybinder.org) reads its configuration from a root binder/ folder and refuses to build when binder/ and .binder/ both exist. .binder/postBuild and .binder/requirements.txt move into binder/, so the TinyTorch "Launch Binder" buttons keep working; binder/README.md records which file names the toolchain must not use there. - contributors/projects.json still pointed the book's contributor record at publishing/; it now names binder/, where that .all-contributorsrc lives. - The margin-figure reader-link audit report linked its 222 figures through the retired quarto/ tree; the links now resolve under books/. The hooks reformatted hidden Python cells and trimmed whitespace in the Volume II chapters whose figure imports this rename touches. Checks: ./binder/binder check cli passes (contract and canonical hooks), binder.tools.figures imports, and every workflow YAML file parses. binder test suite, excluding the four modules that cannot import mlsysim through the root symlink (fixed separately): 7 failed, 346 passed. The GitHub repository variables BOOK_ROOT, BOOK_TOOLS, BOOK_DEPS, and BOOK_DOCKER still name the retired book/ layout and must change when this reaches origin.
4.1 KiB
4.1 KiB
GitHub Workflow Runs Cleanup
This script helps clean up old GitHub workflow runs while keeping a configurable number of recent runs per workflow. It's particularly useful when you have many failed runs from debugging.
Quick Start
-
Get a GitHub Personal Access Token
- Go to https://github.com/settings/tokens
- Create a token with
actions:writeandreposcopes - Save the token securely
-
Set up the token
# Option 1: Set environment variable (recommended) export GITHUB_TOKEN="your_token_here" # Option 2: Use --token flag each time -
Preview what would be cleaned up
python3 tools/scripts/cleanup_workflow_runs.py --summary python3 tools/scripts/cleanup_workflow_runs.py --dry-run --keep 5 -
Actually clean up workflow runs
# Keep 5 most recent runs per workflow python3 tools/scripts/cleanup_workflow_runs.py --keep 5 # Keep 10 most recent runs per workflow python3 tools/scripts/cleanup_workflow_runs.py --keep 10
Usage Examples
Show Current State
# See summary of all workflows and run counts
python3 tools/scripts/cleanup_workflow_runs.py --summary
Dry Run (Preview)
# See what would be deleted (keeping 5 runs per workflow)
python3 tools/scripts/cleanup_workflow_runs.py --dry-run --keep 5
# Preview cleanup for specific workflow
python3 tools/scripts/cleanup_workflow_runs.py --dry-run --workflow "quarto-build-container.yml" --keep 3
Actual Cleanup
# Clean all workflows, keep 5 most recent runs each
python3 tools/scripts/cleanup_workflow_runs.py --keep 5
# Clean specific workflow only, keep 3 runs
python3 tools/scripts/cleanup_workflow_runs.py --workflow "quarto-build-container.yml" --keep 3
# Keep more runs (10 per workflow)
python3 tools/scripts/cleanup_workflow_runs.py --keep 10
Advanced Usage
Environment Variables
# Set token once
export GITHUB_TOKEN="ghp_your_token_here"
# Override repository detection
export GITHUB_REPOSITORY="owner/repo"
Workflow-Specific Cleanup
You can target specific workflows by name or filename:
# By workflow filename
python3 tools/scripts/cleanup_workflow_runs.py --workflow "quarto-build-container.yml" --keep 3
# By workflow name
python3 tools/scripts/cleanup_workflow_runs.py --workflow "Quarto Build" --keep 3
Safety Features
- Dry Run Mode: Always preview before deleting
- Rate Limiting: Automatically handles GitHub API rate limits
- Error Handling: Graceful handling of API errors and permissions
- Auto-Detection: Automatically detects repository from git remote
- Confirmation: Clear output showing what was deleted
Troubleshooting
Permission Errors
❌ Permission denied. Check your token has 'actions:write' scope.
- Ensure your GitHub token has
actions:writeandreposcopes - Re-generate token if needed
Rate Limiting
⚠️ Rate limit exceeded. Waiting 60 seconds...
- The script automatically waits for rate limit reset
- GitHub allows 5,000 API requests per hour for authenticated users
Repository Not Found
❌ Repository not specified and could not auto-detect from git
- Use
--repo owner/repoflag - Or ensure you're running from a git repository with GitHub remote
Script Options
| Option | Default | Description |
|---|---|---|
--keep |
5 | Number of recent runs to keep per workflow |
--workflow |
(all) | Target specific workflow by name or filename |
--dry-run |
false | Preview mode - don't actually delete |
--summary |
false | Show workflow summary and exit |
--token |
env var | GitHub personal access token |
--repo |
auto-detect | Repository in owner/repo format |
Best Practices
- Always dry run first: Use
--dry-runto preview changes - Keep enough runs: Don't go below 3-5 runs to maintain debugging context
- Target specific workflows: Use
--workflowfor problematic workflows - Regular cleanup: Run weekly/monthly to prevent accumulation
- Monitor rate limits: Be aware of GitHub API limits for large cleanups