local-ci
Run the GitHub Actions jobs your branch would trigger, on your machine, and get a short report back.
local-ci run # what a pull request of these changes would trigger
local-ci run --all # every check a pull request can trigger
local-ci reads .github/workflows/, works out which workflows a pull request
from this branch would start (triggers, branches, paths / paths-ignore),
and runs their jobs in a throwaway git worktree of the commit. It prints one
line per job and, for a failure, the end of the failing step's log. Full logs
and a JSON result are kept on disk.
It is meant for the moment before you push, and for coding agents that need to know "would CI pass?" without reading workflow files and logs themselves.
With examples/demo and a change that breaks one test shard:
$ local-ci run --no-status
local-ci 0.1.0 · 350924e vs main · 1 file changed · triggered by the changes · logs ~/Library/Caches/local-ci/runs/demo-2daacfc9/1793539365-350924e
setup ok 1 step 0s
PASS ci.yml › lint 0s
PASS ci.yml › discover 0s
PASS ci.yml › test (1) 0s
FAIL ci.yml › test (2) › Unit tests (shard 2) (exit 1) 0s
PASS ci.yml › integration 3s
SKIP deploy (needs failed)
── ci.yml › test (2) › Unit tests (shard 2) (exit 1)
expected 5, got 4
log: ~/Library/Caches/local-ci/runs/demo-2daacfc9/1793539365-350924e/ci-test-2/03-unit-tests-shard-2.log
result: failure · pass 4 / fail 1 / error 0 / skip 1 · 3s
status: not posted (--no-status)
It is not a GitHub Actions runner. Jobs run directly on your machine (not in
Ubuntu containers), with the tools you have installed. What cannot be
reproduced locally is skipped and listed under not covered instead of being
reported as a pass.
Install
cargo install local-ci
Or download a binary from the releases.
Commands
| Command | What it does |
|---|---|
local-ci plan |
Show the workflows, units and setup steps that would run. Runs nothing. |
local-ci run |
Run them and report. Exit code 0 = success, 1 = failure, 2 = error (could not check everything), 130 = interrupted. |
local-ci status |
Record the last run's result as the local-ci commit status (for a commit you have pushed since). |
Common options (plan and run):
| Option | |
|---|---|
--base <ref> |
Compare against this ref. Default: origin's default branch. |
--sha <rev> |
Test this commit. Default: HEAD. Uncommitted changes are never tested. |
--all |
All checks: ignore paths / paths-ignore, and run workflows that are disabled on GitHub. branches and types still apply, so a workflow that only runs on pushes to main stays out. |
--include-disabled |
Also run workflows that are disabled on GitHub, with paths / paths-ignore still applied. --all implies it. |
--workflows-dir <dir> |
Also read the workflows in this directory (relative to the repository root, repeatable). GitHub never runs them, so this is the place for checks you only want before pushing. They are picked by the same triggers and paths, read from the commit like the rest, and named by their path in the output (ci/local/mutation.yml › ...). |
-w, --workflow <file or name> |
Only these workflows. |
-j, --job <id> |
Only these jobs, plus the jobs they need. |
-C <dir> |
Repository directory. |
run also takes --parallel <n>, --no-canirun, --no-status, --keep
(keep the worktrees), --tail <lines>, --job-timeout <minutes> and --json.
How a run works
- Worktree. The commit is checked out with
git worktree add --detachunder the cache directory. Your working tree is never touched, so steps such asgit add -A,cp .env.example .envor generators that rewrite tracked files are harmless. The worktree is removed afterwards. - Setup, once. In CI every job runs
npm cion a fresh VM. Locally that would install the same dependencies once per job. Install steps (npm ci,pip install,flutter pub get,npx prisma generate, ...) and steps that several jobs repeat word for word at their start are run once, before any job, and skipped in the jobs. Installs that happen later anyway (a matrix job, a script that callsnpm ci) go through annpmwrapper onPATH: a directory is installed once per run and lockfile, and laternpm ci/npm installthere are no-ops. - Units in parallel. Jobs linked by
needs:(or writing the same build output) form a unit and run in order. Units run in parallel, each in its own copy of the worktree as it is after setup, as each CI job has its own checkout: a job that edits files for a while (a negative control, a formatter, mutation testing) is not seen by the jobs beside it. The copy is a copy-on-write clone (clonefile(2)on APFS,cp --reflink=autoelsewhere), sonode_modulesand other setup output cost little to copy. Units that start services or containers, or look like integration / e2e tests, are exclusive: they hold a per-repository lock, so they never overlap, in this run or in anotherlocal-cirun of the same repository. - Report. One line per job, the tail of each failing step, where the logs
are, and the overall state:
success,failureorerror. - Commit status. The state is posted as the
local-cicommit status withghwhen the commit is on GitHub. Before you push it is not; runlocal-ci statusafter pushing.--no-statusskips this.
What is supported
- Triggers
pull_request/pull_request_target(withtypes,branches,paths,paths-ignore) andpush. A run pretends to be a non-draft pull request into the base branch.workflow_dispatch,scheduleand the rest are reported as not triggered, and so are workflows disabled on GitHub (read withghwhen it is available) unless--include-disabledor--allis given. run:steps withbash(GitHub'sbash --noprofile --norc -eo pipefail),sh,pythonor a customshell: ... {0};working-directory,env,if:,continue-on-error,timeout-minutes.- Expressions: contexts
github,env,matrix,steps,needs,job,runner,strategy,inputs,vars; operators;success(),failure(),always(),cancelled(),contains,startsWith,endsWith,format,join,toJSON,fromJSON,hashFiles(always empty). Anything else is an error, never a silentfalse. strategy.matrixwithinclude/exclude, matrices computed fromneeds.*.outputs,fail-fast.$GITHUB_OUTPUT,$GITHUB_ENV,$GITHUB_PATH,$GITHUB_STEP_SUMMARY; joboutputs.services:with Docker. Each container gets a free host port, andlocalhost:<port>/127.0.0.1:<port>in the job'senvandrun:scripts (and*PORT*variables holding the port) are rewritten to it, so a database you already run on 5432 is not in the way.--health-cmdis waited for.uses:—actions/checkout, caches and artifacts are skipped;setup-node,setup-python,setup-go,setup-java,setup-ruby,flutter-action,setup-dartandrust-toolchaincheck that the tool is installed and warn when its version differs. Other actions are skipped and listed undernot covered.
Not covered: steps that read secrets.* or github.token, steps that push,
publish or deploy (git push, gh release, npm publish, aws, kubectl,
terraform apply, ...), steps that install system packages (sudo,
apt-get, brew install, ...), container: jobs and reusable workflows. A
git push from inside a script is pointed at a URL that does not exist. pip install goes into a virtualenv of the run and npm install -g
into a prefix of the run, so neither changes your machine.
Working with other tools
- canirun: when it is installed,
every
run:step outside setup is wrapped incanirun exec, so heavy steps wait for CPU instead of piling up. Timeouts start when the step gets its turn. - Ports used by a workflow's own
docker composesteps are not rewritten; exclusive units take the per-repository lock instead.
Files
The cache directory is ~/Library/Caches/local-ci on macOS and
$XDG_CACHE_HOME/local-ci (or ~/.cache/local-ci) elsewhere; set
LOCAL_CI_HOME to move it. It holds the worktrees while they run
(wt/<sha>-<pid> and one wt/<sha>-u<n>-<pid> per unit), the last 20
runs of each repository (runs/<repo>/<time>-<sha>/ with one log per step and
result.json), and the locks.
License
MIT