Repository: nektos/act
Stars: 69905
CLAUDE.md
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Act is a tool to run GitHub Actions locally. It reads .github/workflows/ files, builds an execution plan, and uses Docker to run containers for each action. Written in Go 1.24+.
Common Commands
- make build — build binary to dist/local/act
- make test — run go test ./... and the act CLI
- make lint-go — run golangci-lint run
- make format — run go fmt ./...
- make tidy — run go mod tidy
- make pr — full PR checklist: tidy, format-all, lint, test
- go test ./pkg/runner/... — run tests for a single package
- go test ./pkg/runner/ -run TestRunEvent — run a single test
Architecture
Execution Flow
1. CLI (cmd/root.go) — Cobra-based CLI parses flags into an Input struct
2. Planner (pkg/model/planner.go) — parses workflow YAML into a Plan containing Stages (serial) with Runs (parallel jobs)
3. Runner (pkg/runner/runner.go) — converts the Plan into composable Executor chains
4. RunContext (pkg/runner/run_context.go) — holds all state for a job execution (env vars, matrix, containers, expressions)
5. Steps (pkg/runner/step.go) — each step type (action, docker, script) implements the step interface
Core Abstraction: Executor Pattern
The Executor type (pkg/common/executor.go) is a func(ctx context.Context) error used throughout the codebase. Executors compose via:
- .Then(), .Finally(), .OnError() — chaining
- NewPipelineExecutor() — serial execution
- NewParallelExecutor() — parallel execution
- .If(), .IfNot() — conditional execution
Key Packages
- pkg/model/ — workflow YAML parsing, plan creation, action definitions
- pkg/runner/ — core execution engine, expression evaluation, step types (local/remote/docker/composite actions, reusable workflows)
- pkg/container/ — Docker API wrapper, container and host execution environments
- pkg/common/ — Executor pattern, context utilities, logging
- pkg/exprparser/ — GitHub Actions ${{ }} expression language interpreter
- pkg/artifacts/ and pkg/artifactcache/ — artifact upload/download and caching server
Linting Rules
Configured in .golangci.yml:
- Use errors from stdlib, not github.com/pkg/errors
- Use github.com/sirupsen/logrus (aliased as log), not stdlib log
- Use github.com/stretchr/testify for tests, not gotest.tools/v3
- Max cyclomatic complexity: 20
- Import aliases enforced: logrus → log, testify/assert → assert
Testing
- Tests use testify/assert and testify/mock
- Table-driven tests are common in pkg/model/ and pkg/exprparser/
- Test fixtures live in testdata/ directories alongside their packages
- pkg/runner/testdata/ contains extensive sample GitHub Actions workflows used as integration test fixtures
README.md
Overview   
"Think globally, act locally"Run your GitHub Actions locally! Why would you want to do this? Two reasons:
- Fast Feedback - Rather than having to commit/push every time you want to test out the changes you are making to your .github/workflows/ files (or for any changes to embedded GitHub actions), you can use act to run the actions locally. The environment variables and filesystem are all configured to match what GitHub provides.
- Local Task Runner - I love make>). However, I also hate repeating myself. With act, you can use the GitHub Actions defined in your .github/workflows/ to replace your Makefile!
Now Manage and Run Act Directly From VS Code!<br/>
Check out the GitHub Local Actions Visual Studio Code extension which allows you to leverage the power of act to run and test workflows locally without leaving your editor.How Does It Work?
When you run act it reads in your GitHub Actions from .github/workflows/ and determines the set of actions that need to be run. It uses the Docker API to either pull or build the necessary images, as defined in your workflow files and finally determines the execution path based on the dependencies that were defined. Once it has the execution path, it then uses the Docker API to run containers for each action based on the images prepared earlier. The environment variables and filesystem are all configured to match what GitHub provides.
Let's see it in action with a sample repo!
!Demo
Act User Guide
Please look at the act user guide for more documentation.
Support
Need help? Ask in discussions!
Contributing
Want to contribute to act? Awesome! Check out the contributing guidelines to get involved.
Manually building from source
- Install Go tools 1.20+ - (<https://golang.org/doc/install>)
- Clone this repo git clone [email protected]:nektos/act.git
- Run unit tests with make test
- Build and install: make install