开发者生态
morning
FailTrace – 从其 URL 重现本地运行失败的 GitHub Actions
摘要
Stop guessing why CI failed. Reproduce it locally. 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 th...
the
and
failed
run
step
make
Run
failure
you
github
2026-11-19
1 阅读
约9分钟阅读
ri4dh
字号:
别再猜测 CI 失败的原因了。在本地复制它。粘贴失败的 GitHub Actions 运行 URL。 FailTrace 找到失败的作业和步骤,将它们与确切提交时的工作流文件进行匹配,从日志中提取失败,并告诉您在机器上重现它之间存在什么障碍。 failuretrace 检查 https://github.com/owner/repo/actions/runs/123456789 # 为什么失败? failtrace 计划 https://github.com/owner/repo/actions/runs/123456789 # 它将如何复制? failtrace repro https://github.com/owner/repo/actions/runs/123456789 # reproduce it in Docker Status: early development.所有三个命令都有效。 repro 涵盖了失败步骤是 run: 脚本的 Linux 作业。请参阅路线图和限制。 act 在本地运行您的工作流程,它非常擅长这一点。 FailTrace answers a different question: why did this particular run fail, and can I make it fail the same way here?它从失败的运行开始,而不是工作流程文件。您可以获得准确的提交、尝试、作业、矩阵组合和失败步骤。没有什么可配置的。它专注于失败。目标是仅重播失败步骤所需的内容,而不是整个工作流程。它给你一个判决。你现在就得到诊断。稍后你还会得到复制/未复制/片状的信息,以及 CI 和你的机器之间的差异。失败的 prometheus/prometheus 运行的实际输出(已修剪): ✗ CI · prometheus/prometheus“remote/otlp:删除增量到累积转换” pull_request · on codex/remove-otlp-deltatocumulative · @ cf7d324 · 尝试 1 · 失败────────────────────────────────────────────────────── ✗ 作业:Go 测试(失败) Runner ubuntu-latest → ubuntu-26.04 (20261116.202.1) · runner 2.338.2 Workflow .github/workflows/ci.yml → jobs.test_go 步骤 ✓ 5 运行make GO_ONLY=1 SKIP_GOLANGCI_LINT=1 ✓ 6 运行 go test ./tsdb/ -test.tsdb-isolation=false ✗ 7 运行 make -C 文档/示例/remote_storage ← 此处失败 ○ 8 运行 make -C 文档/示例(已跳过)失败的步骤 #7 运行 make -C 文档/示例/remote_storage shell: sh -e {0} $ make -C Documentation/examples/remote_storage 诊断文件已过期(检查产生了 git diff) · 退出代码 2 日志摘录(“运行 make -C Documentation/examples/remote_storage”中第一个错误周围的 10 行) │ >> 运行检查 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 复制说明!作业在容器内运行 quay.io/prometheus/golang-builder:1.27-base 日志以数百行 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. macOS 和 Linux,使用安装脚本。它会下载适合您平台的最新版本并验证其 SHA-256 校验和:curl -fsSL https://raw.githubusercontent.com/Ri4dH/failtrace/main/scripts/install.sh | sh 如果可写,它会安装到 /usr/local/bin ,否则安装到 ~/.local/bin 。设置 FAILTRACE_INSTALL_DIR 来选择,或 FAILTRACE_VERSION=v0.1.0 来固定版本。 Prebuilt binaries for macOS, Linux and Windows (amd64 and arm64) are on the releases page , with a checksums.txt .使用 Go 1.24+: go install github.com/Ri4dH/failtrace/cmd/failtrace@latest 从源代码: git clone https://github.com/Ri4dH/failtrace cd failuretrace go build -o bin/failtrace ./cmd/failtrace # 最近一次运行失败跟踪尝试中的所有失败作业https://github.com/owner/repo/actions/runs/123456789 # 单个作业(通过在 Actions UI 中单击作业获得的 URL)failtrace 检查 https://github.com/owner/repo/actions/runs/123456789/job/987654321 # 重新运行工作流的特定尝试 failuretrace 检查https://github.com/owner/repo/actions/runs/123456789/attempts/2 # 显示更多日志上下文,或为脚本和其他工具发出 JSON 失败跟踪检查 -n 60 < run-url >失败跟踪检查 --json < run-url > | jq ' .failed_jobs[0].failure ' 标志 默认 说明 --json off 将报告打印为 JSON -n, --lines 25 从失败步骤显示的日志行 --j
这篇文章对您有帮助吗?
订阅66必读
每日精选科技资讯,直达你的邮箱