FailTrace 支持从 URL 本地复现 CI 失败

原标题:FailTrace – Reproduce a failed GitHub Actions run locally from its URL
62AI 研判分

FailTrace 是一款面向开发者的开源命令行工具,用户只需粘贴失败的 GitHub Actions 运行链接,它便能定位失败的 job 与 step、匹配对应 commit 的工作流文件、从日志中提取失败原因,并给出本地复现方案。工具提供 inspect、plan、repro 三个子命令,其中 repro 可在 Docker 中复现 Linux 任务里由 run 脚本引发的失败。项目目前处于早期开发阶段,定位与 act 不同,聚焦于解释某次具体运行为何失败并复现该失败。

报道正文

本文目录5 个章节

FailTrace

Stop guessing why CI failed. Reproduce it locally.

FailTrace reproducing a failed stretchr/testify CI run in Docker

Paste a failed GitHub Actions run URL. FailTrace finds the job and step that failed, matches them to the workflow file at that exact commit, pulls the failure out of the logs, and tells you what stands between you and reproducing it on your machine.

BASH
failtrace inspect https://github.com/owner/repo/actions/runs/123456789   # why did it fail?
failtrace plan    https://github.com/owner/repo/actions/runs/123456789   # how would it be reproduced?
failtrace repro   https://github.com/owner/repo/actions/runs/123456789   # reproduce it in Docker

Status: early development. All three commands work. repro covers Linux jobs whose failing step is a run: script. See the roadmap and limitations.

Why not act?

act runs your workflows locally, and it's great at that. FailTrace answers a different question: why did this particular run fail, and can I make it fail the same way here?

  • It starts from a failed run, not a workflow file. You get the exact commit, attempt, job, matrix combination, and failing step. Nothing to configure.
  • It focuses on the failure. The goal is to replay only what the failing step needs, not the whole workflow.
  • It gives you a verdict. You get a diagnosis now. Later you'll also get reproduced / not reproduced / flaky, plus what differed between CI and your machine.

Example

Real output for a failed prometheus/prometheus run (trimmed):

YAML
✗ CI · prometheus/prometheus
  "remote/otlp: remove delta-to-cumulative conversion"
  pull_request · on codex/remove-otlp-deltatocumulative · @ cf7d324 · attempt 1 · failure

────────────────────────────────────────────────────────────
✗ Job: Go tests  (failure)
  Runner     ubuntu-latest → ubuntu-26.04 (20261116.202.1) · runner 2.338.2
  Workflow   .github/workflows/ci.yml → jobs.test_go

  Steps
    ✓  5  Run make GO_ONLY=1 SKIP_GOLANGCI_LINT=1
    ✓  6  Run go test ./tsdb/ -test.tsdb-isolation=false
    ✗  7  Run make -C documentation/examples/remote_storage  ← failed here
    ○  8  Run make -C documentation/examples (skipped)

  Failed step  #7 Run make -C documentation/examples/remote_storage
    shell: sh -e {0}
    $ make -C documentation/examples/remote_storage

  Diagnosis  files out of date (a check produced a git diff) · exit code 2

  Log excerpt (10 lines around the first error in "Run make -C documentation/examples/remote_storage")
    │ >> running check for unused/missing packages in go.mod
    │ go mod tidy
    │ go: downloading github.com/oapi-codegen/nullable v1.1.0
    │ diff --git a/documentation/examples/remote_storage/go.mod b/documentation/examples/remote_storage/go.mod
    │ --- a/documentation/examples/remote_storage/go.mod
    │ +++ b/documentation/examples/remote_storage/go.mod

  Reproduction notes
    ! job runs inside container quay.io/prometheus/golang-builder:1.27-base

The log ends with hundreds of lines of go.sum diff. FailTrace centres the excerpt on the first error line so you see the cause, go mod tidy changing go.mod, instead of the noise after it.

Install

macOS and Linux, using the install script. It downloads the latest release for your platform and verifies its SHA-256 checksum:

BASH
curl -fsSL https://raw.githubusercontent.com/Ri4dH/failtrace/main/scripts/install.sh | sh

It installs to /usr/local/bin if that's writable, otherwise to ~/.local/bin. Set FAILTRACE_INSTALL_DIR to choose, or FAILTRACE_VERSION=v0.1.0 to pin a release.

Prebuilt binaries for macOS, Linux and Windows (amd64 and arm64) are on the releases page, with a checksums.txt.

With Go 1.24+:

BASH
go install github.com/Ri4dH/failtrace/cmd/failtrace@latest

From source:

BASH
git clone https://github.com/Ri4dH/failtrace
cd failtrace
go build -o bin/failtrace ./cmd/failtrace

Usage

BASH
# All failed jobs in the latest attempt of a run
failtrace inspect https://github.com/owner/repo/actions/runs/123456789

# A single job (the URL you get from clicking a job in the Actions UI)
failtrace inspect https://github.com/owner/repo/actions/runs/123456789/job/987654321

# A specific attempt of a re-run workflow
failtrace inspect https://github.com/owner/repo/actions/runs/123456789/attempts/2

# Show more log context, or emit JSON for scripts and other tools
failtrace inspect -n 60 <run-url>
failtrace inspect --json <run-url> | jq '.failed_jobs[0].failure'
FlagDefaultDescription
--jsonoffPrint the report as JSON
-n, --lines25Log lines to show from the failed step
--joball failedInspect only this job ID

Colour output turns off automatically when stdout is not a terminal, or when NO_COLOR is set.

Authentication

FailTrace needs a GitHub token, even for public repositories, because the logs API requires one. It looks in this order:

  1. GITHUB_TOKEN
  2. GH_TOKEN
  3. gh auth token (if you use the GitHub CLI, this already works)

Private repositories need a token that can read Actions on that repo. GitHub Enterprise Server URLs work too: the API base becomes https://<host>/api/v3.

(注:更多技术实现细节与完整 API 文档请查阅原项目 README)