This guide explains how to use act to run your GitHub Actions workflows locally, providing fast feedback and debugging capabilities for your CI/CD pipelines.
Act is a tool that allows you to run GitHub Actions locally using Docker. It reads your .github/workflows/ files and executes them in a local environment that mimics GitHub's runner environment.
- Fast Feedback: Test workflow changes without pushing to GitHub
- Debugging: Identify issues before they reach CI
- Resource Efficiency: No GitHub Actions minutes consumed
- Local Development: Validate syntax and logic locally
- Matrix Testing: Test all Python version combinations
brew install actSee the act installation guide for your platform.
- Docker: Act requires Docker to be running
- Docker Desktop: Recommended for macOS/Windows users
# macOS
open -a Docker
# Linux
sudo systemctl start dockerIf you're on Apple Silicon, you'll need to specify the container architecture:
# Create act configuration
mkdir -p "/Users/$USER/Library/Application Support/act"
echo "-P ubuntu-latest=catthehacker/ubuntu:act-latest" > "/Users/$USER/Library/Application Support/act/actrc"Act reads from your .env file. Ensure environment variable names use underscores (not hyphens):
# ✅ Correct format
fastwoe_token=pypi-...
xrisklab_token=pypi-...
# ❌ Incorrect format (act doesn't like hyphens)
fastwoe-token=pypi-...
xrisklab-token=pypi-...act --container-architecture linux/amd64 --list# Run the CI workflow
act --container-architecture linux/amd64 -W .github/workflows/ci.yml
# Run the type checking workflow
act --container-architecture linux/amd64 -W .github/workflows/typecheck.yml
# Run compatibility tests
act --container-architecture linux/amd64 -W .github/workflows/compatibility.yml# Run only the test job
act --container-architecture linux/amd64 -j test -W .github/workflows/ci.yml
# Run only the lint job
act --container-architecture linux/amd64 -j lint -W .github/workflows/ci.yml
# Run only the type-check job
act --container-architecture linux/amd64 -j type-check -W .github/workflows/ci.yml# Validate workflow without executing
act --container-architecture linux/amd64 -W .github/workflows/ci.yml --dryrun
# Test specific job
act --container-architecture linux/amd64 -j lint -W .github/workflows/ci.yml --dryrunWhen testing Kiro's new IV standard errors functionality:
# Test the enhanced type checking workflow
act --container-architecture linux/amd64 -W .github/workflows/typecheck.yml --dryrun
# Test CI type checking
act --container-architecture linux/amd64 -j type-check -W .github/workflows/ci.yml --dryrunTest specific Python versions:
# Test Python 3.11 specifically
act --container-architecture linux/amd64 -j test -W .github/workflows/ci.yml --matrix python-version:3.11 --dryrun
# Test Python 3.12 specifically
act --container-architecture linux/amd64 -j test -W .github/workflows/ci.yml --matrix python-version:3.12 --dryrunTest different trigger events:
# Test pull request event
act --container-architecture linux/amd64 -W .github/workflows/ci.yml --event pull_request --dryrun
# Test push event (default)
act --container-architecture linux/amd64 -W .github/workflows/ci.yml --event push --dryrun# Test all CI jobs
act --container-architecture linux/amd64 -W .github/workflows/ci.yml --dryrun
# Test only tests (Python 3.9-3.12 matrix)
act --container-architecture linux/amd64 -j test -W .github/workflows/ci.yml --dryrun
# Test only linting
act --container-architecture linux/amd64 -j lint -W .github/workflows/ci.yml --dryrun
# Test only type checking
act --container-architecture linux/amd64 -j type-check -W .github/workflows/ci.yml --dryrun# Test the dedicated type checking workflow
act --container-architecture linux/amd64 -W .github/workflows/typecheck.yml --dryrun
# This workflow includes:
# - Python 3.11 setup
# - uv installation
# - Dependencies installation
# - FastWoe & ty verification
# - CI checks (format, lint, typecheck)
# - Strict type checking# Test Python version compatibility
act --container-architecture linux/amd64 -W .github/workflows/compatibility.yml --dryrun# Test release process
act --container-architecture linux/amd64 -W .github/workflows/release.yml --dryrunact --container-architecture linux/amd64 -W .github/workflows/ci.yml -v --dryrunact --container-architecture linux/amd64 -W .github/workflows/ci.yml --env CUSTOM_VAR=value --dryrun# Skip specific jobs
act --container-architecture linux/amd64 -W .github/workflows/ci.yml --skip-job test --dryrun# Use a different base image
act --container-architecture linux/amd64 -P ubuntu-latest=ubuntu:22.04 -W .github/workflows/ci.yml --dryrun# Error: Cannot connect to the Docker daemon
# Solution: Start Docker Desktop
open -a Docker # macOS# Error: Container architecture mismatch
# Solution: Always use --container-architecture linux/amd64
act --container-architecture linux/amd64 [other-options]# Error: unexpected character "-" in variable name
# Solution: Use underscores instead of hyphens in .env file
fastwoe_token=... # ✅ Correct
fastwoe-token=... # ❌ Incorrect# Error: Failed to pull image
# Solution: Check Docker is running and has internet access
docker pull catthehacker/ubuntu:act-latest- Start with dry runs: Always use
--dryrunfirst to validate syntax - Test individual jobs: Use
-j job-nameto isolate issues - Check Docker: Ensure Docker is running and accessible
- Verify environment: Check your
.envfile format - Use verbose mode: Add
-vfor detailed output
# Test workflows before committing
act --container-architecture linux/amd64 -W .github/workflows/ci.yml --dryrun
# If dry run passes, commit your changes
git add .
git commit -m "Add new feature"
git push# Test new workflow changes
act --container-architecture linux/amd64 -W .github/workflows/typecheck.yml --dryrun
# Test specific functionality
act --container-architecture linux/amd64 -j type-check -W .github/workflows/ci.yml --dryrun# Test release workflow
act --container-architecture linux/amd64 -W .github/workflows/release.yml --dryrun
# Test compatibility across Python versions
act --container-architecture linux/amd64 -W .github/workflows/compatibility.yml --dryrun- Always use dry runs first: Validate syntax before execution
- Test individual jobs: Isolate issues by testing specific jobs
- Use consistent architecture flags: Always use
--container-architecture linux/amd64on Apple Silicon - Keep environment clean: Ensure
.envfile uses proper naming conventions - Test matrix combinations: Verify all Python version combinations work
- Validate new workflows: Test new workflow files before pushing
Your project includes these workflows:
ci.yml: Main CI pipeline with tests, linting, and type checkingtypecheck.yml: Dedicated type checking with ty integrationcompatibility.yml: Python version compatibility testingrelease.yml: Release automation and publishing
Each workflow can be tested locally using the commands above, providing fast feedback for your development process.