Act Setup (Local CI)
Quick Setup (5 minutes)
Section titled “Quick Setup (5 minutes)”1. Install act
Section titled “1. Install act”macOS:
brew install actLinux:
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bashWindows (Chocolatey):
choco install act-cliManual install: Download from act releases
2. Verify Docker
Section titled “2. Verify Docker”# Check Docker is runningdocker info
# If not, start Docker Desktopopen -a Docker # macOS3. Test Installation
Section titled “3. Test Installation”# List available workflowsact -l
# You should see jobs from .github/workflows/ci.yml4. Create Secrets File (Optional)
Section titled “4. Create Secrets File (Optional)”# Copy examplecp .secrets.example .secrets
# Edit with your tokens (if needed)nano .secretsAdd real values for:
GITHUB_TOKEN- For GitHub API access (generate at https://github.com/settings/tokens)CODECOV_TOKEN- For code coverage uploads (optional)CARGO_REGISTRY_TOKEN- For crate publishing (optional)
Note: Most tests don’t require secrets. Only create .secrets if workflows fail with “secret not found”.
5. Run Your First Test
Section titled “5. Run Your First Test”# Test the CI workflow./test-ci-with-act.sh testFirst run: Downloads runner images (~2GB), takes 5-10 minutes.
Subsequent runs: Much faster (images are cached).
Configuration
Section titled “Configuration”.actrc - Runner Settings
Section titled “.actrc - Runner Settings”The project includes pre-configured settings in .actrc:
# GitHub-compatible runner images-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest
# Verbose output for debugging-v
# Reuse containers for speed--reuse
# Resource limits (adjust for your machine)--container-options "--cpus=4 --memory=8g"Customize for your machine:
# Edit .actrcnano .actrc
# Reduce resources for older machines:--container-options "--cpus=2 --memory=4g".secrets - Secret Management
Section titled “.secrets - Secret Management”Never commit .secrets - it’s gitignored for security.
Minimal secrets (most workflows work without secrets):
GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxFull secrets (for all workflows):
GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxCODECOV_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxCARGO_REGISTRY_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxRun All Tests
Section titled “Run All Tests”./test-ci-with-act.shThis runs all jobs in .github/workflows/ci.yml:
- ✅ Formatting check (
cargo fmt) - ✅ Linting (
cargo clippy) - ✅ Test suite (
cargo test) - ✅ Security audit (
cargo audit) - ✅ Release builds
- ✅ Benchmarks
- ✅ Code coverage
Run Specific Job
Section titled “Run Specific Job”# Just the test job./test-ci-with-act.sh test
# Just security audit./test-ci-with-act.sh security
# Just builds./test-ci-with-act.sh buildList Available Jobs
Section titled “List Available Jobs”./test-ci-with-act.sh --listOutput:
Stage Job ID Job name Workflow name Workflow file Events0 test Test Suite CI ci.yml push,pull_request0 security Security Audit CI ci.yml push,pull_request0 build Build Release CI ci.yml push,pull_request0 benchmark Benchmarks CI ci.yml push,pull_request0 coverage Code Coverage CI ci.yml push,pull_requestComparison: Native vs. act
Section titled “Comparison: Native vs. act”You have two testing options:
Native Testing (Recommended for daily dev)
Section titled “Native Testing (Recommended for daily dev)”./test-ci-locally.shPros:
- ⚡ Fast (no Docker overhead)
- 🎯 Tests your actual environment
- 🍎 Perfect for Apple Silicon MLX tests
- 📴 Works offline
Best for: Daily development, rapid iteration
act Testing (Recommended pre-push)
Section titled “act Testing (Recommended pre-push)”./test-ci-with-act.shPros:
- 🎭 Emulates GitHub’s exact environment
- 🔄 Tests matrix builds (Ubuntu/macOS/Windows)
- 🐛 Catches platform-specific bugs
- ✅ High confidence CI will pass
Best for: Pre-merge validation, workflow testing
Recommendation: Use native testing during development, then run act before pushing.
Apple Silicon (M1/M2/M3) Notes
Section titled “Apple Silicon (M1/M2/M3) Notes”Native Testing Preferred
Section titled “Native Testing Preferred”For MLX backend tests, use native testing:
./test-ci-locally.shThis runs real MLX tests on Metal hardware.
act Limitations
Section titled “act Limitations”act runs in Docker, which can’t access Metal APIs:
- ❌ Can’t run MLX inference tests
- ✅ Can verify MLX tests compile on Ubuntu
- ✅ Can test all other backends (vLLM, Ollama, CPU)
Architecture Flag
Section titled “Architecture Flag”If you get architecture errors:
# Force amd64 architectureact --container-architecture linux/amd64
# Or add to .actrc:echo "--container-architecture linux/amd64" >> .actrcTroubleshooting
Section titled “Troubleshooting”Error: act: command not found
Section titled “Error: act: command not found”Solution: Install act (see step 1 above)
Error: Cannot connect to Docker daemon
Section titled “Error: Cannot connect to Docker daemon”Solution:
# Start Docker Desktopopen -a Docker # macOSsudo systemctl start docker # Linux
# Verify it's runningdocker infoError: Segmentation fault or exec format error
Section titled “Error: Segmentation fault or exec format error”Cause: Architecture mismatch (Apple Silicon running x86_64 images)
Solution:
# Force amd64 architectureact --container-architecture linux/amd64Error: Container killed (OOM)
Section titled “Error: Container killed (OOM)”Cause: Not enough memory allocated to Docker
Solution 1: Increase Docker memory (Docker Desktop → Settings → Resources)
Solution 2: Reduce memory in .actrc:
--container-options "--cpus=2 --memory=4g"Solution 3: Run single-threaded tests:
# In workflow, use:cargo test -- --test-threads=1Slow First Run
Section titled “Slow First Run”Cause: Downloading runner images (~2GB)
Solution: Be patient - first run takes 5-10 minutes. Subsequent runs are much faster due to caching.
Pre-download images:
docker pull ghcr.io/catthehacker/ubuntu:act-latestJobs Fail in act But Pass Locally
Section titled “Jobs Fail in act But Pass Locally”Possible causes:
-
Environment differences
- Check env vars in workflow
- Verify tools are installed in runner image
-
Missing secrets
- Create
.secretsfile - Add required tokens
- Create
-
Platform-specific code
- Some tests require native platform (MLX)
- Use native testing for these
Debug:
# Run with verbose loggingact -v -j test
# Inspect runner containerdocker run -it ghcr.io/catthehacker/ubuntu:act-latest bash
# Check installed toolswhich cargorustc --versionDevelopment Workflow
Section titled “Development Workflow”Daily Development Loop
Section titled “Daily Development Loop”# 1. Make changesvim src/main.rs
# 2. Quick test (native)cargo test
# 3. Full local CI check./test-ci-locally.sh
# 4. Fix any issues, repeatPre-Push Validation
Section titled “Pre-Push Validation”# 1. Run native tests./test-ci-locally.sh
# 2. Run act validation./test-ci-with-act.sh
# 3. Push with confidencegit pushPre-Merge Checklist
Section titled “Pre-Merge Checklist”-
cargo fmt --all -- --checkpasses -
cargo clippy -- -D warningspasses -
cargo testpasses -
cargo auditpasses - Binary size < 50MB
-
./test-ci-locally.shpasses - (Optional)
./test-ci-with-act.shpasses - All tests green on GitHub Actions
Advanced Usage
Section titled “Advanced Usage”Run Specific Workflow File
Section titled “Run Specific Workflow File”# Run ci.yml onlyact -W .github/workflows/ci.yml
# Run publish.ymlact -W .github/workflows/publish.ymlTest Different Events
Section titled “Test Different Events”# Test push event (default)./test-ci-with-act.sh test push
# Test pull_request event./test-ci-with-act.sh test pull_request
# Test release eventact releaseDry Run (Show What Would Run)
Section titled “Dry Run (Show What Would Run)”# Show jobs without runningact -n
# Show specific jobact -n -j testCustom Runner Images
Section titled “Custom Runner Images”# Use different image (e.g., smaller)act -P ubuntu-latest=node:16-buster
# Or use official GitHub images (larger)act -P ubuntu-latest=ghcr.io/actions/runner:latestDebug Mode
Section titled “Debug Mode”# Verbose loggingact -v
# Even more verboseact -v -v
# Debug specific stepact --debug -j testResources
Section titled “Resources”Documentation
Section titled “Documentation”- Full guide:
docs/LOCAL_CI_TESTING.md - Quick reference:
docs/ACT_QUICKREF.md - act repository: https://github.com/nektos/act
- Runner images: https://github.com/catthehacker/docker_images
Scripts
Section titled “Scripts”./test-ci-with-act.sh- Run workflows with act./test-ci-locally.sh- Run tests natively.actrc- act configuration.secrets.example- Secrets template
Workflows
Section titled “Workflows”.github/workflows/ci.yml- Main CI workflow.github/workflows/publish.yml- Package publish workflow.github/workflows/release.yml- Release workflow
Next Steps
Section titled “Next Steps”- Install act:
brew install act - Test it works:
./test-ci-with-act.sh --list - Run a job:
./test-ci-with-act.sh test - Integrate into workflow: Run before every push
Questions? Check docs/LOCAL_CI_TESTING.md for detailed troubleshooting.
Happy testing! 🚀