|
1 | 1 | # CI |
2 | 2 |
|
3 | | -Read this when you need to wait for pull request checks or verify a specific |
4 | | -workflow attempt after merge. |
| 3 | +Read this when you need to wait for pull request checks. |
5 | 4 |
|
6 | 5 | ## Applies to |
7 | 6 |
|
8 | 7 | Sidekick responses and the REPL entries they submit. |
9 | 8 |
|
10 | 9 | ## Instructions |
11 | 10 |
|
12 | | -- Read `<Guide.Entries />` first. Use the task's canonical pull request URL and |
13 | | - choose a time budget. Put the entire wait in one ordinary entry. |
14 | | -- `<PullRequest.Checks url=… watch timeoutSeconds={…} as="checkResult" />` |
15 | | - watches every reported check run and commit status for the head it first |
16 | | - observes, and binds `{ outcome, reason?, headSha, checks }`. It waits for |
17 | | - every reported check to settle, even after one has failed. |
18 | | -- Successful, skipped and neutral results pass. Failure, error, cancellation, |
19 | | - timeout and action-required results fail. A pull request that reports no |
20 | | - checks yet keeps the watch waiting. |
21 | | -- Submit the entry, read the receipt, and then read that exact entry's output, |
22 | | - for example with `<REPL.Entry.Output entry={2} />` when the receipt names |
23 | | - entry 2. Read further pages as needed. A completed entry can report any CI |
24 | | - outcome; use the watch result from that entry for the next action. |
25 | | -- Decide from `outcome`, never from a filtered array: a list of failed records |
26 | | - can be empty while CI is still pending. |
27 | | - - `success`: report that the watched checks passed for `headSha`. |
28 | | - - `failure`: inspect the failed records and their links. The query shows |
29 | | - failed rows across the full collection. |
30 | | - - `incomplete` with `reason: "timeout"`: report what was still pending and |
31 | | - decide whether to wait again. |
32 | | - - `incomplete` with `reason: "head-changed"`: report the watched `headSha` |
33 | | - and confirm the intended revision before starting another watch. |
34 | | - - `incomplete` with `reason: "read-error"`: report that the outcome could not |
35 | | - be established. |
36 | | -- While the entry runs, the person can read its **Output · live** for the short |
37 | | - head and the passed, failed and pending counts. Draft **Stop** ends the watch |
38 | | - and binds nothing. Sidekick **Stop** ends the Send and leaves an admitted |
39 | | - entry running; read that exact entry when you resume. |
40 | | -- Keep compact derived values in root bindings and put large reports or |
41 | | - separately collected progress histories in files. |
42 | | - |
43 | | -## Example |
44 | | - |
45 | | -This response submits an entry that renders the result and uses `Query` to show |
46 | | -failed rows only once the outcome is known to be `failure`. |
47 | | - |
48 | | -`````xmd |
49 | | -<Let as="code" select="code"> |
50 | | -````xmd |
51 | | -<PullRequest.Checks url="https://github.com/taras/executable.md/pull/123" |
52 | | - watch timeoutSeconds={600} as="checkResult" /> |
53 | | -
|
54 | | -<Output> |
55 | | -<Json value={checkResult} /> |
56 | | -
|
57 | | -<If condition={checkResult.outcome === "failure"}> |
58 | | -### Failed check records |
59 | | -
|
60 | | -<Query value={checkResult.checks} |
61 | | - yq='[.[] | select((.kind == "check-run" and .status == "completed" and (.conclusion == "failure" or .conclusion == "cancelled" or .conclusion == "timed_out" or .conclusion == "action_required")) or (.kind == "commit-status" and (.state == "failure" or .state == "error")))]' /> |
62 | | -</If> |
63 | | -</Output> |
64 | | -```` |
65 | | -</Let> |
66 | | -<REPL.EntryInput>{code}</REPL.EntryInput> |
67 | | -<REPL.Submit /> |
68 | | -````` |
69 | | - |
70 | | -If the 600-second budget expires while a check is pending, the entry renders: |
71 | | - |
72 | | -```json |
73 | | -{ |
74 | | - "outcome": "incomplete", |
75 | | - "reason": "timeout", |
76 | | - "headSha": "0123456789abcdef0123456789abcdef01234567", |
77 | | - "checks": [ |
78 | | - { |
79 | | - "kind": "commit-status", |
80 | | - "id": "42", |
81 | | - "headSha": "0123456789abcdef0123456789abcdef01234567", |
82 | | - "name": "green", |
83 | | - "state": "pending", |
84 | | - "description": "CI is running", |
85 | | - "url": "https://github.com/taras/executable.md/actions/runs/45030887260", |
86 | | - "createdAt": "2026-11-23T12:00:00Z", |
87 | | - "updatedAt": "2026-11-23T12:00:00Z" |
88 | | - } |
89 | | - ] |
90 | | -} |
91 | | -``` |
92 | | - |
93 | | -## Verify a workflow attempt after merge |
94 | | - |
95 | | -`<PullRequest.Checks>` watches a pull request's head, not a workflow run. For a |
96 | | -specific attempt after merge, use `gh` with the repository, workflow, intended |
97 | | -merge SHA, run ID and attempt number. Identify the run by workflow and merge |
98 | | -SHA, then inspect the requested attempt: |
99 | | - |
100 | | -```sh |
101 | | -gh run view 45030887260 --repo taras/executable.md --attempt 1 |
102 | | -gh api repos/taras/executable.md/actions/runs/45030887260/attempts/1 --jq '{runId: .id, attempt: .run_attempt, headSha: .head_sha, status, conclusion}' |
103 | | -``` |
104 | | - |
105 | | -Replace the example identifiers with the task's own. Compare the returned head |
106 | | -SHA with the intended merge SHA before reporting the result. If the attempt is |
107 | | -still active, repeat the same attempt-scoped read within the task's time budget. |
108 | | -Use `status` and `conclusion` to report how that attempt ended. A retry has a |
109 | | -different attempt number; keep the original attempt in the command when the |
110 | | -task asks about its outcome. |
111 | | - |
112 | | -## Common mistake |
113 | | - |
114 | | -Treating an empty failed-records query as success. Query only selects from the |
115 | | -records the watch returned; it says nothing about whether the watch settled. |
116 | | -Branch on `outcome` first. |
117 | | - |
118 | | -## Read next |
119 | | - |
120 | | -`<Guide.Lifetimes />` for cancellation and `<Guide.Bindings />` for published |
121 | | -values. |
| 11 | +Use the pull request URL and choose a time budget. Look up `<PullRequest.Checks>` with `<REPL.Syntax names={["PullRequest.Checks"]} />`. Submit the watch in one entry and read its outcome before filtering for failures. An empty list can mean checks are still pending. |
0 commit comments