This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

使用 EAS CLI 查询 EAS Insights

通过终端使用 eas workflow:insights 命令查询 EAS 工作流程和 Maestro 的见解。


EAS Insights 的 Workflows 和 Maestro 标签显示的指标,也可以通过终端获取。使用 eas workflow:insights 命令来检查运行状态、找到不稳定的流程,并将数据输入到你自己的报告中。

🌐 The metrics the Workflows and Maestro tabs of EAS Insights show are also available from the terminal. Use the eas workflow:insights commands to check run health, find flaky flows, and feed the numbers into your own reports.

有关更新和渠道使用,请参见 EAS CLI 参考中的eas update:insights和eas channel:insights。

🌐 For update and channel usage, see eas update:insights and eas channel:insights in the EAS CLI reference.

先决条件

🌐 Prerequisites

先决条件

3 要求

1.

EAS 命令行工具

全局安装 EAS CLI:

Terminal
- npm install --global eas-cli
- yarn global add eas-cli
- pnpm add --global eas-cli
- bun add --global eas-cli

2.

一个运行 EAS 工作流的项目

请查看 开始使用 EAS 工作流。要获取 Maestro 的洞察信息,项目还需要一个带有 maestro 任务 的工作流。随着工作流的运行,结果会自动显示。

3.

从你的项目目录登录 EAS CLI

使用 eas login 登录。默认情况下,每个命令都会从当前目录的应用配置中读取项目 ID。使用 --project-id 可以从任何地方查询项目,并使用具有访问权限的账户:

Terminal
- eas workflow:insights --project-id <project-id>

计划和回顾限制

🌐 Plans and lookback limits

工作流程和Maestro洞察功能可在生产版和企业版计划中使用。查看EAS定价了解每个计划包含的内容。

🌐 Workflows and Maestro insights are available on the Production and Enterprise plans. See EAS pricing for what each plan includes.

每个计划也限制了时间范围可以追溯多远:

🌐 Each plan also limits how far back a time range can start:

  • 生产:过去30天。
  • 企业:过去365天。

这个限制适用于拥有该项目的账号计划。当时间范围开始得比计划允许的早时,命令会失败并告诉你你的计划包含多少天。

🌐 The limit applies to the plan of the account that owns the project. When a time range starts earlier than the plan allows, the command fails and tells you how many days your plan includes.

命令

🌐 Commands

命令它显示的内容
eas workflow:insights运行次数、成功率和每个工作流的趋势
eas workflow:insights:maestro你的 Maestro 流程的通过率和偶发失败率,或者单个流程的历史记录

两个命令都接受这些标志:

🌐 Both commands accept these flags:

  • --days <number>:显示最近 N 天的数据。默认是 7 天。
  • --start <ISO date> 和 --end <ISO date>:设定一个明确的时间范围。与 --days 互斥。单独传 --start 可以包含直到现在的所有内容。单独传 --end 会失败。
  • --workflow <file name>:只包括这个工作流文件的运行,例如 ci.yml。包括文件扩展名,并且对多个工作流重复使用这个标志。工作流在首次运行后才会对这个标志可用。项目不知道的名称会导致命令失败,并列出它知道的名称。
  • --git-ref <ref>:只包含为这个 git 引用请求的运行。命令会把像 main 这样的裸名当作分支,并将其展开为 refs/heads/main。其他情况,请传递完整的引用,比如 refs/tags/v1.0.0。命令会匹配完整的 40 字符提交 SHA,就像 eas workflow:run 记录的那样。
  • --limit <number>:要列出多少行。默认是50行。该命令不接受1到100之外的数值。
  • --project-id <id>:在不进入项目目录的情况下查询项目。
  • --json:机器可读输出。意味着 --non-interactive。
  • --non-interactive:不要提示就失败。

洞察只包括已完成的运行。时间范围以完整的 UTC 时段查询,因此命令报告的范围可能比你请求的略宽。概览指标将所选时间范围与之前相同长度的时期进行比较。例外是 eas workflow:insights:maestro --flow,它只报告所选范围内单个流的数字。数据是汇总用于趋势分析的,可能会滞后于实时。可以用它来研究趋势,而不是作为权威记录。

🌐 Insights include finished runs only. Time ranges are queried in whole UTC periods, so a command can report a slightly wider range than the one you asked for. Overview metrics compare the selected time range with the previous period of equal length. The exception is eas workflow:insights:maestro --flow, which reports one flow's numbers for the selected range alone. The data is aggregated for trend analysis and can lag behind real time. Use it to investigate trends rather than as an authoritative record.

