Skip to content

feat(runner): forge-runner, a self-hosted CI runner on nektos/act (I-4) - #157

Merged
PastaPastaPasta merged 11 commits into
masterfrom
feat/forge-runner
Sep 29, 2026
Merged

PastaPastaPasta merged 11 commits into
masterfrom
feat/forge-runner

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

I-4 of the CI track (platform-parity-spec §2.4, §2.5, §2.8, Group I): forge-runner, a self-hosted CI runner built on nektos/act. It is the "fork of the GitHub runners stack" option: it does not write a new runner. It drives act, git with git-remote-dash, and dg ci report (from #148). It has no forge-core or Platform SDK dependency.

What it does

  • Polls each configured repo. It runs git ls-remote dash://<repo> every interval_secs (at least 30 s) and keeps per-repo tip cursors in the state dir. The first poll only records the tips; a restart re-runs nothing.
  • Checks out each pushed ref that matches refs. It fetches into a per-repo bare cache (dash:// refuses shallow fetches, E205), then clones that into a fresh per-run directory held under a per-repo lock.
  • Reads .forge/workflows/*.y*ml itself (yaml_serde) before act:
    • it evaluates GitHub's on.push rules: branches, tags, paths and their -ignore forms, with ! negation;
    • an invalid file becomes one failed check, carrying the reason;
    • it runs act once per workflow file (-W <file>).
  • Reports every job queued → in_progress → completed through dg ci report:
    • the conclusion is success, failure, skipped or timed_out, and a job act never finished is a failure;
    • one hashed --external-id per job keeps each job to a single check run;
    • the check is named <workflow> / <job>.
  • Uploads each job's log with --log --storage <profile>. Logs are capped at 16 MiB and secret values are redacted first. The web app verifies the log against the logSha256 on chain.
  • Retries a push whose checkout failed on later polls, up to attempts. forge-runner run <repo> --ref … --sha … re-runs one commit by hand.
  • Ships a Dockerfile: dg, git-remote-dash, forge-runner, and act 0.2.89 pinned by sha256 (it matches the release's checksums.txt). It runs as a non-root runner user that owns the state dir.

Security

The boundary is the Docker daemon the runner is given, and the guide says so. On top of that, the runner enforces the following.

Workflow content is checked before act runs:

  • Container and services keys are allowlisted. Only image, env, ports and credentials may appear in container or services.*. Everything else is refused, including options and volumes, and anything a newer act might add.
  • No ${{ }} in container or services. act interpolates these at run time: container: ${{ matrix.c }} would carry options past a static check. This was verified against act 0.2.89.
  • Reusable workflows are refused. A job with jobs.*.uses is refused. A per-repo allow_container_options lifts the container, services and uses rules; it defaults to false.
  • YAML merge keys make the file broken. yaml_serde and act's yaml.v3 disagree on <<:, so a workflow that uses one does not run.
  • Only configured runs-on labels run. A label missing from [platforms] is refused rather than falling back to act's old default images.
  • Job ids are validated (^[A-Za-z_][A-Za-z0-9_-]*$) before they are used in any path. Refused jobs become failed checks with the reason. act gets a filtered copy of the workflow, written outside the checkout.

act itself runs locked down:

  • Environment: env_clear(), then an allowlist of PATH, HOME, TMPDIR, USER, LANG, TZ, DOCKER_* and XDG_*. DASH_FORGE_KEY never reaches act or a job.
  • No Docker socket in jobs (--container-daemon-socket -), and jobs join the bridge network, not the host's.
  • GITHUB_TOKEN: always passed as -s GITHUB_TOKEN=, empty unless the ref is trusted. act therefore never falls back to the host's gh token.
  • Secrets: a secrets file is passed only for trusted_refs, which match nothing by default. Fork PRs never run: only pushes to the watched repo's own refs do.
  • No planted configuration: /dev/null is passed for --env-file, --var-file, --input-file and (when untrusted) --secret-file. A committed .actrc is ignored because act never runs with its working directory in the checkout; the guide notes this.
  • No shared caches: --no-cache-server, plus a per-run --action-cache-path.
  • No host execution: a -self-hosted platform is refused in the config.
  • Timeouts: SIGINT, then SIGKILL after 20 s. With sweep_after_timeout (only on a runner-owned daemon), every act-* container, volume and network is removed, and act-toolcache is reset before each run.

Docs:

  • docs/guides/self-host-runner.md: setup, a compose file with a TLS dind on port 2376 (never 2375, never the host socket), a Security section describing what is actually enforced, and the current limits.
  • docs/guides/ci.md gains a "Self-host a runner" section.

Review

  • A first code-review-validator run came back REQUIRES CHANGES; all of C1, C2, H1–H4 and M1–M11 are fixed.
  • A fresh code-review-validator run then APPROVED. It re-verified each fix against act 0.2.89's source and live experiments, and found no working bypass.
  • Its one medium finding (merge keys) and its four low findings are fixed here: the credentials limitation is documented, unconfigured labels are refused, the .actrc note is added, and invalid-UTF-8 logs are kept.

Tests

  • Unit tests (25):
    • config defaults and refusals, including -self-hosted and secrets only for trusted refs;
    • ref globs;
    • ls-remote parsing and cursors;
    • the act argument builder: isolation flags, empty GITHUB_TOKEN, no cache server, /dev/null files;
    • the act environment allowlist;
    • JSON log parsing and the 16 MiB cap;
    • workflow refusals: options, volumes, services, uses, expressions, unknown keys, merge keys, labels;
    • job-id validation, on.push filters, the filtered workflow copy, and symlinked workflow files;
    • hashed run ids, secret redaction, and the timeout and crash paths.
  • Local e2e (crates/forge-runner/tests/e2e-local.sh): real act and Docker, a local git remote, and a recording dg. PASS, 25/25. It covers:
    • priming, then three reports per job under one run id;
    • success and failure conclusions;
    • logs uploaded to the storage profile, and the job seeing its GITHUB_REF and GITHUB_SHA;
    • no socket, no secrets, an empty token and no Forge key on an untrusted ref, with a planted .actrc and .secrets ignored;
    • a container.options job and a uses: job refused and never run, and an invalid file reported as one failure;
    • a branches: [main] workflow skipped on a feature branch;
    • secrets reaching the job on the trusted ref, and their value appearing in no report;
    • no workflows meaning nothing runs, and no act-* container left behind.
  • Live on moutai (minimal, during the lifted hold): one push to the ci-smoke test repo, owned by a freshly minted identity. forge-runner used the real dash:// checkout, act and dg ci report. One check run went queued → in_progress → completed with success, and the job printed its real GITHUB_SHA. The log went to local RustFS with its logSha256, and the run was trusted.

Not in this PR

  • A relay webhook to wake the runner; polling only.
  • pull_request, schedule and dispatch events.
  • Artefacts (act's artifact server).
  • I-3 (forge-check-action) comes next, on its own branch.

🤖 Generated with Claude Code

PastaPastaPasta and others added 10 commits September 29, 2026 12:45
…lows, report via dg ci

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ide, local e2e

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…hallow fetches), GITHUB_SHA in jobs

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…no key in jobs

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… per-run caches and dirs

Workflows are parsed before act: container/services options and volumes and reusable workflows are refused (one failed check each) unless allowed per repo; invalid YAML is a failed check; on.push branch/tag/path filters decide which files run, one act run per file. act runs with a cleared environment, an explicit empty GITHUB_TOKEN, no cache server and a per-run action cache; -self-hosted platforms are refused; runs are locked per repo in their own directory; a timed-out act gets SIGINT then SIGKILL and, on a runner-owned daemon, a sweep of act-* objects; run ids are hashed; failed starts retry.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… runner enforces, as built

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… services; refuse expressions there

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… parsers disagree on <<)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ogs, document credentials and .actrc limits

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 63a0ab48-2bb5-4b3e-bb17-5a354d8d6e35

📥 Commits

Reviewing files that changed from the base of the PR and between 1dd319f and a937490.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • Cargo.toml
  • crates/forge-runner/Cargo.toml
  • crates/forge-runner/Dockerfile
  • crates/forge-runner/build.rs
  • crates/forge-runner/src/act.rs
  • crates/forge-runner/src/config.rs
  • crates/forge-runner/src/main.rs
  • crates/forge-runner/src/run.rs
  • crates/forge-runner/src/watch.rs
  • crates/forge-runner/src/workflow.rs
  • crates/forge-runner/tests/e2e-local.sh
  • docs/guides/README.md
  • docs/guides/ci.md
  • docs/guides/self-host-runner.md

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…de_json preserve_order varies by build)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@PastaPastaPasta
PastaPastaPasta merged commit a409129 into master Sep 29, 2026
23 checks passed
@PastaPastaPasta
PastaPastaPasta deleted the feat/forge-runner branch September 29, 2026 18:08
PastaPastaPasta added a commit that referenced this pull request Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant