@futurelastic/colab-handbook 1.12.0-rc.9 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/README.vi.md +1 -0
- package/audit/audit.mjs +4 -2
- package/package.json +1 -1
- package/templates/README.md +19 -0
- package/templates/ci-laravel.yml +82 -0
- package/templates/ci-node.yml +79 -0
- package/templates/ci-python.yml +79 -0
- package/templates/release-auto.yml +23 -3
- package/tools/colab +100 -12
- package/tools/lib/conflict-markers.js +47 -0
- package/tools/lib/hermetic.js +72 -6
- package/tools/lib/install-check.js +20 -1
- package/tools/lib/notify-endpoint.js +170 -0
- package/tools/lib/release-finalize.js +51 -11
- package/tools/lib/ship-batch.js +11 -1
package/README.md
CHANGED
|
@@ -187,6 +187,7 @@ you want.
|
|
|
187
187
|
| `--hooks` | Point this clone's git at `.githooks/`, whose `pre-commit` runs every check in `pre-commit.d/` — a gitleaks secret scan, and an identity scan that needs a vocabulary you supply by path and keep outside every repo (see [`templates/README.md`](templates/README.md)). `core.hooksPath` lives in `.git/config`, so it is per-clone, per-machine, and never travels with the repo. |
|
|
188
188
|
| `--fleet` | Seed `~/.colab/repos.txt` from `audit/repos.txt`, only if it is absent. The seed is format notes and commented placeholders — it registers **nothing**; `colab register <path>` (step 3) is what fills it. That list stays machine-local on purpose: it names your private repos, and this repo is public. |
|
|
189
189
|
| `--all` | `--tools --hooks --fleet`. |
|
|
190
|
+
| `--notify-url <url>` | Seed `notifyUrl` in `~/.colab/config.json` with a local observer's events URL, only when the key is absent — an existing value is never overwritten. Without the flag, `--tools` seeds it from `~/.colab/notify-endpoint` when a local observer declared its URL there, and otherwise prints that `notifyUrl` is unset and which events that drops. See [`tools/README.md`](tools/README.md#notifyurl--optional-event-push-off-by-default). |
|
|
190
191
|
| `--dry` | Print what would happen, change nothing. Combines with all of the above. |
|
|
191
192
|
| `--check` | **Read-only** health report on what an earlier install left behind — see *Checking an install* below. Takes no other flag; exit 1 on any ✗ row. |
|
|
192
193
|
|
|
@@ -246,8 +247,9 @@ A frozen copy never breaks — it gets **old**, and an old complete copy answers
|
|
|
246
247
|
normally for every command it knows until something asks for one added after it
|
|
247
248
|
was frozen. `--check` is the report nothing else gives: whether the frozen copy is
|
|
248
249
|
behind the latest release, **which commands it does not dispatch**, whether the
|
|
249
|
-
state file exists, whether anything is registered,
|
|
250
|
-
hooklets can actually run (gitleaks, and the identity vocabulary)
|
|
250
|
+
state file exists, whether anything is registered, whether both pre-commit
|
|
251
|
+
hooklets can actually run (gitleaks, and the identity vocabulary), and whether
|
|
252
|
+
`notifyUrl` is unset while a local observer declared an endpoint. ✗ means
|
|
251
253
|
something installed here is stale or unusable; ⚠ means something was never set
|
|
252
254
|
up, which may be deliberate. It never refreshes anything — re-freezing stays your
|
|
253
255
|
call: `./install.sh --tools`.
|
package/README.vi.md
CHANGED
|
@@ -185,6 +185,7 @@ nếu bạn thật sự chỉ cần bấy nhiêu.
|
|
|
185
185
|
| `--hooks` | Trỏ git của clone này vào `.githooks/`, ở đó `pre-commit` chạy lần lượt mọi check trong `pre-commit.d/` — quét secret bằng gitleaks, và quét danh tính (identity) vốn cần một danh sách từ khoá do bạn cấp bằng đường dẫn và giữ NGOÀI mọi repo (xem [`templates/README.md`](templates/README.md)). `core.hooksPath` nằm trong `.git/config` nên là cấu hình per-clone, per-máy, không đi theo repo. |
|
|
186
186
|
| `--fleet` | Tạo `~/.colab/repos.txt` từ `audit/repos.txt`, chỉ khi file chưa tồn tại. Danh sách đó cố tình nằm ngoài repo: nó ghi tên các repo private của bạn, còn repo này thì public. |
|
|
187
187
|
| `--all` | `--tools --hooks --fleet`. |
|
|
188
|
+
| `--notify-url <url>` | Ghi `notifyUrl` vào `~/.colab/config.json` bằng URL nhận event của một observer chạy trên máy, chỉ khi khoá đó chưa có — giá trị đang có không bao giờ bị ghi đè. Không truyền flag thì `--tools` lấy URL từ `~/.colab/notify-endpoint` nếu observer trên máy đã khai ở đó; không có thì in rõ `notifyUrl` đang trống và sẽ mất những event nào. Xem [`tools/README.md`](tools/README.md#notifyurl--optional-event-push-off-by-default). |
|
|
188
189
|
| `--dry` | In ra sẽ làm gì, không thay đổi gì. Ghép được với mọi flag trên. |
|
|
189
190
|
|
|
190
191
|
**Service luôn-bật phải gọi `~/.colab/bin/colab`.** Bản CLI symlink chạy theo
|
package/audit/audit.mjs
CHANGED
|
@@ -1270,12 +1270,14 @@ function auditRepo(target, ctx) {
|
|
|
1270
1270
|
// ---- ship-batch (#373) ------------------------------------------------------
|
|
1271
1271
|
// Batch landing's opt-in: an integer 1–3 (tools/lib/ship-batch.js parseShipBatch — the one reading
|
|
1272
1272
|
// `colab ship --batch` uses, so the two cannot disagree). A malformed value makes ship fail closed
|
|
1273
|
-
// to serial, which is safe but silent, so it fails here
|
|
1273
|
+
// to serial, which is safe but silent, so it fails here — and, since this audit is run by hand, in
|
|
1274
|
+
// the CI templates' descriptor check too (#416, held to this same parser by
|
|
1275
|
+
// tools/lib/ci-template-descriptor-check.test.js). Two further shapes are inert rather than
|
|
1274
1276
|
// wrong, so they warn: no workflow fires on a `ship-batch/**` push (the combined run can never
|
|
1275
1277
|
// arrive), and no `autonomy: auto-trunk` (a batch lands in one unattended push, which needs it).
|
|
1276
1278
|
if ("ship-batch" in (cfg || {}) && cfg["ship-batch"] !== null) {
|
|
1277
1279
|
const sbCfg = shipBatch.parseShipBatch(cfg);
|
|
1278
|
-
if (!sbCfg.valid) fail(sbCfg.reason);
|
|
1280
|
+
if (!sbCfg.valid) fail(`${sbCfg.reason} — the cap is deliberate, see project.schema.md, ship-batch`);
|
|
1279
1281
|
else if (sbCfg.n > 1) {
|
|
1280
1282
|
const firing = workflowsFiringOnBranchPush({ readFile: (p) => src.readFile(p), workflows, branch: shipBatch.PROBE_REF });
|
|
1281
1283
|
if (!firing.length) warn(`ship-batch: ${sbCfg.n} but no workflow in .github/workflows fires on a push to ship-batch/** — colab ship --batch will always fall back to serial; add 'ship-batch/**' to a CI workflow's push: branches:`);
|
package/package.json
CHANGED
package/templates/README.md
CHANGED
|
@@ -31,6 +31,25 @@ Starting points you **copy into your own repo**. That is the entire model.
|
|
|
31
31
|
| `docs-lint.yml` | `.github/workflows/docs-lint.yml` | Every repo that copied `docs-lint.mjs` | Advisory job — `continue-on-error: true` on the lint step, so a finding never blocks a merge until a repo deliberately removes that line. Requires `docs-lint.mjs` to already be in the repo; does not vendor it. |
|
|
32
32
|
| `branch-name.yml` | `.github/workflows/branch-name.yml` | Opt-in — any repo that wants §4's branch shape checked on every PR | One step, no dependencies: the PR's head branch against CONVENTIONS.md §4's regex, both shapes (`<type>/<slug>-<N>` and the `<login>/<machine>/` prefixed one) passing as shipped. Once the repo declares `branchPrefix: machine`, delete the `?` after the regex's first group to require the prefix. The head ref reaches the script through `env:`, never interpolated — on a public repo it is attacker-chosen. |
|
|
33
33
|
|
|
34
|
+
### The `dedupe` job — why a claimed branch's first run skips the suite (#418)
|
|
35
|
+
|
|
36
|
+
All three CI templates open with a `dedupe` job. It runs only on the push that **creates** a
|
|
37
|
+
ref, which is what a session claim does: it pushes the new branch at trunk's head. It checks
|
|
38
|
+
nothing out, needs `permissions: actions: read`, and asks whether this same workflow already
|
|
39
|
+
has a green, non-pull-request run at this exact sha. If one exists, every other job is
|
|
40
|
+
skipped and the run still concludes `success`. If not, or if the check cannot run, the suite
|
|
41
|
+
runs as before. Every later push skips the guard, so real commits always get the full suite.
|
|
42
|
+
Two things to keep in a copy:
|
|
43
|
+
|
|
44
|
+
- **The guard calls `gh`.** GitHub-hosted images have it. On a self-hosted image without
|
|
45
|
+
`gh`, the guard prints a notice and the suite runs, so nothing breaks, but nothing is saved
|
|
46
|
+
either.
|
|
47
|
+
- **Every other job needs `!cancelled()` in its `if:`.** Without it, a job inherits the
|
|
48
|
+
implicit `success()`, which reads every ancestor, `dedupe` included. A job that only needs
|
|
49
|
+
`dedupe` indirectly would then be skipped on every ordinary push. That is why the Laravel
|
|
50
|
+
`migrations` job checks `needs.build.result == 'success'` explicitly. Add the same pair of
|
|
51
|
+
conditions to any job you add.
|
|
52
|
+
|
|
34
53
|
### Migration round-trip — what the Laravel job proves, and what it cannot
|
|
35
54
|
|
|
36
55
|
`ci-laravel.yml`'s `migrations` job runs every migration **twice per engine**: once from
|
package/templates/ci-laravel.yml
CHANGED
|
@@ -104,8 +104,59 @@ env:
|
|
|
104
104
|
# jobs from different runs interleave, and trunk can wait behind branch runs.
|
|
105
105
|
# Read CONVENTIONS.md §7, "Self-hosted runners", before choosing a label.
|
|
106
106
|
jobs:
|
|
107
|
+
# Already tested at this sha? (#418) — the claim push.
|
|
108
|
+
# A session's claim pushes its branch at the moment it is cut (CONVENTIONS.md §5, the
|
|
109
|
+
# claim record), so the branch's first push sits on a sha trunk has usually already
|
|
110
|
+
# run. Without this job that push re-runs the whole suite on a tested commit (~19% of
|
|
111
|
+
# all runs, measured across five adopting repos). This job runs ONLY on a ref's first
|
|
112
|
+
# push (`github.event.created`), checks nothing out, and asks one question: does THIS
|
|
113
|
+
# workflow already have a completed, green, non-PR run at THIS exact sha? Yes → every
|
|
114
|
+
# other job is skipped and the run concludes `success` — a branch-CI `green` that is
|
|
115
|
+
# true, because the same workflow passed at the same sha. Anything else — trunk still
|
|
116
|
+
# running, red, never run, `gh` missing, the API failing — and the suite runs as
|
|
117
|
+
# before (fail-open: this job never fails the run). Every later push has
|
|
118
|
+
# `created == false`, so a real commit always gets the full suite, with no extra hop.
|
|
119
|
+
# Why not simply `if: !github.event.created` on every job: a run whose jobs are ALL
|
|
120
|
+
# skipped concludes `skipped`, which `colab ship` reads as not-green (CONVENTIONS.md
|
|
121
|
+
# §4, "Branch CI"). This job is the one that ends green.
|
|
122
|
+
dedupe:
|
|
123
|
+
name: Already tested at this sha?
|
|
124
|
+
if: github.event_name == 'push' && github.event.created
|
|
125
|
+
runs-on: ubuntu-latest # EDIT: the same label as the jobs below; it needs `gh` (GitHub-hosted images have it).
|
|
126
|
+
permissions:
|
|
127
|
+
actions: read
|
|
128
|
+
outputs:
|
|
129
|
+
tested: ${{ steps.check.outputs.tested }}
|
|
130
|
+
steps:
|
|
131
|
+
- name: Look for a green run of this workflow at this sha
|
|
132
|
+
id: check
|
|
133
|
+
env:
|
|
134
|
+
GH_TOKEN: ${{ github.token }}
|
|
135
|
+
REPO: ${{ github.repository }}
|
|
136
|
+
RUN_ID: ${{ github.run_id }}
|
|
137
|
+
SHA: ${{ github.sha }}
|
|
138
|
+
run: |
|
|
139
|
+
tested=false
|
|
140
|
+
if ! command -v gh >/dev/null 2>&1; then
|
|
141
|
+
echo "::notice::gh is not installed on this runner — running the full suite (#418)."
|
|
142
|
+
elif ! WFID="$(gh api "repos/$REPO/actions/runs/$RUN_ID" --jq .workflow_id 2>/dev/null)" || [ -z "$WFID" ]; then
|
|
143
|
+
echo "::notice::Could not read this run's workflow id — running the full suite (#418)."
|
|
144
|
+
elif ! N="$(gh api "repos/$REPO/actions/workflows/$WFID/runs?head_sha=$SHA&status=success&per_page=20" \
|
|
145
|
+
--jq "[.workflow_runs[] | select(.id != $RUN_ID and .event != \"pull_request\")] | length" 2>/dev/null)"; then
|
|
146
|
+
echo "::notice::Could not list this workflow's runs at $SHA — running the full suite (#418)."
|
|
147
|
+
elif [ "${N:-0}" -ge 1 ] 2>/dev/null; then
|
|
148
|
+
tested=true
|
|
149
|
+
echo "This workflow already passed at $SHA ($N green run(s)) — skipping the suite (#418)."
|
|
150
|
+
echo "Already tested: this workflow has a green run at \`$SHA\` — suite skipped (#418)." >> "$GITHUB_STEP_SUMMARY"
|
|
151
|
+
else
|
|
152
|
+
echo "No green run of this workflow at $SHA yet — running the full suite."
|
|
153
|
+
fi
|
|
154
|
+
echo "tested=$tested" >> "$GITHUB_OUTPUT"
|
|
155
|
+
|
|
107
156
|
gitleaks:
|
|
108
157
|
name: Secret scan (gitleaks)
|
|
158
|
+
needs: dedupe
|
|
159
|
+
if: ${{ !cancelled() && needs.dedupe.outputs.tested != 'true' }}
|
|
109
160
|
runs-on: ubuntu-latest # EDIT: self-hosted label if this repo needs one.
|
|
110
161
|
steps:
|
|
111
162
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
@@ -145,6 +196,8 @@ jobs:
|
|
|
145
196
|
|
|
146
197
|
build:
|
|
147
198
|
name: Build (Laravel + Vite)
|
|
199
|
+
needs: dedupe
|
|
200
|
+
if: ${{ !cancelled() && needs.dedupe.outputs.tested != 'true' }}
|
|
148
201
|
runs-on: ubuntu-latest # EDIT: self-hosted label if this repo needs one.
|
|
149
202
|
# Re-exported so the migrations job below resolves PHP exactly once, here.
|
|
150
203
|
outputs:
|
|
@@ -154,6 +207,31 @@ jobs:
|
|
|
154
207
|
with:
|
|
155
208
|
persist-credentials: false
|
|
156
209
|
|
|
210
|
+
# ---------------------------------------------------------------------------
|
|
211
|
+
# Descriptor check (#416). A value `colab ship` cannot use does not fail there —
|
|
212
|
+
# it fails closed to the safe default, silently. `ship-batch: 5` (the cap is 3)
|
|
213
|
+
# once turned every landing in a busy repo back to serial while this CI stayed
|
|
214
|
+
# green; only a ship dry run noticed. So the value fails HERE, where the person
|
|
215
|
+
# who changed project.yml is looking. Same rule as `colab ship` and the audit
|
|
216
|
+
# (tools/lib/ship-batch.js parseShipBatch): absent/empty/null, or 1–3. Why the
|
|
217
|
+
# cap is 3: project.schema.md, `ship-batch`.
|
|
218
|
+
# ---------------------------------------------------------------------------
|
|
219
|
+
- name: Descriptor check (.github/project.yml)
|
|
220
|
+
working-directory: ${{ github.workspace }}
|
|
221
|
+
run: |
|
|
222
|
+
[ -f .github/project.yml ] || exit 0
|
|
223
|
+
line="$(grep -E '^ship-batch[[:space:]]*:' .github/project.yml | head -1 || true)"
|
|
224
|
+
[ -n "$line" ] || exit 0
|
|
225
|
+
v="$(printf '%s\n' "$line" | sed -E -e 's/^ship-batch[[:space:]]*:[[:space:]]*//' \
|
|
226
|
+
-e 's/[[:space:]]+#.*$//' -e 's/[[:space:]]+$//' \
|
|
227
|
+
-e 's/^"(.*)"$/\1/' -e "s/^'(.*)'\$/\\1/")"
|
|
228
|
+
case "$v" in
|
|
229
|
+
''|'~'|null|1|2|3) echo "ship-batch: ${v:-absent} — ok" ;;
|
|
230
|
+
*)
|
|
231
|
+
echo "::error file=.github/project.yml::ship-batch is '$v', expected an integer 1-3 (omit for serial). colab ship ignores any other value and lands serially. Why the cap is 3: project.schema.md, ship-batch."
|
|
232
|
+
exit 1 ;;
|
|
233
|
+
esac
|
|
234
|
+
|
|
157
235
|
# ---------------------------------------------------------------------------
|
|
158
236
|
# Toolchain resolution. Precedence, highest first:
|
|
159
237
|
# PHP : 1. .github/project.yml -> php: 2. composer.json -> require.php
|
|
@@ -351,6 +429,10 @@ jobs:
|
|
|
351
429
|
migrations:
|
|
352
430
|
name: Migration round-trip (${{ matrix.engine }})
|
|
353
431
|
needs: build
|
|
432
|
+
# Explicit result check, not the implicit success(): success() reads EVERY ancestor,
|
|
433
|
+
# including `dedupe`, which is skipped on every ordinary push — so the implicit
|
|
434
|
+
# form would skip this job on exactly the runs it exists for (#418).
|
|
435
|
+
if: ${{ !cancelled() && needs.build.result == 'success' }}
|
|
354
436
|
runs-on: ubuntu-latest # EDIT: self-hosted label if this repo needs one.
|
|
355
437
|
strategy:
|
|
356
438
|
fail-fast: false
|
package/templates/ci-node.yml
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
# `php artisan wayfinder:generate` and needs PHP on the runner. Use ci-laravel.yml.
|
|
14
14
|
#
|
|
15
15
|
# What it does:
|
|
16
|
+
# 0. Fail on a .github/project.yml value colab would silently ignore (ship-batch, #416).
|
|
16
17
|
# 1. Resolve the Node version from declared sources — never a hardcoded default.
|
|
17
18
|
# 2. Secret scan with gitleaks (pinned release binary, see note at the step).
|
|
18
19
|
# 3. Install dependencies with the package manager the lockfile implies.
|
|
@@ -68,8 +69,59 @@ env:
|
|
|
68
69
|
# jobs from different runs interleave, and trunk can wait behind branch runs.
|
|
69
70
|
# Read CONVENTIONS.md §7, "Self-hosted runners", before choosing a label.
|
|
70
71
|
jobs:
|
|
72
|
+
# Already tested at this sha? (#418) — the claim push.
|
|
73
|
+
# A session's claim pushes its branch at the moment it is cut (CONVENTIONS.md §5, the
|
|
74
|
+
# claim record), so the branch's first push sits on a sha trunk has usually already
|
|
75
|
+
# run. Without this job that push re-runs the whole suite on a tested commit (~19% of
|
|
76
|
+
# all runs, measured across five adopting repos). This job runs ONLY on a ref's first
|
|
77
|
+
# push (`github.event.created`), checks nothing out, and asks one question: does THIS
|
|
78
|
+
# workflow already have a completed, green, non-PR run at THIS exact sha? Yes → every
|
|
79
|
+
# other job is skipped and the run concludes `success` — a branch-CI `green` that is
|
|
80
|
+
# true, because the same workflow passed at the same sha. Anything else — trunk still
|
|
81
|
+
# running, red, never run, `gh` missing, the API failing — and the suite runs as
|
|
82
|
+
# before (fail-open: this job never fails the run). Every later push has
|
|
83
|
+
# `created == false`, so a real commit always gets the full suite, with no extra hop.
|
|
84
|
+
# Why not simply `if: !github.event.created` on every job: a run whose jobs are ALL
|
|
85
|
+
# skipped concludes `skipped`, which `colab ship` reads as not-green (CONVENTIONS.md
|
|
86
|
+
# §4, "Branch CI"). This job is the one that ends green.
|
|
87
|
+
dedupe:
|
|
88
|
+
name: Already tested at this sha?
|
|
89
|
+
if: github.event_name == 'push' && github.event.created
|
|
90
|
+
runs-on: ubuntu-latest # EDIT: the same label as the jobs below; it needs `gh` (GitHub-hosted images have it).
|
|
91
|
+
permissions:
|
|
92
|
+
actions: read
|
|
93
|
+
outputs:
|
|
94
|
+
tested: ${{ steps.check.outputs.tested }}
|
|
95
|
+
steps:
|
|
96
|
+
- name: Look for a green run of this workflow at this sha
|
|
97
|
+
id: check
|
|
98
|
+
env:
|
|
99
|
+
GH_TOKEN: ${{ github.token }}
|
|
100
|
+
REPO: ${{ github.repository }}
|
|
101
|
+
RUN_ID: ${{ github.run_id }}
|
|
102
|
+
SHA: ${{ github.sha }}
|
|
103
|
+
run: |
|
|
104
|
+
tested=false
|
|
105
|
+
if ! command -v gh >/dev/null 2>&1; then
|
|
106
|
+
echo "::notice::gh is not installed on this runner — running the full suite (#418)."
|
|
107
|
+
elif ! WFID="$(gh api "repos/$REPO/actions/runs/$RUN_ID" --jq .workflow_id 2>/dev/null)" || [ -z "$WFID" ]; then
|
|
108
|
+
echo "::notice::Could not read this run's workflow id — running the full suite (#418)."
|
|
109
|
+
elif ! N="$(gh api "repos/$REPO/actions/workflows/$WFID/runs?head_sha=$SHA&status=success&per_page=20" \
|
|
110
|
+
--jq "[.workflow_runs[] | select(.id != $RUN_ID and .event != \"pull_request\")] | length" 2>/dev/null)"; then
|
|
111
|
+
echo "::notice::Could not list this workflow's runs at $SHA — running the full suite (#418)."
|
|
112
|
+
elif [ "${N:-0}" -ge 1 ] 2>/dev/null; then
|
|
113
|
+
tested=true
|
|
114
|
+
echo "This workflow already passed at $SHA ($N green run(s)) — skipping the suite (#418)."
|
|
115
|
+
echo "Already tested: this workflow has a green run at \`$SHA\` — suite skipped (#418)." >> "$GITHUB_STEP_SUMMARY"
|
|
116
|
+
else
|
|
117
|
+
echo "No green run of this workflow at $SHA yet — running the full suite."
|
|
118
|
+
fi
|
|
119
|
+
echo "tested=$tested" >> "$GITHUB_OUTPUT"
|
|
120
|
+
|
|
71
121
|
gitleaks:
|
|
72
122
|
name: Secret scan (gitleaks)
|
|
123
|
+
needs: dedupe
|
|
124
|
+
if: ${{ !cancelled() && needs.dedupe.outputs.tested != 'true' }}
|
|
73
125
|
runs-on: ubuntu-latest # EDIT: self-hosted label if this repo needs one.
|
|
74
126
|
steps:
|
|
75
127
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
@@ -114,6 +166,8 @@ jobs:
|
|
|
114
166
|
|
|
115
167
|
build:
|
|
116
168
|
name: Build
|
|
169
|
+
needs: dedupe
|
|
170
|
+
if: ${{ !cancelled() && needs.dedupe.outputs.tested != 'true' }}
|
|
117
171
|
# A repo can adopt this template before it has any application code at all —
|
|
118
172
|
# a fresh Tier B scaffold with decisions locked and a backlog filed, nothing
|
|
119
173
|
# else. Unguarded, every step below still runs: "Install dependencies" warns
|
|
@@ -147,6 +201,31 @@ jobs:
|
|
|
147
201
|
with:
|
|
148
202
|
persist-credentials: false
|
|
149
203
|
|
|
204
|
+
# ---------------------------------------------------------------------------
|
|
205
|
+
# Descriptor check (#416). A value `colab ship` cannot use does not fail there —
|
|
206
|
+
# it fails closed to the safe default, silently. `ship-batch: 5` (the cap is 3)
|
|
207
|
+
# once turned every landing in a busy repo back to serial while this CI stayed
|
|
208
|
+
# green; only a ship dry run noticed. So the value fails HERE, where the person
|
|
209
|
+
# who changed project.yml is looking. Same rule as `colab ship` and the audit
|
|
210
|
+
# (tools/lib/ship-batch.js parseShipBatch): absent/empty/null, or 1–3. Why the
|
|
211
|
+
# cap is 3: project.schema.md, `ship-batch`.
|
|
212
|
+
# ---------------------------------------------------------------------------
|
|
213
|
+
- name: Descriptor check (.github/project.yml)
|
|
214
|
+
working-directory: ${{ github.workspace }}
|
|
215
|
+
run: |
|
|
216
|
+
[ -f .github/project.yml ] || exit 0
|
|
217
|
+
line="$(grep -E '^ship-batch[[:space:]]*:' .github/project.yml | head -1 || true)"
|
|
218
|
+
[ -n "$line" ] || exit 0
|
|
219
|
+
v="$(printf '%s\n' "$line" | sed -E -e 's/^ship-batch[[:space:]]*:[[:space:]]*//' \
|
|
220
|
+
-e 's/[[:space:]]+#.*$//' -e 's/[[:space:]]+$//' \
|
|
221
|
+
-e 's/^"(.*)"$/\1/' -e "s/^'(.*)'\$/\\1/")"
|
|
222
|
+
case "$v" in
|
|
223
|
+
''|'~'|null|1|2|3) echo "ship-batch: ${v:-absent} — ok" ;;
|
|
224
|
+
*)
|
|
225
|
+
echo "::error file=.github/project.yml::ship-batch is '$v', expected an integer 1-3 (omit for serial). colab ship ignores any other value and lands serially. Why the cap is 3: project.schema.md, ship-batch."
|
|
226
|
+
exit 1 ;;
|
|
227
|
+
esac
|
|
228
|
+
|
|
150
229
|
# ---------------------------------------------------------------------------
|
|
151
230
|
# Toolchain resolution. Precedence, highest first:
|
|
152
231
|
# 1. .github/project.yml -> node: <version>
|
package/templates/ci-python.yml
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
# NOT for: Laravel + Inertia fullstack apps — use ci-laravel.yml.
|
|
28
28
|
#
|
|
29
29
|
# What it does:
|
|
30
|
+
# 0. Fail on a .github/project.yml value colab would silently ignore (ship-batch, #416).
|
|
30
31
|
# 1. Resolve the Python version from declared sources — never a hardcoded default.
|
|
31
32
|
# 2. Secret scan with gitleaks (pinned release binary, see note at the step).
|
|
32
33
|
# 3. Install dependencies from whichever manifest the repo actually has.
|
|
@@ -82,8 +83,59 @@ env:
|
|
|
82
83
|
# jobs from different runs interleave, and trunk can wait behind branch runs.
|
|
83
84
|
# Read CONVENTIONS.md §7, "Self-hosted runners", before choosing a label.
|
|
84
85
|
jobs:
|
|
86
|
+
# Already tested at this sha? (#418) — the claim push.
|
|
87
|
+
# A session's claim pushes its branch at the moment it is cut (CONVENTIONS.md §5, the
|
|
88
|
+
# claim record), so the branch's first push sits on a sha trunk has usually already
|
|
89
|
+
# run. Without this job that push re-runs the whole suite on a tested commit (~19% of
|
|
90
|
+
# all runs, measured across five adopting repos). This job runs ONLY on a ref's first
|
|
91
|
+
# push (`github.event.created`), checks nothing out, and asks one question: does THIS
|
|
92
|
+
# workflow already have a completed, green, non-PR run at THIS exact sha? Yes → every
|
|
93
|
+
# other job is skipped and the run concludes `success` — a branch-CI `green` that is
|
|
94
|
+
# true, because the same workflow passed at the same sha. Anything else — trunk still
|
|
95
|
+
# running, red, never run, `gh` missing, the API failing — and the suite runs as
|
|
96
|
+
# before (fail-open: this job never fails the run). Every later push has
|
|
97
|
+
# `created == false`, so a real commit always gets the full suite, with no extra hop.
|
|
98
|
+
# Why not simply `if: !github.event.created` on every job: a run whose jobs are ALL
|
|
99
|
+
# skipped concludes `skipped`, which `colab ship` reads as not-green (CONVENTIONS.md
|
|
100
|
+
# §4, "Branch CI"). This job is the one that ends green.
|
|
101
|
+
dedupe:
|
|
102
|
+
name: Already tested at this sha?
|
|
103
|
+
if: github.event_name == 'push' && github.event.created
|
|
104
|
+
runs-on: ubuntu-latest # EDIT: the same label as the jobs below; it needs `gh` (GitHub-hosted images have it).
|
|
105
|
+
permissions:
|
|
106
|
+
actions: read
|
|
107
|
+
outputs:
|
|
108
|
+
tested: ${{ steps.check.outputs.tested }}
|
|
109
|
+
steps:
|
|
110
|
+
- name: Look for a green run of this workflow at this sha
|
|
111
|
+
id: check
|
|
112
|
+
env:
|
|
113
|
+
GH_TOKEN: ${{ github.token }}
|
|
114
|
+
REPO: ${{ github.repository }}
|
|
115
|
+
RUN_ID: ${{ github.run_id }}
|
|
116
|
+
SHA: ${{ github.sha }}
|
|
117
|
+
run: |
|
|
118
|
+
tested=false
|
|
119
|
+
if ! command -v gh >/dev/null 2>&1; then
|
|
120
|
+
echo "::notice::gh is not installed on this runner — running the full suite (#418)."
|
|
121
|
+
elif ! WFID="$(gh api "repos/$REPO/actions/runs/$RUN_ID" --jq .workflow_id 2>/dev/null)" || [ -z "$WFID" ]; then
|
|
122
|
+
echo "::notice::Could not read this run's workflow id — running the full suite (#418)."
|
|
123
|
+
elif ! N="$(gh api "repos/$REPO/actions/workflows/$WFID/runs?head_sha=$SHA&status=success&per_page=20" \
|
|
124
|
+
--jq "[.workflow_runs[] | select(.id != $RUN_ID and .event != \"pull_request\")] | length" 2>/dev/null)"; then
|
|
125
|
+
echo "::notice::Could not list this workflow's runs at $SHA — running the full suite (#418)."
|
|
126
|
+
elif [ "${N:-0}" -ge 1 ] 2>/dev/null; then
|
|
127
|
+
tested=true
|
|
128
|
+
echo "This workflow already passed at $SHA ($N green run(s)) — skipping the suite (#418)."
|
|
129
|
+
echo "Already tested: this workflow has a green run at \`$SHA\` — suite skipped (#418)." >> "$GITHUB_STEP_SUMMARY"
|
|
130
|
+
else
|
|
131
|
+
echo "No green run of this workflow at $SHA yet — running the full suite."
|
|
132
|
+
fi
|
|
133
|
+
echo "tested=$tested" >> "$GITHUB_OUTPUT"
|
|
134
|
+
|
|
85
135
|
gitleaks:
|
|
86
136
|
name: Secret scan (gitleaks)
|
|
137
|
+
needs: dedupe
|
|
138
|
+
if: ${{ !cancelled() && needs.dedupe.outputs.tested != 'true' }}
|
|
87
139
|
runs-on: ubuntu-latest # EDIT: self-hosted label if this repo needs one.
|
|
88
140
|
steps:
|
|
89
141
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
@@ -128,6 +180,8 @@ jobs:
|
|
|
128
180
|
|
|
129
181
|
build:
|
|
130
182
|
name: Build (Python)
|
|
183
|
+
needs: dedupe
|
|
184
|
+
if: ${{ !cancelled() && needs.dedupe.outputs.tested != 'true' }}
|
|
131
185
|
runs-on: ubuntu-latest # EDIT: self-hosted label if this repo needs one.
|
|
132
186
|
defaults:
|
|
133
187
|
run:
|
|
@@ -138,6 +192,31 @@ jobs:
|
|
|
138
192
|
with:
|
|
139
193
|
persist-credentials: false
|
|
140
194
|
|
|
195
|
+
# ---------------------------------------------------------------------------
|
|
196
|
+
# Descriptor check (#416). A value `colab ship` cannot use does not fail there —
|
|
197
|
+
# it fails closed to the safe default, silently. `ship-batch: 5` (the cap is 3)
|
|
198
|
+
# once turned every landing in a busy repo back to serial while this CI stayed
|
|
199
|
+
# green; only a ship dry run noticed. So the value fails HERE, where the person
|
|
200
|
+
# who changed project.yml is looking. Same rule as `colab ship` and the audit
|
|
201
|
+
# (tools/lib/ship-batch.js parseShipBatch): absent/empty/null, or 1–3. Why the
|
|
202
|
+
# cap is 3: project.schema.md, `ship-batch`.
|
|
203
|
+
# ---------------------------------------------------------------------------
|
|
204
|
+
- name: Descriptor check (.github/project.yml)
|
|
205
|
+
working-directory: ${{ github.workspace }}
|
|
206
|
+
run: |
|
|
207
|
+
[ -f .github/project.yml ] || exit 0
|
|
208
|
+
line="$(grep -E '^ship-batch[[:space:]]*:' .github/project.yml | head -1 || true)"
|
|
209
|
+
[ -n "$line" ] || exit 0
|
|
210
|
+
v="$(printf '%s\n' "$line" | sed -E -e 's/^ship-batch[[:space:]]*:[[:space:]]*//' \
|
|
211
|
+
-e 's/[[:space:]]+#.*$//' -e 's/[[:space:]]+$//' \
|
|
212
|
+
-e 's/^"(.*)"$/\1/' -e "s/^'(.*)'\$/\\1/")"
|
|
213
|
+
case "$v" in
|
|
214
|
+
''|'~'|null|1|2|3) echo "ship-batch: ${v:-absent} — ok" ;;
|
|
215
|
+
*)
|
|
216
|
+
echo "::error file=.github/project.yml::ship-batch is '$v', expected an integer 1-3 (omit for serial). colab ship ignores any other value and lands serially. Why the cap is 3: project.schema.md, ship-batch."
|
|
217
|
+
exit 1 ;;
|
|
218
|
+
esac
|
|
219
|
+
|
|
141
220
|
# ---------------------------------------------------------------------------
|
|
142
221
|
# Toolchain resolution. Precedence, highest first:
|
|
143
222
|
# 1. .github/project.yml -> python: <version>
|
|
@@ -137,8 +137,11 @@ env:
|
|
|
137
137
|
jobs:
|
|
138
138
|
release:
|
|
139
139
|
name: Cut, finalize, publish
|
|
140
|
-
#
|
|
141
|
-
|
|
140
|
+
# No job-level `if:` here, on purpose (#435): a red CI run is gated in the first step below,
|
|
141
|
+
# so this run concludes success. A job-level `if:` would skip every job, GitHub would record
|
|
142
|
+
# the whole run as `skipped` at that main sha, and `colab ship` reads any finished run that is
|
|
143
|
+
# neither success nor cancelled as "not green". Re-run CI green on that sha and the skipped
|
|
144
|
+
# Release (auto) row would still sit beside it, refusing every ship until main moves.
|
|
142
145
|
runs-on: ubuntu-latest # EDIT: self-hosted label if this repo needs one.
|
|
143
146
|
permissions:
|
|
144
147
|
contents: write # push the tags (and, with promotion: main-loop, the promotion), publish the GitHub Release
|
|
@@ -165,6 +168,23 @@ jobs:
|
|
|
165
168
|
# checkout's origin. The token is this job's, scoped by `permissions:` above.
|
|
166
169
|
persist-credentials: true
|
|
167
170
|
|
|
171
|
+
# A red CI run on main is not a candidate. Gated here rather than by a job-level `if:` so
|
|
172
|
+
# this run concludes success, never `skipped` (#435; the comment on the job above).
|
|
173
|
+
- name: Gate on the triggering CI run
|
|
174
|
+
id: gate
|
|
175
|
+
env:
|
|
176
|
+
EVENT: ${{ github.event_name }}
|
|
177
|
+
CONCLUSION: ${{ github.event.workflow_run.conclusion }}
|
|
178
|
+
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
|
|
179
|
+
run: |
|
|
180
|
+
set -euo pipefail
|
|
181
|
+
if [ "$EVENT" = "workflow_run" ] && [ "$CONCLUSION" != "success" ]; then
|
|
182
|
+
echo "cut=false" >> "$GITHUB_OUTPUT"
|
|
183
|
+
echo "CI concluded \`$CONCLUSION\` at $HEAD_SHA — nothing to cut." | tee -a "$GITHUB_STEP_SUMMARY"
|
|
184
|
+
else
|
|
185
|
+
echo "cut=true" >> "$GITHUB_OUTPUT"
|
|
186
|
+
fi
|
|
187
|
+
|
|
168
188
|
- name: Fetch the colab CLI
|
|
169
189
|
run: |
|
|
170
190
|
set -euo pipefail
|
|
@@ -219,7 +239,7 @@ jobs:
|
|
|
219
239
|
# right after this run promoted: that head has no CI yet — the dispatched run cuts it.
|
|
220
240
|
- name: Cut a candidate (colab release cut --auto)
|
|
221
241
|
id: cut
|
|
222
|
-
if: (github.event_name == 'workflow_run' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && steps.promote.outputs.promoted != 'true'
|
|
242
|
+
if: steps.gate.outputs.cut == 'true' && (github.event_name == 'workflow_run' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && steps.promote.outputs.promoted != 'true'
|
|
223
243
|
run: |
|
|
224
244
|
set -uo pipefail
|
|
225
245
|
OUT="$RUNNER_TEMP/cut.json"
|
package/tools/colab
CHANGED
|
@@ -22,6 +22,7 @@ const squash = require('./lib/squash');
|
|
|
22
22
|
const procs = require('./lib/procs');
|
|
23
23
|
const landed = require('./lib/landed');
|
|
24
24
|
const notify = require('./lib/notify');
|
|
25
|
+
const notifyEndpoint = require('./lib/notify-endpoint'); // #414
|
|
25
26
|
const journal = require('./lib/journal');
|
|
26
27
|
const labels = require('./lib/labels');
|
|
27
28
|
const records = require('./lib/records');
|
|
@@ -56,6 +57,7 @@ const claimComments = require('./lib/claim-comments');
|
|
|
56
57
|
const machine = require('./lib/machine');
|
|
57
58
|
const targetSync = require('./lib/ship-target-sync');
|
|
58
59
|
const shipBatch = require('./lib/ship-batch');
|
|
60
|
+
const conflictMarkers = require('./lib/conflict-markers');
|
|
59
61
|
const docsOnly = require('./lib/docs-only');
|
|
60
62
|
const cureDiff = require('./lib/cure-diff');
|
|
61
63
|
const codeowners = require('./lib/codeowners');
|
|
@@ -1651,7 +1653,8 @@ Conditions (--json checks[].condition; required:false means reported, not blocki
|
|
|
1651
1653
|
regressions blocked_by edges on the tracking issue: open -> refused; closed after the period
|
|
1652
1654
|
began -> needs-new-candidate. Record one with: colab blocked <tracking> --by <issue>
|
|
1653
1655
|
test-period from max(candidate tag date, tracking issue creation), release: test-period long
|
|
1654
|
-
trunk-green every
|
|
1656
|
+
trunk-green every run since the period began on main — and on project.yml's trunk: when that is
|
|
1657
|
+
another branch (trunk: dev, #437) — of the workflows that ran at the candidate,
|
|
1655
1658
|
none red — required only where the final is automatic
|
|
1656
1659
|
|
|
1657
1660
|
manifest-version on-trunk outranks-final — #424's pre-tag checks, required before any final:
|
|
@@ -1721,6 +1724,7 @@ function cmdReleaseFinalize(argv) {
|
|
|
1721
1724
|
if (!isGhUsable(repoAbs)) throw new UserError(`gh not usable (${ghUnusableWhy(repoAbs)}) — the tracking issue, runs and regression edges live on GitHub`);
|
|
1722
1725
|
const doc = projectDoc(repoAbs);
|
|
1723
1726
|
const policy = releasePolicy.evaluateRelease(doc);
|
|
1727
|
+
const windowBranches = releaseFinalize.windowBranches(doc && doc.trunk); // #437
|
|
1724
1728
|
const now = new Date().toISOString();
|
|
1725
1729
|
const remote = git.remoteFor(repoAbs); // #301
|
|
1726
1730
|
|
|
@@ -1800,10 +1804,13 @@ function cmdReleaseFinalize(argv) {
|
|
|
1800
1804
|
});
|
|
1801
1805
|
const suiteWorkflows = [...new Set((rows || []).map((r) => r.workflowName || '(unnamed workflow)'))];
|
|
1802
1806
|
const period = releaseFinalize.periodVerdict({ cutAt: cand.cutAt, trackingCreatedAt: tracking && tracking.createdAt, testPeriodDays: policy.effective.testPeriodDays, now });
|
|
1803
|
-
|
|
1804
|
-
const since =
|
|
1807
|
+
// #437: the window is main plus project.yml's trunk: when that is another branch (trunk: dev).
|
|
1808
|
+
const since = releaseFinalize.mergeWindowRuns(windowBranches.map((branch) => {
|
|
1809
|
+
const raw = git.ghRunsSince(repoAbs, branch, period.start.slice(0, 10));
|
|
1810
|
+
return { branch, read: raw ? { ...raw, runs: releaseCut.withoutOwnWorkflow(raw.runs) } : null }; // #425
|
|
1811
|
+
}));
|
|
1805
1812
|
const trunk = releaseFinalize.trunkGreenVerdict(since ? since.runs : null, {
|
|
1806
|
-
periodStart: period.start, periodEnd: walk ? period.endsAt : null, suiteWorkflows, truncated: !!(since && since.truncated),
|
|
1813
|
+
periodStart: period.start, periodEnd: walk ? period.endsAt : null, suiteWorkflows, truncated: !!(since && since.truncated), branches: windowBranches,
|
|
1807
1814
|
});
|
|
1808
1815
|
const regressions = releaseFinalize.regressionVerdict(tracking && tracking.number ? readRegressionEdges(repoAbs, tracking.number) : [], { periodStart: period.start });
|
|
1809
1816
|
const { manifests, ancestry } = measurePreTag(repoAbs, cand.sha, `${remote}/main`); // #424
|
|
@@ -2391,7 +2398,7 @@ function cmdGateRecorded(argv) {
|
|
|
2391
2398
|
// `live-env:`.
|
|
2392
2399
|
// ---------------------------------------------------------------------------
|
|
2393
2400
|
|
|
2394
|
-
const HELP_GATE_HERMETIC = `colab gate-hermetic [--net auto|on] [--keep VAR,...] [--json] [--verbose] [--repo <path>] -- <test command...>
|
|
2401
|
+
const HELP_GATE_HERMETIC = `colab gate-hermetic [--net auto|on] [--keep VAR,...] [--no-pin] [--json] [--verbose] [--repo <path>] -- <test command...>
|
|
2395
2402
|
|
|
2396
2403
|
Runs the repo's TEST STEP twice and gives one verdict (#403, code-wrap A3):
|
|
2397
2404
|
|
|
@@ -2401,7 +2408,11 @@ Runs the repo's TEST STEP twice and gives one verdict (#403, code-wrap A3):
|
|
|
2401
2408
|
daemon/fleet runtime unset (*_URL *_HOST *_PORT *_TOKEN *_KEY *_SECRET *_SOCK
|
|
2402
2409
|
COLAB_* CLAUDE* GH_* …); network off where the platform allows it —
|
|
2403
2410
|
macOS sandbox-exec, Linux unshare --net (loopback stays up in both) — and the
|
|
2404
|
-
line saying which is always printed.
|
|
2411
|
+
line saying which is always printed. Toolchain-manager homes you have NOT set
|
|
2412
|
+
(RUSTUP_HOME CARGO_HOME PYENV_ROOT RBENV_ROOT ASDF_DATA_DIR NVM_DIR VOLTA_HOME
|
|
2413
|
+
MISE_DATA_DIR GOPATH) are pinned to their real directory first, when it exists,
|
|
2414
|
+
so a rustup/pyenv/asdf proxy still finds the installed toolchain instead of
|
|
2415
|
+
trying to download one (#447). Every pin is printed.
|
|
2405
2416
|
|
|
2406
2417
|
Verdicts (exit 0 = may count as green, 1 = not):
|
|
2407
2418
|
green both runs passed exit 0
|
|
@@ -2418,6 +2429,8 @@ pass \`-- sh -c '…'\` for pipes or &&.
|
|
|
2418
2429
|
--net on do not cut the network (reported); default auto = best effort
|
|
2419
2430
|
--keep A,B pass these variables through to the hermetic run anyway — printed in the
|
|
2420
2431
|
verdict, so a pass-through is never silent
|
|
2432
|
+
--no-pin do not pin toolchain-manager homes: the strict run, for a suite suspected of
|
|
2433
|
+
reading a manager's own config or package cache (~/.cargo/config.toml, …)
|
|
2421
2434
|
--json one JSON object instead of the text verdict
|
|
2422
2435
|
--verbose print each run's full output (default: failing names + a short tail on red)
|
|
2423
2436
|
--repo <path> working tree to run in (default: cwd)
|
|
@@ -2433,7 +2446,7 @@ function cmdGateHermetic(argv) {
|
|
|
2433
2446
|
const cmd = dd === -1 ? [] : argv.slice(dd + 1);
|
|
2434
2447
|
const opts = parseArgs(own, {
|
|
2435
2448
|
values: { '--repo': 'repo', '--net': 'net', '--keep': 'keep' },
|
|
2436
|
-
flags: { '--json': 'json', '--verbose': 'verbose', '-h': 'help', '--help': 'help' },
|
|
2449
|
+
flags: { '--json': 'json', '--verbose': 'verbose', '--no-pin': 'noPin', '-h': 'help', '--help': 'help' },
|
|
2437
2450
|
});
|
|
2438
2451
|
if (opts.help) return print(HELP_GATE_HERMETIC);
|
|
2439
2452
|
if (opts._.length) throw new UserError(`unexpected argument "${opts._[0]}" — the test command goes after \`--\` (see --help)`);
|
|
@@ -2481,7 +2494,10 @@ function cmdGateHermetic(argv) {
|
|
|
2481
2494
|
if (normal.ok && !skip) {
|
|
2482
2495
|
homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'colab-hermetic-home-'));
|
|
2483
2496
|
try {
|
|
2484
|
-
|
|
2497
|
+
const pins = opts.noPin ? [] : hermetic.toolchainPins(process.env, (d) => {
|
|
2498
|
+
try { return fs.statSync(d).isDirectory(); } catch (_) { return false; }
|
|
2499
|
+
});
|
|
2500
|
+
envInfo = hermetic.hermeticEnv(process.env, homeDir, keep, { pins });
|
|
2485
2501
|
net = hermetic.probeNetworkIsolation({
|
|
2486
2502
|
platform: process.platform, mode: netMode,
|
|
2487
2503
|
run: (c, a) => spawnSync(c, a, { stdio: 'ignore' }),
|
|
@@ -2501,7 +2517,7 @@ function cmdGateHermetic(argv) {
|
|
|
2501
2517
|
verdict, ok: exitCode === 0, command: cmd,
|
|
2502
2518
|
liveEnv: { skip, trunkSource, value: trunkLive.value },
|
|
2503
2519
|
normal: { ok: normal.ok, exit: normal.exit },
|
|
2504
|
-
hermetic: herm ? { ok: herm.ok, exit: herm.exit, stripped: envInfo.stripped, kept: envInfo.kept, network: net.note } : null,
|
|
2520
|
+
hermetic: herm ? { ok: herm.ok, exit: herm.exit, stripped: envInfo.stripped, kept: envInfo.kept, pinned: envInfo.pinned, network: net.note } : null,
|
|
2505
2521
|
failing, notes,
|
|
2506
2522
|
}, null, 2));
|
|
2507
2523
|
return exitCode;
|
|
@@ -2515,6 +2531,8 @@ function cmdGateHermetic(argv) {
|
|
|
2515
2531
|
lines.push(`hermetic run: ${herm.ok ? 'green' : 'RED'} (exit ${herm.exit === null ? 'none' : herm.exit}${herm.signal ? `, ${herm.signal}` : ''})`);
|
|
2516
2532
|
lines.push(` HOME=<fresh empty dir>; unset ${envInfo.stripped.length} var(s)${envInfo.stripped.length ? `: ${envInfo.stripped.join(' ')}` : ''}`);
|
|
2517
2533
|
if (envInfo.kept.length) lines.push(` --keep passed through: ${envInfo.kept.join(' ')}`);
|
|
2534
|
+
if (envInfo.pinned.length) lines.push(` toolchain homes pinned to their real dirs: ${envInfo.pinned.join(' ')}`);
|
|
2535
|
+
else if (opts.noPin) lines.push(' toolchain homes: NOT pinned (--no-pin)');
|
|
2518
2536
|
lines.push(` ${net.note}`);
|
|
2519
2537
|
} else {
|
|
2520
2538
|
lines.push('hermetic run: not attempted (normal run is red)');
|
|
@@ -2534,6 +2552,13 @@ function cmdGateHermetic(argv) {
|
|
|
2534
2552
|
for (const l of hermetic.tail(out)) lines.push(` | ${l}`);
|
|
2535
2553
|
}
|
|
2536
2554
|
}
|
|
2555
|
+
if (verdict === 'live-env' && hermetic.looksLikeToolchainMiss(herm.output)) {
|
|
2556
|
+
lines.push('', 'hint: the hermetic failure looks like a toolchain manager that could not find its install',
|
|
2557
|
+
' (a proxy trying to download a toolchain with the network off) — not necessarily the tests. Its',
|
|
2558
|
+
' default homes under $HOME are pinned already, so its install lives elsewhere (or --no-pin was given):',
|
|
2559
|
+
' export the manager\'s home variable (e.g. RUSTUP_HOME, CARGO_HOME) so it passes through, and re-run.',
|
|
2560
|
+
' Name it in the distill comment (#447).');
|
|
2561
|
+
}
|
|
2537
2562
|
lines.push('', `VERDICT: ${verdict} — ${hermetic.VERDICT_TEXT[verdict]}`);
|
|
2538
2563
|
print(lines.join('\n'));
|
|
2539
2564
|
return exitCode;
|
|
@@ -4866,6 +4891,19 @@ function worktreeSubdir(config) { return config.worktreeSubdir || '.worktrees';
|
|
|
4866
4891
|
// slow-but-working. Overridable per-machine/per-repo for a legitimately slow teardown.
|
|
4867
4892
|
const TEARDOWN_TIMEOUT_MS = Number(process.env.COLAB_TEARDOWN_TIMEOUT_MS) || 5 * 60 * 1000;
|
|
4868
4893
|
|
|
4894
|
+
/**
|
|
4895
|
+
* #436: after a pre-ship hook exits 0, which of the paths it was handed still carry conflict markers
|
|
4896
|
+
* in the index — i.e. would be committed with `<<<<<<<` in them. Untrimmed git output, so the line
|
|
4897
|
+
* numbers in the message are the file's own.
|
|
4898
|
+
*/
|
|
4899
|
+
function stagedConflictMarkers(dir, paths) {
|
|
4900
|
+
const rawGit = (args, cwd) => {
|
|
4901
|
+
const r = spawnSync('git', args, { cwd, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
|
|
4902
|
+
return { ok: r.status === 0, stdout: r.stdout || '' };
|
|
4903
|
+
};
|
|
4904
|
+
return conflictMarkers.stagedMarkerPaths(rawGit, dir, paths);
|
|
4905
|
+
}
|
|
4906
|
+
|
|
4869
4907
|
function runHook(repoAbs, name, ctx) {
|
|
4870
4908
|
const hook = path.join(repoAbs, '.colab', 'hooks', name);
|
|
4871
4909
|
try {
|
|
@@ -5708,6 +5746,11 @@ claims from.
|
|
|
5708
5746
|
"contained in trunk" between releases BY CONSTRUCTION, which this heuristic would otherwise
|
|
5709
5747
|
misread as spent and advise deleting, silently breaking GitOps deploys (#63).
|
|
5710
5748
|
|
|
5749
|
+
- \`notifyUrl: unset\` is reported (read-only, never pruned, not part of the verdict) when a
|
|
5750
|
+
local observer declared its events URL in <COLAB_HOME>/notify-endpoint and notifyUrl is not
|
|
5751
|
+
set — that observer then receives no issue.merged / issue.closed / readiness.marked /
|
|
5752
|
+
gate.recorded event (#414). No declared endpoint, no line: unset is the right default there.
|
|
5753
|
+
|
|
5711
5754
|
This exists because claims made without a worktree were never auto-healed before, and a
|
|
5712
5755
|
real repo accumulated 17 stale same-day claims. Run \`colab doctor\` regularly; \`--prune\`
|
|
5713
5756
|
in a cleanup cron.
|
|
@@ -6198,6 +6241,11 @@ function cmdDoctor(argv) {
|
|
|
6198
6241
|
}
|
|
6199
6242
|
}
|
|
6200
6243
|
|
|
6244
|
+
// 10. notifyUrl against a DECLARED local observer (#414). Read-only, never pruned, never counted in
|
|
6245
|
+
// the verdict — it is configuration, not state drift. Silent on a machine with no
|
|
6246
|
+
// <COLAB_HOME>/notify-endpoint: unset is the right default where no observer runs.
|
|
6247
|
+
report.notify = notifyEndpoint.status(config, state.COLAB_DIR);
|
|
6248
|
+
|
|
6201
6249
|
if (opts.json) { print(JSON.stringify(report, null, 2)); return 0; }
|
|
6202
6250
|
|
|
6203
6251
|
const verb = opts.prune ? 'Pruned' : 'Found';
|
|
@@ -6402,6 +6450,11 @@ function cmdDoctor(argv) {
|
|
|
6402
6450
|
print(' which also stops colab handing it to a worktree. A "cwd DELETED" line above is the real');
|
|
6403
6451
|
print(' orphan and wants killing, not reserving.');
|
|
6404
6452
|
}
|
|
6453
|
+
const notifyLine = notifyEndpoint.healthLine(report.notify);
|
|
6454
|
+
if (notifyLine) {
|
|
6455
|
+
print('');
|
|
6456
|
+
print(notifyLine);
|
|
6457
|
+
}
|
|
6405
6458
|
return 0;
|
|
6406
6459
|
}
|
|
6407
6460
|
|
|
@@ -9418,8 +9471,12 @@ for is built in its place, so the survivors of a decline can batch without landi
|
|
|
9418
9471
|
A member that conflicts with the members already in is dropped to the next batch; the rest go on —
|
|
9419
9472
|
unless every conflicting path is generated (defaults + project.yml generated:): then .colab/hooks/pre-ship
|
|
9420
9473
|
regenerates them on the combined head and the member stays in (#387). No hook, or a failing one → dropped.
|
|
9421
|
-
|
|
9422
|
-
|
|
9474
|
+
A hook that exits 0 but leaves a <<<<<<< / >>>>>>> line staged in a path it was handed counts as failing (#436).
|
|
9475
|
+
Resuming a staged batch: a branch you name that the staged batch does not carry (over the cap, dropped
|
|
9476
|
+
at build, added since) is NOT landed with it — the command names both lists and says so (#415).
|
|
9477
|
+
--dry pushes, deletes, lands, comments and releases nothing on EVERY path (#415): a fresh batch is built
|
|
9478
|
+
locally and printed; a staged green batch prints what would land (members, combined run, target sha).
|
|
9479
|
+
Consumer CI must opt in: add 'ship-batch/**' to a CI workflow's push: branches:.
|
|
9423
9480
|
|
|
9424
9481
|
B3 KEEPS the branch by default. Deleting refs from a shared remote is not something this command
|
|
9425
9482
|
does unasked, however certain it is that the content landed: reporting is safe and reversible,
|
|
@@ -11828,6 +11885,14 @@ function cmdShip(argv) {
|
|
|
11828
11885
|
}
|
|
11829
11886
|
if (hasPreShip) {
|
|
11830
11887
|
const hk = runHook(repoAbs, 'pre-ship', { wtPath: branchDir, name: sess.name || sess.branch, branch: sess.branch, ports: [], trunk, base: target, issues: sess.issues });
|
|
11888
|
+
// #436: exit 0 is the hook's claim; the index is the proof. Markers left in a path it was
|
|
11889
|
+
// handed make it a failing hook, checked BEFORE the commit so nothing carrying them is pushed.
|
|
11890
|
+
const markers = hk.ran && hk.ok ? stagedConflictMarkers(branchDir, uf) : [];
|
|
11891
|
+
if (markers.length) {
|
|
11892
|
+
git.git(['merge', '--abort'], branchDir); cleanupEphemeral();
|
|
11893
|
+
process.stderr.write(`✗ B0: pre-ship hook exited 0 but left conflict markers staged in ${conflictMarkers.describe(markers)} — treated as a failing hook. Nothing pushed.\n`);
|
|
11894
|
+
return 1;
|
|
11895
|
+
}
|
|
11831
11896
|
const committed = hk.ran && hk.ok && git.git(['commit', '--no-edit'], branchDir).ok;
|
|
11832
11897
|
if (!committed) {
|
|
11833
11898
|
git.git(['merge', '--abort'], branchDir); cleanupEphemeral();
|
|
@@ -12472,7 +12537,9 @@ function cmdShipBatch(opts) {
|
|
|
12472
12537
|
const batchRefs = (lsBatch.ok ? lsBatch.stdout.split('\n') : []).map((l) => l.split('\t'))
|
|
12473
12538
|
.map(([sha, ref]) => ({ sha: (sha || '').trim(), parsed: shipBatch.parseBatchRef((ref || '').trim()) }))
|
|
12474
12539
|
.filter((x) => x.sha && x.parsed);
|
|
12540
|
+
// #415: every write on the resume path goes through here or shipBatchLand — under --dry, neither writes.
|
|
12475
12541
|
const deleteRef = (ref) => {
|
|
12542
|
+
if (opts.dry) { print(` [dry] would delete ${remote}/${ref}`); return true; }
|
|
12476
12543
|
const d = git.git(['push', remote, '--delete', ref], repoAbs);
|
|
12477
12544
|
if (!d.ok) warn(`could not delete ${remote}/${ref}: ${git.gitFailureLine(d.stderr)} — delete it by hand`);
|
|
12478
12545
|
return d.ok;
|
|
@@ -12502,6 +12569,14 @@ function cmdShipBatch(opts) {
|
|
|
12502
12569
|
const heads = inBatch.map((m) => ({ ...m, now: git.branchRefs(repoAbs, m.branch, remote).remoteSha }));
|
|
12503
12570
|
const matches = heads.length >= 2 && heads.every((m) => m.now && m.now.startsWith(m.sha));
|
|
12504
12571
|
existing = { ref: atBase.parsed.ref, base7: atBase.parsed.base7, sha: atBase.sha, members: inBatch, matches };
|
|
12572
|
+
// #415: the command line and the staged batch can name different sets. A requested branch the
|
|
12573
|
+
// staged batch does not carry (over the cap, dropped at build, or added since) does NOT ride
|
|
12574
|
+
// along — say so, naming both lists, instead of resuming as if the two were the same.
|
|
12575
|
+
const notStaged = shipBatch.notStaged(members, inBatch);
|
|
12576
|
+
if (notStaged.length) {
|
|
12577
|
+
print(` ! ${atBase.parsed.ref} was staged with ${inBatch.map((m) => m.branch).join(', ')}; this command named ${members.join(', ')}.`);
|
|
12578
|
+
print(` NOT in the staged batch, so it does not land with it: ${notStaged.join(', ')} — ship it after this batch (next batch, or colab ship --branch <b>).`);
|
|
12579
|
+
}
|
|
12505
12580
|
}
|
|
12506
12581
|
}
|
|
12507
12582
|
const verdict = existing && existing.matches ? shipBatch.combinedVerdict(git.ghRunsForRef(repoAbs, existing.ref, existing.sha)) : null;
|
|
@@ -12528,7 +12603,7 @@ function cmdShipBatch(opts) {
|
|
|
12528
12603
|
return 4;
|
|
12529
12604
|
}
|
|
12530
12605
|
if (step.step === 'red-serial') {
|
|
12531
|
-
print(`✗ ship-batch: the combined run is red again after its one re-run (${verdict.why}) — nothing landed; ${existing.ref} deleted.`);
|
|
12606
|
+
print(`✗ ship-batch: the combined run is red again after its one re-run (${verdict.why}) — nothing landed; ${existing.ref} ${opts.dry ? 'would be deleted [DRY RUN]' : 'deleted'}.`);
|
|
12532
12607
|
deleteRef(existing.ref);
|
|
12533
12608
|
print(shipBatch.serialLine(existing.members.map((m) => m.branch)));
|
|
12534
12609
|
return 4;
|
|
@@ -12595,8 +12670,13 @@ function cmdShipBatch(opts) {
|
|
|
12595
12670
|
issues: (m.report && m.report.closeIssues) || [],
|
|
12596
12671
|
});
|
|
12597
12672
|
const left = hk.ran ? unmergedIn() : unmerged;
|
|
12673
|
+
// #436: a hook that exits 0 and `git add`s a path still holding markers clears the unmerged
|
|
12674
|
+
// state, so `left` reads empty — read the staged content itself before trusting it.
|
|
12675
|
+
const markers = hk.ran && hk.ok && !left.length ? stagedConflictMarkers(dir, unmerged) : [];
|
|
12598
12676
|
if (!hk.ran || !hk.ok || left.length) {
|
|
12599
12677
|
why = `.colab/hooks/pre-ship could not regenerate ${unmerged.join(', ')} on the combined head${left.length && hk.ok ? ` (still unmerged: ${left.join(', ')})` : ''} — next batch`;
|
|
12678
|
+
} else if (markers.length) {
|
|
12679
|
+
why = `.colab/hooks/pre-ship exited 0 but left conflict markers staged in ${conflictMarkers.describe(markers)} on the combined head — treated as a failing hook, next batch`;
|
|
12600
12680
|
} else regenerated = unmerged;
|
|
12601
12681
|
}
|
|
12602
12682
|
if (why) {
|
|
@@ -12663,6 +12743,14 @@ function cmdShipBatch(opts) {
|
|
|
12663
12743
|
*/
|
|
12664
12744
|
function shipBatchLand(repoAbs, doc, trunk, remote, base, existing, verdict, opts) {
|
|
12665
12745
|
const head = existing.sha;
|
|
12746
|
+
// #415: a staged green batch reached under --dry is a read: what WOULD land, and nothing else —
|
|
12747
|
+
// no fast-forward, no push, no ref delete, no hook, no worktree teardown, no claim, no comment.
|
|
12748
|
+
if (opts.dry) {
|
|
12749
|
+
print(`ship --batch ${shortRepo(repoAbs)} → ${trunk} @ ${shortSha(base)} [DRY RUN]`);
|
|
12750
|
+
print(`→ READY: would fast-forward ${trunk} ${shortSha(base)} → ${shortSha(head)} — ${existing.ref}, combined run ${(verdict.runIds || []).join(', ') || '(id unread)'} ${verdict.why || verdict.state}`);
|
|
12751
|
+
print(` would land ${existing.members.length} member(s), one squash each: ${existing.members.map((m) => m.branch).join(', ')}`);
|
|
12752
|
+
return 0;
|
|
12753
|
+
}
|
|
12666
12754
|
const headBranch = git.git(['rev-parse', '--abbrev-ref', 'HEAD'], repoAbs).stdout;
|
|
12667
12755
|
if (headBranch !== trunk || git.dirtyTracked(repoAbs)) {
|
|
12668
12756
|
throw new UserError(`the main checkout is not on a clean ${trunk} ("${headBranch}"${git.dirtyTracked(repoAbs) ? ', dirty' : ''}) — the batch is green and waiting; fix the checkout and run this command again`);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* #436: a pre-ship hook's exit code is a claim ("ZERO means every conflicted path was resolved"),
|
|
4
|
+
* not proof. A hook that regenerates a path's NEW layout and then `git add`s an OLD path still full
|
|
5
|
+
* of conflict markers exits 0 and stages the markers — git clears the unmerged state on `add`, so
|
|
6
|
+
* `git diff --diff-filter=U` reads clean. This reads what would actually be committed.
|
|
7
|
+
*
|
|
8
|
+
* Detection is deliberately `<<<<<<<` / `>>>>>>>` at column 0 (followed by a space or end of line).
|
|
9
|
+
* A bare `=======` line is NOT a marker on its own: it is also a legitimate Markdown setext-heading
|
|
10
|
+
* underline, and generated docs are exactly the files this check reads. Every real conflict block
|
|
11
|
+
* carries the two outer markers, so nothing is missed by not counting the middle one alone.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const MARKER = /^(<{7}|>{7})(?:[ \t]|$)/;
|
|
15
|
+
|
|
16
|
+
/** Pure: 1-based line numbers of conflict-marker lines in `text`. */
|
|
17
|
+
function markerLines(text) {
|
|
18
|
+
const out = [];
|
|
19
|
+
String(text == null ? '' : text).split('\n').forEach((line, i) => {
|
|
20
|
+
if (MARKER.test(line.replace(/\r$/, ''))) out.push(i + 1);
|
|
21
|
+
});
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Which of `paths` still hold conflict markers in the INDEX (stage 0 — what `git commit` takes) at
|
|
27
|
+
* `cwd`. `gitFn(args, cwd)` → `{ ok, stdout }`. A path absent from the index (deleted, or still
|
|
28
|
+
* unmerged at stages 1-3) is skipped here: deletion is a resolution, and an unmerged path is the
|
|
29
|
+
* caller's existing `--diff-filter=U` check. Returns `[{ path, lines }]`.
|
|
30
|
+
*/
|
|
31
|
+
function stagedMarkerPaths(gitFn, cwd, paths) {
|
|
32
|
+
const hits = [];
|
|
33
|
+
for (const p of [...new Set(paths || [])]) {
|
|
34
|
+
const r = gitFn(['show', `:0:${p}`], cwd);
|
|
35
|
+
if (!r || !r.ok) continue;
|
|
36
|
+
const lines = markerLines(r.stdout);
|
|
37
|
+
if (lines.length) hits.push({ path: p, lines });
|
|
38
|
+
}
|
|
39
|
+
return hits;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** One line naming each path and its first marker lines. */
|
|
43
|
+
function describe(hits) {
|
|
44
|
+
return (hits || []).map((h) => `${h.path}:${h.lines.slice(0, 3).join(',')}${h.lines.length > 3 ? ',…' : ''}`).join(', ');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = { markerLines, stagedMarkerPaths, describe };
|
package/tools/lib/hermetic.js
CHANGED
|
@@ -51,6 +51,70 @@ const TEST_RUNNER_LEAKS = ['NODE_TEST_CONTEXT', 'NODE_TEST_WORKER_ID'];
|
|
|
51
51
|
// HOME-derived locations re-pointed INTO the fresh home, so nothing reaches the real one through them.
|
|
52
52
|
const XDG_DIRS = { XDG_CONFIG_HOME: '.config', XDG_DATA_HOME: '.local/share', XDG_CACHE_HOME: '.cache', XDG_STATE_HOME: '.local/state' };
|
|
53
53
|
|
|
54
|
+
// Toolchain-manager homes (#447). A version manager's proxy (`cargo`/`rustc` from rustup, a pyenv
|
|
55
|
+
// or asdf shim, …) finds its installed toolchain through ONE variable whose default is under
|
|
56
|
+
// $HOME. With HOME swapped for an empty dir the proxy finds nothing, tries to install a toolchain,
|
|
57
|
+
// and — network off — fails; the verdict then read `live-env` and blamed the code for a machine
|
|
58
|
+
// dependency it does not have (measured: a rustup-managed Rust workspace, `live-env` locally,
|
|
59
|
+
// green on CI where the container brings its own toolchain). An installed toolchain is the
|
|
60
|
+
// compiler/interpreter the test step runs ON, not live state the tests READ, so the variable is
|
|
61
|
+
// pinned to the real directory BEFORE HOME moves — only when the caller has not set it already
|
|
62
|
+
// (a set value passes through untouched: none of these names match a strip rule) and only when
|
|
63
|
+
// that directory actually exists (nothing is invented). Every pin is printed in the verdict, the
|
|
64
|
+
// same visibility rule as --keep. The cost, stated: such a home also holds the manager's own
|
|
65
|
+
// config and package cache (~/.cargo/config.toml, ~/.cargo/registry, ~/go/pkg/mod), and a test
|
|
66
|
+
// reading THOSE is not caught — `--no-pin` restores the strict run for a suite suspected of it.
|
|
67
|
+
const TOOLCHAIN_HOMES = [
|
|
68
|
+
{ name: 'RUSTUP_HOME', rel: '.rustup', manager: 'rustup' },
|
|
69
|
+
{ name: 'CARGO_HOME', rel: '.cargo', manager: 'rustup/cargo' },
|
|
70
|
+
{ name: 'PYENV_ROOT', rel: '.pyenv', manager: 'pyenv' },
|
|
71
|
+
{ name: 'RBENV_ROOT', rel: '.rbenv', manager: 'rbenv' },
|
|
72
|
+
{ name: 'ASDF_DATA_DIR', rel: '.asdf', manager: 'asdf' },
|
|
73
|
+
{ name: 'NVM_DIR', rel: '.nvm', manager: 'nvm' },
|
|
74
|
+
{ name: 'VOLTA_HOME', rel: '.volta', manager: 'volta' },
|
|
75
|
+
// mise follows XDG_DATA_HOME, which the hermetic run re-points — so its default must be resolved
|
|
76
|
+
// against the CALLER's XDG_DATA_HOME, not the fresh one.
|
|
77
|
+
{ name: 'MISE_DATA_DIR', rel: '.local/share/mise', xdg: ['XDG_DATA_HOME', 'mise'], manager: 'mise' },
|
|
78
|
+
{ name: 'GOPATH', rel: 'go', manager: 'go (GOTOOLCHAIN downloads + module cache)' },
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Which toolchain homes to pin → `[{ name, value, manager }]`. `exists(path)` is injected so this
|
|
83
|
+
* stays pure; the CLI passes a real directory check. A variable already set in `env` is never in
|
|
84
|
+
* the list — it reaches the hermetic run unchanged anyway.
|
|
85
|
+
*/
|
|
86
|
+
function toolchainPins(env, exists) {
|
|
87
|
+
const home = env.HOME;
|
|
88
|
+
const pins = [];
|
|
89
|
+
for (const t of TOOLCHAIN_HOMES) {
|
|
90
|
+
if (env[t.name]) continue;
|
|
91
|
+
let dir = null;
|
|
92
|
+
if (t.xdg && env[t.xdg[0]]) dir = `${env[t.xdg[0]].replace(/\/+$/, '')}/${t.xdg[1]}`;
|
|
93
|
+
else if (home) dir = `${home.replace(/\/+$/, '')}/${t.rel}`;
|
|
94
|
+
if (dir && exists(dir)) pins.push({ name: t.name, value: dir, manager: t.manager });
|
|
95
|
+
}
|
|
96
|
+
return pins;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// The output shapes of a version manager that could not find its toolchain — what a missed pin
|
|
100
|
+
// looks like. Used only for a hint line under a `live-env` verdict; the verdict itself is unchanged.
|
|
101
|
+
const TOOLCHAIN_MISS_PATTERNS = [
|
|
102
|
+
/syncing channel updates for/i, // rustup proxy installing a toolchain
|
|
103
|
+
/static\.rust-lang\.org/i,
|
|
104
|
+
/rustup could not choose a version|no default toolchain/i,
|
|
105
|
+
/pyenv: version .* is not installed/i,
|
|
106
|
+
/rbenv: version .* is not installed/i,
|
|
107
|
+
/No version is set for command|No preset version installed/i, // asdf
|
|
108
|
+
/mise .*(is not installed|missing:)/i,
|
|
109
|
+
/go: downloading go\d|toolchain not available/i,
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
/** True when a failed run's output looks like a toolchain manager missing its install. */
|
|
113
|
+
function looksLikeToolchainMiss(output) {
|
|
114
|
+
const s = String(output || '');
|
|
115
|
+
return TOOLCHAIN_MISS_PATTERNS.some((re) => re.test(s));
|
|
116
|
+
}
|
|
117
|
+
|
|
54
118
|
function shouldStrip(name) {
|
|
55
119
|
if (name === 'HOME' || name === 'PATH') return false;
|
|
56
120
|
if (STRIP_EXACT.has(name) || STRIP_EXACT.has(name.toLowerCase())) return true;
|
|
@@ -65,15 +129,17 @@ function normalEnv(env) {
|
|
|
65
129
|
}
|
|
66
130
|
|
|
67
131
|
/**
|
|
68
|
-
* The hermetic run's env → `{ env, stripped, kept }`. `home` is the fresh directory the
|
|
69
|
-
* created. `keep` names variables the caller explicitly passes through anyway — every one is
|
|
70
|
-
* echoed in the verdict, so a pass-through is visible, never silent.
|
|
132
|
+
* The hermetic run's env → `{ env, stripped, kept, pinned }`. `home` is the fresh directory the
|
|
133
|
+
* caller created. `keep` names variables the caller explicitly passes through anyway — every one is
|
|
134
|
+
* echoed in the verdict, so a pass-through is visible, never silent. `pins` (from `toolchainPins`)
|
|
135
|
+
* are toolchain-manager homes set to their real directories before HOME moves (#447) — echoed too.
|
|
71
136
|
*/
|
|
72
|
-
function hermeticEnv(env, home, keep = []) {
|
|
137
|
+
function hermeticEnv(env, home, keep = [], { pins = [] } = {}) {
|
|
73
138
|
const keepSet = new Set(keep);
|
|
74
139
|
const out = {};
|
|
75
140
|
const stripped = [];
|
|
76
141
|
const kept = [];
|
|
142
|
+
for (const p of pins) out[p.name] = p.value;
|
|
77
143
|
for (const [k, v] of Object.entries(env)) {
|
|
78
144
|
if (TEST_RUNNER_LEAKS.includes(k)) continue;
|
|
79
145
|
if (keepSet.has(k)) { out[k] = v; if (shouldStrip(k)) kept.push(k); continue; }
|
|
@@ -83,7 +149,7 @@ function hermeticEnv(env, home, keep = []) {
|
|
|
83
149
|
}
|
|
84
150
|
out.HOME = home;
|
|
85
151
|
for (const [k, rel] of Object.entries(XDG_DIRS)) if (!keepSet.has(k)) out[k] = `${home}/${rel}`;
|
|
86
|
-
return { env: out, stripped: stripped.sort(), kept: kept.sort() };
|
|
152
|
+
return { env: out, stripped: stripped.sort(), kept: kept.sort(), pinned: pins.map((p) => p.name) };
|
|
87
153
|
}
|
|
88
154
|
|
|
89
155
|
// ---- the network ----------------------------------------------------------------------------
|
|
@@ -188,6 +254,6 @@ const VERDICT_TEXT = {
|
|
|
188
254
|
};
|
|
189
255
|
|
|
190
256
|
module.exports = {
|
|
191
|
-
parseLiveEnv, shouldStrip, normalEnv, hermeticEnv, probeNetworkIsolation, parseFailures, tail,
|
|
257
|
+
parseLiveEnv, shouldStrip, normalEnv, hermeticEnv, toolchainPins, looksLikeToolchainMiss, TOOLCHAIN_HOMES, probeNetworkIsolation, parseFailures, tail,
|
|
192
258
|
classify, VERDICT_TEXT, DARWIN_PROFILE, LINUX_WRAPPER, TEST_RUNNER_LEAKS,
|
|
193
259
|
};
|
|
@@ -25,6 +25,7 @@ const fs = require('fs');
|
|
|
25
25
|
const path = require('path');
|
|
26
26
|
const { execFileSync } = require('child_process');
|
|
27
27
|
const stamp = require('./stamp');
|
|
28
|
+
const notifyEndpoint = require('./notify-endpoint');
|
|
28
29
|
|
|
29
30
|
const OK = 'ok';
|
|
30
31
|
const WARN = 'warn';
|
|
@@ -218,6 +219,23 @@ function checkHooks({ root, colabHome, home, env }) {
|
|
|
218
219
|
return rows;
|
|
219
220
|
}
|
|
220
221
|
|
|
222
|
+
/**
|
|
223
|
+
* notifyUrl against a DECLARED local observer (#414). Silent unless something says an observer runs
|
|
224
|
+
* here: a machine with no <COLAB_HOME>/notify-endpoint gets no row at all — unset is the right default
|
|
225
|
+
* there, and a ⚠ on every such machine would teach people to ignore the row. ⚠ rather than ✗: the
|
|
226
|
+
* key is something never set up, not something installed that went stale.
|
|
227
|
+
*/
|
|
228
|
+
function checkNotify({ colabHome }) {
|
|
229
|
+
let cfg = {};
|
|
230
|
+
try { cfg = JSON.parse(readText(path.join(colabHome, 'config.json')) || '{}'); } catch (_) { /* reported by colab itself */ }
|
|
231
|
+
const st = notifyEndpoint.status(cfg, colabHome);
|
|
232
|
+
if (st.state === 'unset') return [];
|
|
233
|
+
if (st.state === 'set' && !st.declared) {
|
|
234
|
+
return [{ area: 'notify', severity: OK, text: `notifyUrl = ${st.url}` }];
|
|
235
|
+
}
|
|
236
|
+
return [{ area: 'notify', severity: WARN, text: notifyEndpoint.healthLine(st) }];
|
|
237
|
+
}
|
|
238
|
+
|
|
221
239
|
function runChecks(opts) {
|
|
222
240
|
const o = { env: process.env, ...opts };
|
|
223
241
|
return [
|
|
@@ -226,6 +244,7 @@ function runChecks(opts) {
|
|
|
226
244
|
checkState(o),
|
|
227
245
|
...checkFleet(o),
|
|
228
246
|
...checkHooks(o),
|
|
247
|
+
...checkNotify(o),
|
|
229
248
|
];
|
|
230
249
|
}
|
|
231
250
|
|
|
@@ -255,5 +274,5 @@ if (require.main === module) {
|
|
|
255
274
|
|
|
256
275
|
module.exports = {
|
|
257
276
|
OK, WARN, FAIL,
|
|
258
|
-
dispatchedCommands, checkLink, checkFrozen, checkState, checkFleet, checkHooks, runChecks, render,
|
|
277
|
+
dispatchedCommands, checkLink, checkFrozen, checkState, checkFleet, checkHooks, checkNotify, runChecks, render,
|
|
259
278
|
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* notify-endpoint.js — is this machine's `notifyUrl` set, and SHOULD it be? (#414)
|
|
4
|
+
*
|
|
5
|
+
* `notifyUrl` is optional by design (lib/notify.js): unset means colab makes no network call of its
|
|
6
|
+
* own, and silence is the right behaviour on a machine with no observer. But a machine that DOES run
|
|
7
|
+
* a local observer (a companion dashboard ingesting `issue.merged`, `issue.closed`,
|
|
8
|
+
* `readiness.marked`, `gate.recorded`) depends on the push for the kinds it cannot recover by
|
|
9
|
+
* polling state.json, and an unset key there is a silent outage. Measured on a two-machine fleet
|
|
10
|
+
* running the same observer: the machine set up by hand had recorded 2 292 `issue.merged` events;
|
|
11
|
+
* the one set up a month later with install.sh had 0, and nothing said so until someone asked for
|
|
12
|
+
* lead time.
|
|
13
|
+
*
|
|
14
|
+
* Two inputs answer "should it be set", and colab guesses neither:
|
|
15
|
+
*
|
|
16
|
+
* 1. an explicit URL a human passes to `install.sh --notify-url <url>`;
|
|
17
|
+
* 2. the DECLARED ENDPOINT FILE, `<COLAB_HOME>/notify-endpoint` — the convention by which a local
|
|
18
|
+
* observer announces itself. The observer writes its own events URL there (one http(s) URL on
|
|
19
|
+
* the first non-comment line); colab only reads it. No port is probed and no well-known URL is
|
|
20
|
+
* hard-coded: an observer's address is the observer's fact, not the handbook's.
|
|
21
|
+
*
|
|
22
|
+
* What reads this:
|
|
23
|
+
* - install.sh seeds `notifyUrl` from (1), else (2), ONLY when the key is absent — an existing
|
|
24
|
+
* value is someone's deliberate choice and is never overwritten. When nothing seeds it, install
|
|
25
|
+
* says plainly that the key is unset and what that costs.
|
|
26
|
+
* - `install.sh --check` and `colab doctor` report `notifyUrl: unset` when (2) exists and the key
|
|
27
|
+
* does not. No declared endpoint → nothing is reported: silence stays right for a machine with
|
|
28
|
+
* no observer.
|
|
29
|
+
*
|
|
30
|
+
* CommonJS, zero dependencies. Runnable as a script (install.sh's entry):
|
|
31
|
+
* node tools/lib/notify-endpoint.js seed --colab-home <dir> [--url <url>] [--dry]
|
|
32
|
+
* It writes config.json through lib/state.js, the CLI's own writer, so the file's shape cannot drift
|
|
33
|
+
* from what `colab config set` produces. state.js reads COLAB_HOME at require time, so the entry
|
|
34
|
+
* sets it from --colab-home before requiring it.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
const fs = require('fs');
|
|
38
|
+
const path = require('path');
|
|
39
|
+
|
|
40
|
+
const ENDPOINT_FILE = 'notify-endpoint';
|
|
41
|
+
const HTTP_RE = /^https?:\/\//i;
|
|
42
|
+
|
|
43
|
+
/** The event kinds a local observer only learns of by push — named in the "unset" line. */
|
|
44
|
+
const PUSH_ONLY_KINDS = Object.freeze(['issue.merged', 'issue.closed', 'readiness.marked', 'gate.recorded']);
|
|
45
|
+
|
|
46
|
+
function endpointFile(colabHome) {
|
|
47
|
+
return path.join(colabHome, ENDPOINT_FILE);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Read the declared endpoint. Returns null when no file exists (the common, silent case), else
|
|
52
|
+
* `{ file, url }` for a usable URL or `{ file, invalid }` naming what is wrong with it — a declared
|
|
53
|
+
* endpoint that cannot be used is reported, never silently treated as absent.
|
|
54
|
+
*/
|
|
55
|
+
function readDeclared(colabHome) {
|
|
56
|
+
const file = endpointFile(colabHome);
|
|
57
|
+
let raw;
|
|
58
|
+
try { raw = fs.readFileSync(file, 'utf8'); } catch (_) { return null; }
|
|
59
|
+
const line = raw.split(/\r?\n/).map((l) => l.replace(/#.*$/, '').trim()).find(Boolean);
|
|
60
|
+
if (!line) return { file, invalid: 'empty — no URL on any non-comment line' };
|
|
61
|
+
if (!HTTP_RE.test(line)) return { file, invalid: `not an http(s) URL: ${line}` };
|
|
62
|
+
return { file, url: line };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function configuredUrl(cfg) {
|
|
66
|
+
return cfg && typeof cfg.notifyUrl === 'string' ? cfg.notifyUrl.trim() : '';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The read-only verdict both health checks print. `state`:
|
|
71
|
+
* 'set' notifyUrl is configured (payload: url; `declared` when the file names another)
|
|
72
|
+
* 'unset-declared' notifyUrl absent while an observer declared an endpoint — the outage case
|
|
73
|
+
* 'declared-invalid' notifyUrl absent and the declared file is unusable
|
|
74
|
+
* 'unset' neither — a machine with no observer; callers stay silent
|
|
75
|
+
*/
|
|
76
|
+
function status(cfg, colabHome) {
|
|
77
|
+
const url = configuredUrl(cfg);
|
|
78
|
+
const declared = readDeclared(colabHome);
|
|
79
|
+
if (url) {
|
|
80
|
+
return declared && declared.url && declared.url !== url
|
|
81
|
+
? { state: 'set', url, declared }
|
|
82
|
+
: { state: 'set', url };
|
|
83
|
+
}
|
|
84
|
+
if (!declared) return { state: 'unset' };
|
|
85
|
+
if (declared.invalid) return { state: 'declared-invalid', declared };
|
|
86
|
+
return { state: 'unset-declared', declared };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** One human line for a status, or null when the right output is silence. */
|
|
90
|
+
function healthLine(st) {
|
|
91
|
+
if (st.state === 'unset-declared') {
|
|
92
|
+
return `notifyUrl: unset — ${st.declared.file} declares a local observer at ${st.declared.url}, ` +
|
|
93
|
+
`which receives no events (${PUSH_ONLY_KINDS.join(', ')}). Fix: colab config set notifyUrl ${st.declared.url}`;
|
|
94
|
+
}
|
|
95
|
+
if (st.state === 'declared-invalid') {
|
|
96
|
+
return `notifyUrl: unset — ${st.declared.file} is ${st.declared.invalid}, so nothing could be seeded from it`;
|
|
97
|
+
}
|
|
98
|
+
if (st.state === 'set' && st.declared) {
|
|
99
|
+
return `notifyUrl: ${st.url} — differs from the endpoint declared in ${st.declared.file} (${st.declared.url}); ` +
|
|
100
|
+
'left as configured, check which one the local observer listens on';
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Decide what install.sh does. Pure: returns `{ action, url?, source?, lines[] }` and writes nothing.
|
|
107
|
+
* action 'keep' the key is already set — never overwritten
|
|
108
|
+
* action 'seed' write `url` (from the flag, else the declared file)
|
|
109
|
+
* action 'none' nothing to seed — the lines say plainly the key is unset and what it costs
|
|
110
|
+
*/
|
|
111
|
+
function plan({ cfg, colabHome, flagUrl }) {
|
|
112
|
+
const current = configuredUrl(cfg);
|
|
113
|
+
const declared = readDeclared(colabHome);
|
|
114
|
+
if (flagUrl && !HTTP_RE.test(flagUrl)) {
|
|
115
|
+
return { action: 'error', lines: [`--notify-url must be an http(s) URL, got: ${flagUrl}`] };
|
|
116
|
+
}
|
|
117
|
+
if (current) {
|
|
118
|
+
const lines = [`✓ notifyUrl = ${current} (already set → left untouched)`];
|
|
119
|
+
if (flagUrl && flagUrl !== current) {
|
|
120
|
+
lines.push(`⚠ --notify-url ${flagUrl} NOT applied: an existing value is never overwritten. ` +
|
|
121
|
+
`To change it: colab config set notifyUrl ${flagUrl}`);
|
|
122
|
+
}
|
|
123
|
+
const hl = healthLine(status(cfg, colabHome));
|
|
124
|
+
if (hl) lines.push(`⚠ ${hl}`);
|
|
125
|
+
return { action: 'keep', lines };
|
|
126
|
+
}
|
|
127
|
+
if (flagUrl) return { action: 'seed', url: flagUrl, source: '--notify-url', lines: [] };
|
|
128
|
+
if (declared && declared.url) return { action: 'seed', url: declared.url, source: declared.file, lines: [] };
|
|
129
|
+
const lines = [];
|
|
130
|
+
if (declared && declared.invalid) lines.push(`⚠ ${declared.file} is ${declared.invalid} — ignored.`);
|
|
131
|
+
lines.push(
|
|
132
|
+
'⚠ notifyUrl is UNSET — colab pushes no events from this machine.',
|
|
133
|
+
` A local observer (e.g. a companion dashboard) here will never receive ${PUSH_ONLY_KINDS.join(', ')}.`,
|
|
134
|
+
' Observer on this machine? Re-run with --notify-url <its events URL>, or: colab config set notifyUrl <url>',
|
|
135
|
+
' No observer here? Nothing to do — unset is the right default.',
|
|
136
|
+
);
|
|
137
|
+
return { action: 'none', lines };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function main(argv) {
|
|
141
|
+
const sub = argv[0];
|
|
142
|
+
const val = (flag) => {
|
|
143
|
+
const i = argv.indexOf(flag);
|
|
144
|
+
return i >= 0 && argv[i + 1] !== undefined ? argv[i + 1] : undefined;
|
|
145
|
+
};
|
|
146
|
+
const colabHome = val('--colab-home') || process.env.COLAB_HOME || path.join(require('os').homedir(), '.colab');
|
|
147
|
+
if (sub !== 'seed') {
|
|
148
|
+
process.stderr.write('usage: notify-endpoint.js seed --colab-home <dir> [--url <url>] [--dry]\n');
|
|
149
|
+
return 2;
|
|
150
|
+
}
|
|
151
|
+
process.env.COLAB_HOME = colabHome; // before state.js computes its paths
|
|
152
|
+
const state = require('./state');
|
|
153
|
+
const cfg = state.loadConfig();
|
|
154
|
+
const p = plan({ cfg, colabHome, flagUrl: val('--url') });
|
|
155
|
+
const out = (l) => process.stdout.write(` ${l}\n`);
|
|
156
|
+
if (p.action === 'error') { process.stderr.write(` ✗ ${p.lines[0]}\n`); return 2; }
|
|
157
|
+
if (p.action !== 'seed') { p.lines.forEach(out); return 0; }
|
|
158
|
+
if (argv.includes('--dry')) { out(`[dry] seed notifyUrl = ${p.url} (from ${p.source})`); return 0; }
|
|
159
|
+
// Re-read inside the write: a key set between plan and write is still never overwritten.
|
|
160
|
+
const fresh = state.loadConfig();
|
|
161
|
+
if (configuredUrl(fresh)) { out(`✓ notifyUrl = ${configuredUrl(fresh)} (already set → left untouched)`); return 0; }
|
|
162
|
+
fresh.notifyUrl = p.url;
|
|
163
|
+
state.saveConfig(fresh);
|
|
164
|
+
out(`📡 notifyUrl seeded: ${p.url} (from ${p.source}) — colab now pushes its events there`);
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (require.main === module) process.exitCode = main(process.argv.slice(2));
|
|
169
|
+
|
|
170
|
+
module.exports = { ENDPOINT_FILE, PUSH_ONLY_KINDS, endpointFile, readDeclared, status, healthLine, plan, main };
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
* issue opened late can never shorten the window a human had to veto in;
|
|
27
27
|
* - events are comments on the issue carrying `<!-- colab:release-event k=v … -->` markers.
|
|
28
28
|
*
|
|
29
|
-
* Nothing else is stored: trunk-green-throughout is re-measured from GitHub's run list on every run
|
|
29
|
+
* Nothing else is stored: trunk-green-throughout is re-measured from GitHub's run list on every run —
|
|
30
|
+
* over `main` and, where project.yml's `trunk:` is another branch, that branch too (#437, windowBranches).
|
|
30
31
|
*
|
|
31
32
|
* `--auto` (#423) changes WHICH candidate a run judges, nothing else: instead of always the newest
|
|
32
33
|
* one (whose clock a daily cut keeps restarting, so on a repo cutting a candidate every day no
|
|
@@ -238,20 +239,22 @@ function periodVerdict({ cutAt, trackingCreatedAt, testPeriodDays, now }) {
|
|
|
238
239
|
}
|
|
239
240
|
|
|
240
241
|
/**
|
|
241
|
-
* Trunk CI green THROUGHOUT the period. `runs` is `gh run list --branch
|
|
242
|
-
* `truncated` true when
|
|
242
|
+
* Trunk CI green THROUGHOUT the period. `runs` is the window's `gh run list --branch <b>` rows, merged
|
|
243
|
+
* across windowBranches() by mergeWindowRuns() (null = unread), `truncated` true when a read hit its
|
|
244
|
+
* limit, `branches` the branches read (named in the detail). Only runs created at/after `periodStart`, of a
|
|
243
245
|
* workflow in `suiteWorkflows` (the workflows that vetted the candidate — an unrelated scheduled
|
|
244
246
|
* workflow cannot veto a release), and not `pull_request` events, count.
|
|
245
247
|
*
|
|
246
248
|
* Returns { ok, permanent, pending, detail }:
|
|
247
249
|
* - a completed run that failed (anything but success/skipped/neutral/cancelled) -> permanent:
|
|
248
250
|
* trunk was red during this candidate's period, and nothing later un-reds it;
|
|
249
|
-
* - cancelled -> fine when a LATER run of the same workflow succeeded or is still running
|
|
251
|
+
* - cancelled -> fine when a LATER run of the same workflow ON THE SAME BRANCH succeeded or is still running
|
|
250
252
|
* (pending), otherwise not clean (not permanent: a re-run can settle it);
|
|
251
253
|
* - a run still queued/in progress -> pending.
|
|
252
254
|
*/
|
|
253
|
-
function trunkGreenVerdict(runs, { periodStart, periodEnd = null, suiteWorkflows, truncated }) {
|
|
254
|
-
|
|
255
|
+
function trunkGreenVerdict(runs, { periodStart, periodEnd = null, suiteWorkflows, truncated, branches = ['main'] }) {
|
|
256
|
+
const on = (branches && branches.length ? branches : ['main']).join(' + ');
|
|
257
|
+
if (runs === null || runs === undefined) return { ok: false, permanent: false, pending: false, detail: `gh run list on ${on} failed — cannot confirm trunk stayed green` };
|
|
255
258
|
if (truncated) return { ok: false, permanent: false, pending: false, detail: 'the run list hit its read limit — cannot confirm trunk stayed green' };
|
|
256
259
|
const startMs = Date.parse(periodStart);
|
|
257
260
|
// #423: --auto bounds the window to the candidate's own period — a run after it closed is about newer code.
|
|
@@ -260,19 +263,56 @@ function trunkGreenVerdict(runs, { periodStart, periodEnd = null, suiteWorkflows
|
|
|
260
263
|
const inWindow = runs.filter((r) => r && Date.parse(r.createdAt) >= startMs && Date.parse(r.createdAt) < endMs && suite.has(r.workflowName || '(unnamed workflow)') && r.event !== 'pull_request');
|
|
261
264
|
const red = inWindow.filter((r) => r.status === 'completed' && !NOT_RED.has(r.conclusion) && r.conclusion !== 'cancelled');
|
|
262
265
|
if (red.length) {
|
|
263
|
-
return { ok: false, permanent: true, pending: false, detail: `trunk went red during the test period: ${red.map((r) => `${r.workflowName} ${r.conclusion} at ${String(r.headSha).slice(0, 7)} (${r.createdAt})`).join('; ')}` };
|
|
266
|
+
return { ok: false, permanent: true, pending: false, detail: `trunk went red during the test period: ${red.map((r) => `${r.workflowName} ${r.conclusion}${r.branch ? ` on ${r.branch}` : ''} at ${String(r.headSha).slice(0, 7)} (${r.createdAt})`).join('; ')}` };
|
|
264
267
|
}
|
|
265
268
|
const unsettled = [];
|
|
266
269
|
let pending = inWindow.some((r) => r.status !== 'completed');
|
|
267
270
|
for (const c of inWindow.filter((r) => r.status === 'completed' && r.conclusion === 'cancelled')) {
|
|
268
|
-
|
|
271
|
+
// #437: a later run on ANOTHER branch tested other code — it never settles this one's cancellation.
|
|
272
|
+
const later = inWindow.filter((r) => r.workflowName === c.workflowName && (r.branch || null) === (c.branch || null) && Date.parse(r.createdAt) > Date.parse(c.createdAt));
|
|
269
273
|
if (later.some((r) => r.status === 'completed' && r.conclusion === 'success')) continue;
|
|
270
274
|
if (later.some((r) => r.status !== 'completed')) { pending = true; continue; }
|
|
271
|
-
unsettled.push(`${c.workflowName} cancelled at ${String(c.headSha).slice(0, 7)} with no later run`);
|
|
275
|
+
unsettled.push(`${c.workflowName} cancelled${c.branch ? ` on ${c.branch}` : ''} at ${String(c.headSha).slice(0, 7)} with no later run`);
|
|
272
276
|
}
|
|
273
277
|
if (unsettled.length) return { ok: false, permanent: false, pending: false, detail: `not settled: ${unsettled.join('; ')}` };
|
|
274
278
|
if (pending) return { ok: false, permanent: false, pending: true, detail: 'a trunk run in the test period is still in flight' };
|
|
275
|
-
return { ok: true, permanent: false, pending: false, detail: `${inWindow.length}
|
|
279
|
+
return { ok: true, permanent: false, pending: false, detail: `${inWindow.length} run(s) on ${on} of the candidate's workflows since ${periodStart}${periodEnd ? ` until ${periodEnd}` : ''}, none red` };
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* #437: the branches whose runs make up the trunk-green window. Candidates are cut from `main`, so
|
|
284
|
+
* `main` is always read; where project.yml's `trunk:` is another branch (`trunk: dev` + `deploy: tag`)
|
|
285
|
+
* it is read too. On that shape `main` receives CI only at promotions, so a `main`-only window holds
|
|
286
|
+
* little beyond the promotion's own run and "trunk stayed green" would be close to vacuous — `trunk:`
|
|
287
|
+
* is where the code under test actually moves during the period. A red run there counts exactly as a
|
|
288
|
+
* red run on `main` does on `trunk: main`, where every run after the cut is newer code too.
|
|
289
|
+
*/
|
|
290
|
+
function windowBranches(trunk) {
|
|
291
|
+
const t = String(trunk || '').trim();
|
|
292
|
+
return t && t !== 'main' ? [t, 'main'] : ['main'];
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* #437: `reads` is [{ branch, read }] where `read` is ghRunsSince()'s { runs, truncated } or null. Returns
|
|
297
|
+
* { runs, truncated } with every row tagged `branch` (deduplicated by databaseId, first read wins), or
|
|
298
|
+
* null when ANY branch could not be read — a window missing one branch is not a window that was clean.
|
|
299
|
+
*/
|
|
300
|
+
function mergeWindowRuns(reads) {
|
|
301
|
+
const list = reads || [];
|
|
302
|
+
if (!list.length || list.some((x) => !x || !x.read || !Array.isArray(x.read.runs))) return null;
|
|
303
|
+
const seen = new Set();
|
|
304
|
+
const runs = [];
|
|
305
|
+
for (const { branch, read } of list) {
|
|
306
|
+
for (const r of read.runs) {
|
|
307
|
+
if (!r) continue;
|
|
308
|
+
if (r.databaseId !== undefined && r.databaseId !== null) {
|
|
309
|
+
if (seen.has(r.databaseId)) continue;
|
|
310
|
+
seen.add(r.databaseId);
|
|
311
|
+
}
|
|
312
|
+
runs.push({ ...r, branch });
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return { runs, truncated: list.some((x) => !!x.read.truncated) };
|
|
276
316
|
}
|
|
277
317
|
|
|
278
318
|
/**
|
|
@@ -475,7 +515,7 @@ module.exports = {
|
|
|
475
515
|
STATES, CONDITIONS, HOLD_LABEL, CUT_SUBJECT_SUFFIX,
|
|
476
516
|
parseVersion, compareVersions, parseCandidate,
|
|
477
517
|
parseReleaseMarker, releaseMarker, eventMarker, hasEvent, trackingTitle, trackingBody,
|
|
478
|
-
selectCandidate, openCandidates, pickNewestClean, periodVerdict, trunkGreenVerdict, regressionVerdict,
|
|
518
|
+
selectCandidate, openCandidates, pickNewestClean, periodVerdict, trunkGreenVerdict, windowBranches, mergeWindowRuns, regressionVerdict,
|
|
479
519
|
handoffCommand, decide, tagMessage, migrationGrantVerdict,
|
|
480
520
|
carriedIssues, previousFinal, releasedEvent, releasedComment,
|
|
481
521
|
};
|
package/tools/lib/ship-batch.js
CHANGED
|
@@ -257,6 +257,16 @@ function batchGreenCoversTrunk({ trunkRows, batchRows, trunkFires, batchFires })
|
|
|
257
257
|
return (batchRows || []).length >= a.length;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
+
/**
|
|
261
|
+
* #415: branches the command line names that a staged batch does not carry, in command-line order.
|
|
262
|
+
* `staged` is parseMemberTrailers' `[{ branch }]`. Not a refusal on its own: a branch over the cap or
|
|
263
|
+
* dropped at build is EXPECTED to be missing on resume — the caller must say so, never stay silent.
|
|
264
|
+
*/
|
|
265
|
+
function notStaged(requested, staged) {
|
|
266
|
+
const have = new Set((staged || []).map((m) => m && m.branch).filter(Boolean));
|
|
267
|
+
return [...new Set(requested || [])].filter((b) => b && !have.has(b));
|
|
268
|
+
}
|
|
269
|
+
|
|
260
270
|
/** The clause each member's 🚢 evidence comment gains: which combined run graded it. */
|
|
261
271
|
function evidenceSuffix({ n, ref, headSha, runIds }) {
|
|
262
272
|
const runs = (runIds || []).length ? (runIds || []).join(', ') : '(id unread)';
|
|
@@ -273,5 +283,5 @@ module.exports = {
|
|
|
273
283
|
MAX_BATCH, REF_PREFIX, PROBE_REF, TRAILER_KEY,
|
|
274
284
|
parseShipBatch, batchRefName, parseBatchRef, memberTrailer, parseMemberTrailers,
|
|
275
285
|
branchCiClass, memberEligibility, selectMembers, wiring, combinedVerdict, nextStep, foreignBatchStep,
|
|
276
|
-
batchGreenCoversTrunk, evidenceSuffix, serialLine,
|
|
286
|
+
batchGreenCoversTrunk, evidenceSuffix, serialLine, notStaged,
|
|
277
287
|
};
|