使用 --help 运行任何命令以查看你安装的 EAS CLI 版本支持的所有标志。

🌐 Run any command with --help to see the flags supported by your installed EAS CLI version.

eas workflow:insights

显示与工作流标签相同的概览、运行时长拆分和工作流表格。用它可以查看你的工作流运行和成功的频率,以及哪些工作流失败最多。

🌐 Shows the same overview, runs-over-time breakdown, and workflows table as the Workflows tab. Use it to see how often your workflows run and succeed, and which ones fail most.

Terminal
# Last 7 days, all workflows
- eas workflow:insights

# One workflow, last 30 days
- eas workflow:insights --workflow ci.yml --days 30

# Only failed runs on the main branch
- eas workflow:insights --status FAILURE --git-ref main

# Only runs started by a GitHub push
- eas workflow:insights --trigger GITHUB_PUSH

命令标志:

🌐 Command flags:

  • --status <status>:只包括具有此状态的运行。可选 SUCCESS、FAILURE 或 CANCELED 中的一个。对于多个状态,请重复使用该标志。
  • --trigger <type>:只包含由此触发器启动的运行,例如 MANUAL、SCHEDULE 或 GITHUB_PUSH。对多个触发器重复使用该标志。运行 eas workflow:insights --help 获取完整列表。

输出有三个部分:

🌐 The output has three parts:

  • 概览:总运行次数、成功率、活跃工作流和失败运行数,以及与上一个周期的变化。
  • 运行超时:每个时间周期的总运行次数、成功次数、失败次数和取消次数。时间周期是完整的UTC区间,其长度根据时间范围而定。表格只列出了有运行记录的周期,如果有遗漏,会在标题中说明。当选定时间范围内没有任何运行时,表格不会显示。
  • 工作流:在这个时间范围内运行次数最多的工作流,以及它们的运行次数、成功率和上次运行时间。工作流 列显示的是文件名,因此你可以直接将一行传给 --workflow。

使用 --json 时,这些部分是 overview、runsOverTime 和 workflows 键,以及在设置过滤器时的 project、timespan 和 filters。每个概览指标都是一个包含 current 和 previous 值的对象。runsOverTime 是一个包含 granularity 和 buckets 数组的对象,该数组记录每个周期,包括表格中省略的空周期。workflows 中的每一条目都带有 fileName,并紧挨着工作流文件中的 name,而 hasMoreWorkflows 告诉你是否 --limit 中断了表格。

🌐 With --json, these parts are the overview, runsOverTime, and workflows keys, alongside project, timespan, and filters when a filter is set. Each overview metric is an object with current and previous values. runsOverTime is an object with granularity and a buckets array that keeps every period, including the empty ones the table leaves out. Each entry in workflows carries fileName next to the name from the workflow file, and hasMoreWorkflows tells you whether --limit cut the table short.

eas workflow:insights:maestro

显示与 Maestro 选项卡相同的概览和流程表。用它来找到失败或不稳定最多的流程。传入 --flow 可以深入查看某个流程,就像在仪表板中选择一个流程一样。

🌐 Shows the same overview and flows table as the Maestro tab. Use it to find the flows that fail or flake the most. Pass --flow to drill into one flow instead, the way selecting a flow in the dashboard does.

Terminal
# Last 7 days, flows with the most failures first
- eas workflow:insights:maestro

# Flakiest flows over the last 30 days
- eas workflow:insights:maestro --days 30 --sort flake-rate

# Only failed runs of flows tagged smoke
- eas workflow:insights:maestro --status FAILED --tag smoke

# The history of one flow, by its path in the repository
- eas workflow:insights:maestro --flow .maestro/login.yml --days 30

命令标志:

🌐 Command flags:

  • --status <status>:只包括具有此状态的流程运行。选项为 PASSED、FLAKY 或 FAILED 之一,其中 PASSED 表示第一次尝试就通过。对于多个状态可以重复使用这个标志。
  • --tag <tag>:只包括带有此标签的流程运行。对于多个标签请重复使用此标志。
  • --search <text>:只列出路径中包含此文本的流。它只缩小流表,所以概览仍然涵盖其他筛选条件匹配的所有流。
  • --sort <column>:按 fails(默认)、runs、flakes、pass-rate、flake-rate、p90 或 last-run 对流表进行排序。
  • --sort-direction <direction>:desc(默认)或 asc。
  • --flow <path>:显示某个流程的历史,而不是概览。路径完全按照 Flow 列走,不能与 --status、--tag、--search、--sort 或 --sort-direction 组合。

