# 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 `Stage`s (serial) with `Run`s (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 ![act-logo](https://raw.githubusercontent.com/wiki/nektos/act/img/logo-150.png) # Overview [![push](https://github.com/nektos/act/workflows/push/badge.svg?branch=master&event=push)](https://github.com/nektos/act/actions) [![Go Report Card](https://goreportcard.com/badge/github.com/nektos/act)](https://goreportcard.com/report/github.com/nektos/act) [![awesome-runners](https://img.shields.io/badge/listed%20on-awesome--runners-blue.svg)](https://github.com/jonico/awesome-runners) > "Think globally, `act` locally" Run your [GitHub Actions](https://developer.github.com/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](https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables) and [filesystem](https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#filesystems-on-github-hosted-runners) 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`! > [!TIP] > **Now Manage and Run Act Directly From VS Code!**
> Check out the [GitHub Local Actions](https://sanjulaganepola.github.io/github-local-actions-docs/) 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](https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables) and [filesystem](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#file-systems) are all configured to match what GitHub provides. Let's see it in action with a [sample repo](https://github.com/cplee/github-actions-demo)! ![Demo](https://raw.githubusercontent.com/wiki/nektos/act/quickstart/act-quickstart-2.gif) # Act User Guide Please look at the [act user guide](https://nektosact.com) for more documentation. # Support Need help? Ask in [discussions](https://github.com/nektos/act/discussions)! # Contributing Want to contribute to act? Awesome! Check out the [contributing guidelines](CONTRIBUTING.md) to get involved. ## Manually building from source - Install Go tools 1.20+ - () - Clone this repo `git clone git@github.com:nektos/act.git` - Run unit tests with `make test` - Build and install: `make install`