概览显示了 Maestro 的运行情况、通过率、波动流程以及平均持续时间,每项都有与上一个周期的变化。波动运行也算作通过,所以一个流程可以显示较高的通过率,同时波动率不为零。在概览下方,随时间变化的运行使用与 eas workflow:insights 相同的分类。流程表列出了每个流程的运行次数、通过率、失败次数和波动率。表格还显示了 P90(第 90 百分位)持续时间、最后一次运行以及那次运行的状态。使用 --json,这些是 totals、runsOverTime 和 flows 键。totalFlows 和 hasMoreFlows 告诉你有多少流程匹配,以及 --limit 是否截断了表格。

🌐 The overview shows Maestro runs, pass rate, flaky flows, and average duration, each with the change from the previous period. A flaky run counts as a pass, so a flow can show a high pass rate together with a non-zero flake rate. Below the overview, runs over time uses the same buckets as eas workflow:insights. The flows table lists each flow with its runs, pass rate, fails, and flake rate. The table also shows P90 (90th percentile) duration, last run, and the status of that last run. With --json, these are the totals, runsOverTime, and flows keys. totalFlows and hasMoreFlows tell you how many flows matched and whether --limit cut the table short.

使用 --flow 时,输出会先显示该流程的运行次数、通过率、不稳定运行次数和 P90 持续时间。然后列出该流程随时间的运行情况、五种最常见的错误模式以及最近的运行情况。--limit 适用于最近的运行。使用 --json 时,查看 totals、errorPatterns 和 recentRuns 键,以及 totalRecentRuns 和 hasMoreRecentRuns。

🌐 With --flow, the output starts with that flow's runs, pass rate, flaky runs, and P90 duration. It then lists the flow's runs over time, its five most common error patterns, and its most recent runs. --limit applies to the recent runs. With --json, look for the totals, errorPatterns, and recentRuns keys, plus totalRecentRuns and hasMoreRecentRuns.

表格会把持续时间打印为 450ms 或 12.3s,没有运行报告的则为 n/a。--json 输出以毫秒为单位报告持续时间,并且会省略值为 null 的键。可以用备用值读取这些,比如 jq '.flows[] | {path, p90: (.p90DurationMs // "n/a")}'。

🌐 Tables print durations as 450ms or 12.3s, and n/a where no run reported one. The --json output reports durations in milliseconds and leaves out any key whose value is null. Read those with a fallback, such as jq '.flows[] | {path, p90: (.p90DurationMs // "n/a")}'.

常见任务

🌐 Common tasks

查看你的工作流程在主分支上的情况:

Terminal
- eas workflow:insights --git-ref main --days 30

先找出需要修复的 Maestro 流程:

Terminal
# Flows with the most failures over the last 30 days
- eas workflow:insights:maestro --days 30

# Then look at the error patterns of the worst one
- eas workflow:insights:maestro --flow <flow-path> --days 30

从 CI 构建自动化报告:

  1. 在拥有该项目的账户上创建一个机器人用户。
  2. 在你的 CI 任务中将它的访问令牌设置为 EXPO_TOKEN 环境变量。
  3. 通过 ID 查询项目,并从 JSON 输出中读取你需要的数字。

非 JSON 消息会输出到标准错误,所以你可以直接把输出传给像 jq 这样的工具。当一个命令执行失败时,标准输出保持为空,消息会输出到标准错误。退出码是非零的,所以在解析之前先检查一下:

🌐 Non-JSON messages go to stderr, so you can pipe the output straight into a tool such as jq. When a command fails, stdout stays empty and the message goes to stderr. The exit code is non-zero, so check it before parsing:

Terminal
# Success rate of all workflows over the last 7 days, as a number
- eas workflow:insights --project-id <project-id> --json | jq '.overview.successRatePercent.current'

# Pass rate and P90 duration per flow over the last 7 days, up to 100 flows
- eas workflow:insights:maestro --project-id <project-id> --limit 100 --json | jq '.flows[] | {path, passRatePercent, p90DurationMs}'