@tablation/crew 0.171.1 → 0.172.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/dist/cli.js +506 -10
- package/dist/sandbox-intel-bridge.cjs +50 -2
- package/docs/repo-setup-prompt.md +2 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -38,7 +38,11 @@ function doctorBaseReport(r, base, health) {
|
|
|
38
38
|
function ciProviderFor(name, deps) {
|
|
39
39
|
return name === "github" ? githubProvider(deps) : null;
|
|
40
40
|
}
|
|
41
|
+
function pipelineProviderFor(name, deps) {
|
|
42
|
+
return name === "buildkite" ? buildkiteProvider(deps) : null;
|
|
43
|
+
}
|
|
41
44
|
var isQueryableCiProvider = (name) => name === "github";
|
|
45
|
+
var isPipelineCiProvider = (name) => name === "buildkite";
|
|
42
46
|
function logTail(log, n = 40) {
|
|
43
47
|
return log.split("\n").map((l) => l.replace(/^\d{4}-\d\d-\d\dT[\d:.]+Z /, "").replace(/\r$/, "")).filter((l) => l.trim()).slice(-n).join("\n");
|
|
44
48
|
}
|
|
@@ -107,6 +111,98 @@ function githubProvider(deps) {
|
|
|
107
111
|
}
|
|
108
112
|
var CiAccessError = class extends Error {
|
|
109
113
|
};
|
|
114
|
+
var BUILDKITE_HOST = "buildkite.com";
|
|
115
|
+
var BUILDKITE_API = "https://api.buildkite.com/v2";
|
|
116
|
+
function buildkiteState(state) {
|
|
117
|
+
switch (state) {
|
|
118
|
+
case "passed":
|
|
119
|
+
case "blocked":
|
|
120
|
+
case "finished":
|
|
121
|
+
return "passed";
|
|
122
|
+
case "failed":
|
|
123
|
+
case "failing":
|
|
124
|
+
case "canceled":
|
|
125
|
+
case "canceling":
|
|
126
|
+
return "failed";
|
|
127
|
+
case "skipped":
|
|
128
|
+
case "not_run":
|
|
129
|
+
return "other";
|
|
130
|
+
default:
|
|
131
|
+
return "pending";
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function buildkiteProvider(deps) {
|
|
135
|
+
const doFetch = deps.fetch ?? fetch;
|
|
136
|
+
const get2 = async (path, accept = "application/json") => {
|
|
137
|
+
const token = deps.token(BUILDKITE_HOST);
|
|
138
|
+
if (!token) throw new CiAccessError(`no readable credential for ${BUILDKITE_HOST}`);
|
|
139
|
+
return doFetch(path.startsWith("http") ? path : `${BUILDKITE_API}${path}`, {
|
|
140
|
+
headers: { authorization: `Bearer ${token}`, accept, "user-agent": "crew" },
|
|
141
|
+
redirect: "follow"
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
const slug2 = (q2) => {
|
|
145
|
+
const m = /^([^/\s]+)\/([^/\s]+)$/.exec(q2.pipeline ?? "");
|
|
146
|
+
return m ? `/organizations/${m[1]}/pipelines/${m[2]}` : null;
|
|
147
|
+
};
|
|
148
|
+
const describe2 = (res, q2) => {
|
|
149
|
+
if (res.status === 429) return `${BUILDKITE_HOST} is rate limiting this token`;
|
|
150
|
+
if (res.status === 401 || res.status === 403) return `the ${BUILDKITE_HOST} token cannot read ${q2.pipeline}'s builds (HTTP ${res.status})`;
|
|
151
|
+
if (res.status === 404) return `pipeline ${q2.pipeline} is not visible to the ${BUILDKITE_HOST} token (HTTP 404)`;
|
|
152
|
+
return `${BUILDKITE_HOST} answered HTTP ${res.status}`;
|
|
153
|
+
};
|
|
154
|
+
return {
|
|
155
|
+
name: "buildkite",
|
|
156
|
+
async runs(q2) {
|
|
157
|
+
const base = slug2(q2);
|
|
158
|
+
if (!base) return { ok: false, why: `release.pipeline.pipeline "${q2.pipeline ?? ""}" is not org/slug` };
|
|
159
|
+
let res;
|
|
160
|
+
try {
|
|
161
|
+
res = await get2(`${base}/builds?commit=${encodeURIComponent(q2.sha)}&per_page=100`);
|
|
162
|
+
} catch (e) {
|
|
163
|
+
if (e instanceof CiAccessError) return { ok: false, why: e.message };
|
|
164
|
+
return { ok: false, why: `${BUILDKITE_HOST} unreachable: ${e.message}` };
|
|
165
|
+
}
|
|
166
|
+
if (!res.ok) return { ok: false, why: describe2(res, q2) };
|
|
167
|
+
let builds;
|
|
168
|
+
try {
|
|
169
|
+
builds = await res.json();
|
|
170
|
+
} catch {
|
|
171
|
+
return { ok: false, why: `${BUILDKITE_HOST} sent a reply that is not JSON` };
|
|
172
|
+
}
|
|
173
|
+
if (!Array.isArray(builds)) return { ok: false, why: `${BUILDKITE_HOST} sent a reply that is not a list of builds` };
|
|
174
|
+
return {
|
|
175
|
+
ok: true,
|
|
176
|
+
runs: builds.filter((b) => !b.commit || b.commit.startsWith(q2.sha) || q2.sha.startsWith(b.commit)).map((b) => ({
|
|
177
|
+
// The REST path addresses a build by its number, so that is the id `failure` needs.
|
|
178
|
+
id: String(b.number ?? b.id),
|
|
179
|
+
name: `${q2.pipeline} #${b.number ?? b.id}`,
|
|
180
|
+
url: b.web_url ?? "",
|
|
181
|
+
state: buildkiteState(b.state),
|
|
182
|
+
ref: q2.tag && b.branch === q2.tag ? "tag" : b.branch === q2.base ? "base" : "other"
|
|
183
|
+
}))
|
|
184
|
+
};
|
|
185
|
+
},
|
|
186
|
+
async failure(q2, run4) {
|
|
187
|
+
const out = { run: run4 };
|
|
188
|
+
const base = slug2(q2);
|
|
189
|
+
if (!base) return out;
|
|
190
|
+
try {
|
|
191
|
+
const res = await get2(`${base}/builds/${run4.id}`);
|
|
192
|
+
if (!res.ok) return out;
|
|
193
|
+
const job = (await res.json()).jobs?.find((j) => j.type === "script" && (j.state === "failed" || j.state === "timed_out"));
|
|
194
|
+
if (!job) return out;
|
|
195
|
+
out.job = job.name ?? job.label ?? void 0;
|
|
196
|
+
if (job.log_url) {
|
|
197
|
+
const log = await get2(job.log_url, "text/plain");
|
|
198
|
+
if (log.ok) out.logTail = logTail(await log.text());
|
|
199
|
+
}
|
|
200
|
+
} catch {
|
|
201
|
+
}
|
|
202
|
+
return out;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
110
206
|
function describeHttp(res, q2) {
|
|
111
207
|
if (res.status === 429 || res.status === 403 && res.headers.get("x-ratelimit-remaining") === "0") {
|
|
112
208
|
return `${q2.host} is rate limiting this credential`;
|
|
@@ -3627,6 +3723,7 @@ var RELEASE_KEYS = /* @__PURE__ */ new Set([
|
|
|
3627
3723
|
"ship",
|
|
3628
3724
|
"ci",
|
|
3629
3725
|
"verify",
|
|
3726
|
+
"pipeline",
|
|
3630
3727
|
"isolateFailures",
|
|
3631
3728
|
"rightOfWayMinutes",
|
|
3632
3729
|
"rebuildPrimary",
|
|
@@ -3638,6 +3735,7 @@ var RELEASE_KEYS = /* @__PURE__ */ new Set([
|
|
|
3638
3735
|
]);
|
|
3639
3736
|
var VERSIONINGS = ["auto", "none"];
|
|
3640
3737
|
var CI_KEYS = /* @__PURE__ */ new Set(["provider", "ref"]);
|
|
3738
|
+
var PIPELINE_KEYS = /* @__PURE__ */ new Set(["qa", "production", "pipeline", "qaTimeoutSeconds", "qaIntervalSeconds", "startTimeoutSeconds"]);
|
|
3641
3739
|
var VERIFY_KEYS = /* @__PURE__ */ new Set(["match", "timeoutSeconds", "intervalSeconds"]);
|
|
3642
3740
|
var ISOLATE_KEYS = /* @__PURE__ */ new Set(["maxCandidates"]);
|
|
3643
3741
|
var DEFAULT_ISOLATE_MAX_CANDIDATES = 8;
|
|
@@ -3660,7 +3758,19 @@ function parseIsolateMax(raw, where, fail2) {
|
|
|
3660
3758
|
return n;
|
|
3661
3759
|
}
|
|
3662
3760
|
var MATCHES = ["commit", "version"];
|
|
3663
|
-
var MODES = ["local", "integrate", "ci_manual", "ci_auto", "external"];
|
|
3761
|
+
var MODES = ["local", "integrate", "ci_manual", "ci_auto", "external", "pipeline"];
|
|
3762
|
+
function parsePipelineRoles(raw, where, fail2) {
|
|
3763
|
+
const url = (v, at) => {
|
|
3764
|
+
if (typeof v !== "string" || !/^https?:\/\/[^\s/]+/i.test(v.trim())) throw fail2(`${at} must be an http(s) address (got "${String(v)}")`);
|
|
3765
|
+
return v.trim().replace(/\/+$/, "");
|
|
3766
|
+
};
|
|
3767
|
+
if (typeof raw === "string") return [{ role: "app", url: url(raw, where) }];
|
|
3768
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
3769
|
+
const roles = Object.entries(raw).map(([role, v]) => ({ role, url: url(v, `${where}.${role}`) }));
|
|
3770
|
+
if (roles.length) return roles;
|
|
3771
|
+
}
|
|
3772
|
+
throw fail2(`${where} must be an address, or a map of role to address`);
|
|
3773
|
+
}
|
|
3664
3774
|
var PROVIDERS = ["github", "buildkite", "other", "none"];
|
|
3665
3775
|
function findRepoConfig(dir) {
|
|
3666
3776
|
for (const name of REPO_CONFIG_FILENAMES) {
|
|
@@ -3859,7 +3969,40 @@ function parseRepoConfig(text2, file, opts = {}) {
|
|
|
3859
3969
|
`${file}: release.mode "external" means the crew does not release, but hooks.deploy is defined \u2014 remove one, or use ci_manual/ci_auto if the crew should be involved`
|
|
3860
3970
|
);
|
|
3861
3971
|
}
|
|
3862
|
-
if (mode
|
|
3972
|
+
if (mode === "pipeline" && hooks.deploy) {
|
|
3973
|
+
throw new RepoConfigError(
|
|
3974
|
+
`${file}: release.mode "pipeline" means a pipeline deploys, but hooks.deploy is defined \u2014 the crew never runs a deploy script in this mode. Remove it`
|
|
3975
|
+
);
|
|
3976
|
+
}
|
|
3977
|
+
rejectUnknown(raw.release?.pipeline, PIPELINE_KEYS, "release.pipeline", file, newer);
|
|
3978
|
+
let pipeline;
|
|
3979
|
+
if (raw.release?.pipeline !== void 0 && raw.release?.pipeline !== null) {
|
|
3980
|
+
const pr = raw.release.pipeline;
|
|
3981
|
+
const fail2 = (m) => new RepoConfigError(`${file}: ${m}`);
|
|
3982
|
+
if (typeof pr !== "object" || Array.isArray(pr)) throw fail2("release.pipeline must be a map");
|
|
3983
|
+
if (typeof pr.pipeline !== "string" || !pr.pipeline.trim()) throw fail2("release.pipeline.pipeline must name the CI pipeline (for Buildkite, org/slug)");
|
|
3984
|
+
const pnum = (v, key, dflt) => {
|
|
3985
|
+
if (v === void 0 || v === null) return dflt;
|
|
3986
|
+
const n = Number(v);
|
|
3987
|
+
if (!Number.isFinite(n) || n <= 0) throw fail2(`release.pipeline.${key} must be a positive number (got "${String(v)}")`);
|
|
3988
|
+
return n;
|
|
3989
|
+
};
|
|
3990
|
+
pipeline = {
|
|
3991
|
+
qa: parsePipelineRoles(pr.qa, "release.pipeline.qa", fail2),
|
|
3992
|
+
production: parsePipelineRoles(pr.production, "release.pipeline.production", fail2),
|
|
3993
|
+
pipeline: pr.pipeline.trim(),
|
|
3994
|
+
qaTimeoutSeconds: pnum(pr.qaTimeoutSeconds, "qaTimeoutSeconds", 600),
|
|
3995
|
+
qaIntervalSeconds: pnum(pr.qaIntervalSeconds, "qaIntervalSeconds", 15),
|
|
3996
|
+
startTimeoutSeconds: pnum(pr.startTimeoutSeconds, "startTimeoutSeconds", 1800)
|
|
3997
|
+
};
|
|
3998
|
+
}
|
|
3999
|
+
if (mode === "pipeline" && !pipeline) {
|
|
4000
|
+
throw new RepoConfigError(`${file}: release.mode "pipeline" needs release.pipeline (qa, production and pipeline)`);
|
|
4001
|
+
}
|
|
4002
|
+
if (mode !== "pipeline" && pipeline) {
|
|
4003
|
+
throw new RepoConfigError(`${file}: release.pipeline only applies to release.mode "pipeline" (got "${mode}")`);
|
|
4004
|
+
}
|
|
4005
|
+
if (mode !== "local" && mode !== "external" && mode !== "integrate" && mode !== "pipeline" && !hooks.released) {
|
|
3863
4006
|
throw new RepoConfigError(
|
|
3864
4007
|
`${file}: release.mode "${mode}" needs a hooks.released \u2014 the crew cannot observe a release it did not perform without one`
|
|
3865
4008
|
);
|
|
@@ -3977,6 +4120,7 @@ function parseRepoConfig(text2, file, opts = {}) {
|
|
|
3977
4120
|
ship,
|
|
3978
4121
|
ci: { provider, ref: raw.release?.ci?.ref ? String(raw.release.ci.ref) : void 0 },
|
|
3979
4122
|
verify,
|
|
4123
|
+
...pipeline ? { pipeline } : {},
|
|
3980
4124
|
isolateFailures: isolateMax === void 0 ? void 0 : { maxCandidates: isolateMax },
|
|
3981
4125
|
rightOfWayMinutes: rightOfWay,
|
|
3982
4126
|
...parallelGatesRaw ? { parallelGates: true } : {},
|
|
@@ -4184,6 +4328,7 @@ function resolveRepoConfig(repo, ship, dir) {
|
|
|
4184
4328
|
DEFAULTS.intervalSeconds
|
|
4185
4329
|
)
|
|
4186
4330
|
},
|
|
4331
|
+
...repo?.release.pipeline ? { pipeline: repo.release.pipeline } : {},
|
|
4187
4332
|
isolateFailures: {
|
|
4188
4333
|
maxCandidates: pick(
|
|
4189
4334
|
"release.isolateFailures.maxCandidates",
|
|
@@ -4253,7 +4398,13 @@ function validateEffective(cfg) {
|
|
|
4253
4398
|
'release.mode "external" without a merged hook \u2014 the crew hands work off and then has no reliable way to learn whether it landed'
|
|
4254
4399
|
);
|
|
4255
4400
|
}
|
|
4256
|
-
if (cfg.release.mode
|
|
4401
|
+
if (cfg.release.mode === "pipeline" && !cfg.release.pipeline) {
|
|
4402
|
+
problems.push(`release.mode "pipeline" needs release.pipeline (qa, production and pipeline) in the repo's .crew.yaml`);
|
|
4403
|
+
}
|
|
4404
|
+
if (cfg.release.mode === "pipeline" && cfg.hooks.deploy) {
|
|
4405
|
+
problems.push('release.mode "pipeline" never runs a deploy hook \u2014 the pipeline deploys');
|
|
4406
|
+
}
|
|
4407
|
+
if (cfg.release.mode !== "local" && cfg.release.mode !== "external" && cfg.release.mode !== "integrate" && cfg.release.mode !== "pipeline" && !cfg.hooks.released) {
|
|
4257
4408
|
problems.push(
|
|
4258
4409
|
`release.mode "${cfg.release.mode}" needs a released hook \u2014 without one a CI release would be reported as successful merely for having been pushed`
|
|
4259
4410
|
);
|
|
@@ -7772,6 +7923,7 @@ var State = class _State {
|
|
|
7772
7923
|
const gateFailed = `.test-gate-failed-${suffix}`;
|
|
7773
7924
|
const gateReported = `.test-gate-reported-${suffix}`;
|
|
7774
7925
|
const heldReported = `.release-held-${suffix}`;
|
|
7926
|
+
const prodSeen = `.pipeline-production-${suffix}`;
|
|
7775
7927
|
const read = (f2) => {
|
|
7776
7928
|
try {
|
|
7777
7929
|
return readFileSync21(this.path(f2), "utf8").trim() || null;
|
|
@@ -7836,6 +7988,12 @@ var State = class _State {
|
|
|
7836
7988
|
clearHeldReported: () => {
|
|
7837
7989
|
rmSync11(this.path(heldReported), { force: true });
|
|
7838
7990
|
},
|
|
7991
|
+
/** `release.mode: pipeline` (CREW-2290): the commit production reported on the last look, for rollback detection. */
|
|
7992
|
+
pipelineProductionSeen: () => read(prodSeen),
|
|
7993
|
+
notePipelineProductionSeen: (sha) => {
|
|
7994
|
+
writeFileSync16(this.path(prodSeen), `${sha}
|
|
7995
|
+
`);
|
|
7996
|
+
},
|
|
7839
7997
|
testGateReported: (sha) => read(gateReported) === sha,
|
|
7840
7998
|
noteTestGateReported: (sha) => {
|
|
7841
7999
|
writeFileSync16(this.path(gateReported), `${sha}
|
|
@@ -9448,6 +9606,12 @@ var STATUS_DEFAULTS = defaultStatusValues();
|
|
|
9448
9606
|
var EPIC_DEFAULTS = defaultGroup("epics");
|
|
9449
9607
|
var MAP_DEFAULTS = defaultGroup("maps");
|
|
9450
9608
|
var single = (k) => STATUS_DEFAULTS.single[k];
|
|
9609
|
+
var RELEASED_TO_QA_DEFAULT = "released_to_qa";
|
|
9610
|
+
function withReleasedToQaResolved(c) {
|
|
9611
|
+
const v = c.statuses.releasedToQa;
|
|
9612
|
+
if (!v || c.statuses.resolved.includes(v)) return c;
|
|
9613
|
+
return { ...c, statuses: { ...c.statuses, resolved: [...c.statuses.resolved, v] } };
|
|
9614
|
+
}
|
|
9451
9615
|
var DEFAULT_CONTRACT = {
|
|
9452
9616
|
columns: defaultGroup("columns"),
|
|
9453
9617
|
comments: defaultGroup("comments"),
|
|
@@ -9460,6 +9624,7 @@ var DEFAULT_CONTRACT = {
|
|
|
9460
9624
|
handoff: single("handoff"),
|
|
9461
9625
|
verifying: single("verifying"),
|
|
9462
9626
|
verified: single("verified"),
|
|
9627
|
+
releasedToQa: RELEASED_TO_QA_DEFAULT,
|
|
9463
9628
|
deployed: single("deployed"),
|
|
9464
9629
|
needsHuman: single("needsHuman"),
|
|
9465
9630
|
reviewing: STATUS_DEFAULTS.single.reviewing ?? null,
|
|
@@ -9486,7 +9651,7 @@ var DEFAULT_CONTRACT = {
|
|
|
9486
9651
|
repoExemptReportTypes: ["coordinating", "question", "investigation"]
|
|
9487
9652
|
};
|
|
9488
9653
|
function closedStatuses(c) {
|
|
9489
|
-
return c.statuses.resolved.filter((s) => s !== c.statuses.verified);
|
|
9654
|
+
return c.statuses.resolved.filter((s) => s !== c.statuses.verified && s !== c.statuses.releasedToQa);
|
|
9490
9655
|
}
|
|
9491
9656
|
function resolveContract(override) {
|
|
9492
9657
|
if (!override) return DEFAULT_CONTRACT;
|
|
@@ -9932,7 +10097,7 @@ var Tracker = class _Tracker {
|
|
|
9932
10097
|
);
|
|
9933
10098
|
}
|
|
9934
10099
|
this.models = route2.resolved.models;
|
|
9935
|
-
this.contract = resolveContract(route2.contract);
|
|
10100
|
+
this.contract = withReleasedToQaResolved(resolveContract(route2.contract));
|
|
9936
10101
|
this.userAgent = ship.userAgent;
|
|
9937
10102
|
this.shipName = ship.name;
|
|
9938
10103
|
this.stateDir = ship.stateDir;
|
|
@@ -9970,6 +10135,31 @@ var Tracker = class _Tracker {
|
|
|
9970
10135
|
}
|
|
9971
10136
|
return [...seen.values()];
|
|
9972
10137
|
}
|
|
10138
|
+
/**
|
|
10139
|
+
* Every ticket of this route's area at `status`, which need not be an open
|
|
10140
|
+
* one (CREW-2290: the pipeline mode reads tickets released to QA, a status no
|
|
10141
|
+
* lane polls). `extra` narrows it, e.g. to a recent `released_at`.
|
|
10142
|
+
*/
|
|
10143
|
+
async ticketsAtStatus(status2, extra = []) {
|
|
10144
|
+
const conds = [{ columnName: this.contract.columns.status, operator: "EQ", value: status2 }, ...extra];
|
|
10145
|
+
const areaId = this.route.resolved?.areaId;
|
|
10146
|
+
if (areaId) conds.push({ columnName: this.contract.columns.slice, operator: "EQ", value: areaId });
|
|
10147
|
+
return this.listAll(this.models.issues, `tickets at ${status2}`, encodeFilters(conds));
|
|
10148
|
+
}
|
|
10149
|
+
/**
|
|
10150
|
+
* Whether the Issues status field offers `value`. `undefined` when the field
|
|
10151
|
+
* metadata cannot be read, which callers treat as "unknown", not "missing".
|
|
10152
|
+
*/
|
|
10153
|
+
async statusOptionExists(value2) {
|
|
10154
|
+
try {
|
|
10155
|
+
const model = await this.client.dataModels.get(this.models.issues);
|
|
10156
|
+
const field = model.fields.find((f2) => f2.columnName === this.contract.columns.status);
|
|
10157
|
+
const opts = field?.fieldType?.choiceOptions;
|
|
10158
|
+
return Array.isArray(opts) ? opts.some((o) => o.value === value2) : void 0;
|
|
10159
|
+
} catch {
|
|
10160
|
+
return void 0;
|
|
10161
|
+
}
|
|
10162
|
+
}
|
|
9973
10163
|
/**
|
|
9974
10164
|
* How many open tickets match `extra` (a `crew status` number or the sweep
|
|
9975
10165
|
* summary's skipped-by-mode count), from the count endpoint rather than
|
|
@@ -22474,6 +22664,24 @@ async function applyStamp(tracker, plan, version, contract, emit, dryRun, cwd, s
|
|
|
22474
22664
|
}
|
|
22475
22665
|
return stamped;
|
|
22476
22666
|
}
|
|
22667
|
+
async function applyQaStamp(tracker, tickets, version, contract, emit, seat) {
|
|
22668
|
+
let stamped = 0;
|
|
22669
|
+
const priorAssignee = seat ? await priorAssignees(tracker, tickets.map((ticket) => ({ ticket, reason: "released to QA" })), seat, contract, emit) : /* @__PURE__ */ new Map();
|
|
22670
|
+
for (const ticket of tickets) {
|
|
22671
|
+
try {
|
|
22672
|
+
await tracker.updateTicket(ticket.id, {
|
|
22673
|
+
status: contract.statuses.releasedToQa,
|
|
22674
|
+
...priorAssignee.has(ticket.id) ? { [contract.columns.assignee]: priorAssignee.get(ticket.id) ?? null } : {},
|
|
22675
|
+
...version ? { released_version: version } : {}
|
|
22676
|
+
});
|
|
22677
|
+
emit.emit(`stamped ${contract.statuses.releasedToQa}${version ? ` (${version})` : ""}`, { ticket: ticket.issue_id });
|
|
22678
|
+
stamped++;
|
|
22679
|
+
} catch (e) {
|
|
22680
|
+
emit.warn(`could not stamp: ${e.message}`, { ticket: ticket.issue_id });
|
|
22681
|
+
}
|
|
22682
|
+
}
|
|
22683
|
+
return stamped;
|
|
22684
|
+
}
|
|
22477
22685
|
async function applyExternalClosures(tracker, closures, contract, emit, dryRun, cwd) {
|
|
22478
22686
|
if (!closures?.length) return 0;
|
|
22479
22687
|
let stamped = 0;
|
|
@@ -23493,6 +23701,11 @@ async function runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay) {
|
|
|
23493
23701
|
o.emit.emit(`deploy guard lifted by ${real.length} new commit(s) since ${failedAt.slice(0, 8)}: ${real.join("; ")}`);
|
|
23494
23702
|
}
|
|
23495
23703
|
}
|
|
23704
|
+
if (o.repo.release.mode === "pipeline" && o.pipelineInFlight && !o.mergeOnly && !o.dryRun) {
|
|
23705
|
+
const f2 = o.pipelineInFlight;
|
|
23706
|
+
o.emit.emit(scoped(`not releasing \u2014 a pipeline run is in flight: ${f2.why}${f2.url ? ` (${f2.url})` : ""}; verified tickets wait for the next release`), { step: "release" });
|
|
23707
|
+
return { merged: [], deployed: false, stopped: "pipeline run in flight", decision };
|
|
23708
|
+
}
|
|
23496
23709
|
if (o.repo.release.mode === "external") {
|
|
23497
23710
|
o.emit.emit("release.mode is external \u2014 the crew hands work off and does not release");
|
|
23498
23711
|
const reviewingStatus = o.contract.statuses.reviewing;
|
|
@@ -24034,7 +24247,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolationR
|
|
|
24034
24247
|
}
|
|
24035
24248
|
}
|
|
24036
24249
|
}
|
|
24037
|
-
if (o.repo.release.mode === "ci_auto" || o.repo.release.mode === "ci_manual") {
|
|
24250
|
+
if (o.repo.release.mode === "ci_auto" || o.repo.release.mode === "ci_manual" || o.repo.release.mode === "pipeline") {
|
|
24038
24251
|
try {
|
|
24039
24252
|
await o.onBasePushed?.(merged);
|
|
24040
24253
|
} catch (e) {
|
|
@@ -24067,6 +24280,8 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolationR
|
|
|
24067
24280
|
deployed = true;
|
|
24068
24281
|
o.state?.clearDeployFailed();
|
|
24069
24282
|
}
|
|
24283
|
+
} else if (o.repo.release.mode === "pipeline") {
|
|
24284
|
+
o.emit.emit("release.mode is pipeline \u2014 the pipeline builds and deploys to QA; the tickets are marked released to QA once the run passes and QA reports this commit");
|
|
24070
24285
|
} else if (o.repo.release.mode !== "local") {
|
|
24071
24286
|
o.emit.emit(`release.mode is ${o.repo.release.mode} \u2014 CI takes it from here`);
|
|
24072
24287
|
}
|
|
@@ -24138,6 +24353,264 @@ async function runFleetPasses(deps) {
|
|
|
24138
24353
|
}
|
|
24139
24354
|
}
|
|
24140
24355
|
|
|
24356
|
+
// src/pipeline-release.ts
|
|
24357
|
+
var defaultProbe = async (url) => {
|
|
24358
|
+
try {
|
|
24359
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(1e4), redirect: "follow", headers: { accept: "application/json" } });
|
|
24360
|
+
return { status: res.status, body: await res.text() };
|
|
24361
|
+
} catch {
|
|
24362
|
+
return null;
|
|
24363
|
+
}
|
|
24364
|
+
};
|
|
24365
|
+
var sleepFor = (c, ms3) => (c.sleep ?? ((n) => new Promise((r) => setTimeout(r, n))))(ms3);
|
|
24366
|
+
var nowOf = (c) => (c.now ?? Date.now)();
|
|
24367
|
+
var failKey = (c, sha) => `ci_run_failed:${c.scope}/pipeline-${sha.slice(0, 8)}`;
|
|
24368
|
+
var rollbackKey = (c) => `ci_run_failed:${c.scope}/production-rollback`;
|
|
24369
|
+
function commitFromHealth(body) {
|
|
24370
|
+
try {
|
|
24371
|
+
const json2 = JSON.parse(body);
|
|
24372
|
+
const c = typeof json2.commit === "string" ? json2.commit.trim() : "";
|
|
24373
|
+
return /^[0-9a-f]{7,40}$/i.test(c) ? c.toLowerCase() : null;
|
|
24374
|
+
} catch {
|
|
24375
|
+
return null;
|
|
24376
|
+
}
|
|
24377
|
+
}
|
|
24378
|
+
var sameCommit = (a, b) => a.length >= 7 && b.length >= 7 && (a.toLowerCase().startsWith(b.toLowerCase()) || b.toLowerCase().startsWith(a.toLowerCase()));
|
|
24379
|
+
async function readRole(c, r, withReady) {
|
|
24380
|
+
const probe = c.probe ?? defaultProbe;
|
|
24381
|
+
const health = await probe(`${r.url}/api/health-check`);
|
|
24382
|
+
const reading = {
|
|
24383
|
+
role: r.role,
|
|
24384
|
+
url: r.url,
|
|
24385
|
+
reachable: !!health,
|
|
24386
|
+
commit: health && health.status >= 200 && health.status < 300 ? commitFromHealth(health.body) : null
|
|
24387
|
+
};
|
|
24388
|
+
if (withReady) {
|
|
24389
|
+
const ready = await probe(`${r.url}/api/ready`);
|
|
24390
|
+
reading.ready = !!ready && ready.status >= 200 && ready.status < 300;
|
|
24391
|
+
}
|
|
24392
|
+
return reading;
|
|
24393
|
+
}
|
|
24394
|
+
async function qaReports(c, sha) {
|
|
24395
|
+
const { qa, qaTimeoutSeconds, qaIntervalSeconds } = c.settings;
|
|
24396
|
+
const deadline = nowOf(c) + qaTimeoutSeconds * 1e3;
|
|
24397
|
+
let lastWhy = "";
|
|
24398
|
+
for (; ; ) {
|
|
24399
|
+
const readings = await Promise.all(qa.map((r) => readRole(c, r, true)));
|
|
24400
|
+
const problems = readings.flatMap((r) => {
|
|
24401
|
+
if (!r.reachable) return [`${r.role} (${r.url}) is unreachable`];
|
|
24402
|
+
if (!r.ready) return [`${r.role} (${r.url}) is not ready`];
|
|
24403
|
+
if (!r.commit) return [`${r.role} (${r.url}) reports no commit`];
|
|
24404
|
+
return sameCommit(r.commit, sha) ? [] : [`${r.role} (${r.url}) reports ${r.commit.slice(0, 8)}`];
|
|
24405
|
+
});
|
|
24406
|
+
if (problems.length === 0) return { ok: true };
|
|
24407
|
+
lastWhy = problems.join("; ");
|
|
24408
|
+
if (nowOf(c) >= deadline) return { ok: false, why: `QA did not report ${sha.slice(0, 8)} within ${qaTimeoutSeconds}s: ${lastWhy}` };
|
|
24409
|
+
await sleepFor(c, qaIntervalSeconds * 1e3);
|
|
24410
|
+
}
|
|
24411
|
+
}
|
|
24412
|
+
async function reportFailure(c, rel, headline, url) {
|
|
24413
|
+
const label = rel.version ?? rel.sha.slice(0, 8);
|
|
24414
|
+
const key = failKey(c, rel.sha);
|
|
24415
|
+
if (!c.firstReport || c.firstReport(key)) {
|
|
24416
|
+
c.emit.error(`pipeline release ${label}: ${headline}${url ? ` (${url})` : ""} \u2014 its tickets stay verified`, { step: "release", data: { sha: rel.sha, ...url ? { url } : {} } });
|
|
24417
|
+
}
|
|
24418
|
+
await c.attention?.raise({
|
|
24419
|
+
kind: "ci_run_failed",
|
|
24420
|
+
key,
|
|
24421
|
+
message: `${c.scope}: pipeline release ${label} \u2014 ${headline}`,
|
|
24422
|
+
since: (/* @__PURE__ */ new Date()).toISOString(),
|
|
24423
|
+
ci: { ...url ? { url } : {}, blocking: true, repo: c.scope, version: label }
|
|
24424
|
+
});
|
|
24425
|
+
}
|
|
24426
|
+
async function settlePipeline(c, rel, carried, markReleasedToQa) {
|
|
24427
|
+
if (carried.length === 0) return { kind: "idle" };
|
|
24428
|
+
const q2 = { ...c.query, sha: rel.sha, ...rel.tag ? { tag: rel.tag } : {}, pipeline: c.settings.pipeline };
|
|
24429
|
+
const got = await c.provider.runs(q2);
|
|
24430
|
+
if (!got.ok) {
|
|
24431
|
+
c.emit.warn(`pipeline release ${rel.version ?? rel.sha.slice(0, 8)}: cannot read the ${c.provider.name} runs (${got.why}) \u2014 not releasing again until it can be read`, { step: "release" });
|
|
24432
|
+
return { kind: "in-flight", why: `cannot read the ${c.provider.name} runs: ${got.why}` };
|
|
24433
|
+
}
|
|
24434
|
+
const runs = got.runs;
|
|
24435
|
+
const link = runs.find((r) => r.url)?.url;
|
|
24436
|
+
if (runs.length === 0) {
|
|
24437
|
+
const at = c.commitDate(rel.sha);
|
|
24438
|
+
const age = at ? nowOf(c) - new Date(at).getTime() : 0;
|
|
24439
|
+
if (age < c.settings.startTimeoutSeconds * 1e3) {
|
|
24440
|
+
return { kind: "in-flight", why: `no ${c.provider.name} run for ${rel.sha.slice(0, 8)} yet` };
|
|
24441
|
+
}
|
|
24442
|
+
const why = `no ${c.provider.name} run appeared for ${rel.sha.slice(0, 8)} within ${c.settings.startTimeoutSeconds}s of the push`;
|
|
24443
|
+
await reportFailure(c, rel, why);
|
|
24444
|
+
return { kind: "failed", why };
|
|
24445
|
+
}
|
|
24446
|
+
const pending = runs.filter((r) => r.state === "pending");
|
|
24447
|
+
if (pending.length) return { kind: "in-flight", why: `${pending[0].name} is running`, url: pending[0].url || void 0 };
|
|
24448
|
+
const failed = runs.filter((r) => r.state === "failed");
|
|
24449
|
+
if (failed.length) {
|
|
24450
|
+
const details = [];
|
|
24451
|
+
for (const r of failed) details.push(await c.provider.failure(q2, r));
|
|
24452
|
+
const why = details.map(describeCiFailure).join("; ");
|
|
24453
|
+
await reportFailure(c, rel, `run failed: ${why}`, failed.find((r) => r.url)?.url);
|
|
24454
|
+
return { kind: "failed", why, url: failed.find((r) => r.url)?.url };
|
|
24455
|
+
}
|
|
24456
|
+
const qa = await qaReports(c, rel.sha);
|
|
24457
|
+
if (!qa.ok) {
|
|
24458
|
+
await reportFailure(c, rel, qa.why, link);
|
|
24459
|
+
return { kind: "failed", why: qa.why, ...link ? { url: link } : {} };
|
|
24460
|
+
}
|
|
24461
|
+
c.attention?.clear(failKey(c, rel.sha));
|
|
24462
|
+
await markReleasedToQa(carried, rel);
|
|
24463
|
+
c.emit.emit(
|
|
24464
|
+
`pipeline release ${rel.version ?? rel.sha.slice(0, 8)}: QA reports ${rel.sha.slice(0, 8)} \u2014 ${carried.length} ticket(s) released to QA`,
|
|
24465
|
+
{ step: "release", data: { sha: rel.sha, tickets: carried.map(displayKey) } }
|
|
24466
|
+
);
|
|
24467
|
+
return { kind: "released-to-qa", tickets: carried };
|
|
24468
|
+
}
|
|
24469
|
+
async function readProduction(c) {
|
|
24470
|
+
const readings = await Promise.all(c.settings.production.map((r) => readRole(c, r, false)));
|
|
24471
|
+
const bad = readings.filter((r) => !r.commit);
|
|
24472
|
+
if (bad.length) return { kind: "unreadable", why: `${bad.map((r) => `${r.role} (${r.url})`).join(", ")} reports no commit` };
|
|
24473
|
+
const commits = [...new Set(readings.map((r) => r.commit))];
|
|
24474
|
+
if (commits.length > 1 && !commits.every((x) => sameCommit(x, commits[0]))) return { kind: "mixed", commits };
|
|
24475
|
+
return { kind: "commit", sha: commits[0] };
|
|
24476
|
+
}
|
|
24477
|
+
var commitOf = (t) => typeof t.commit_sha === "string" && t.commit_sha ? t.commit_sha : null;
|
|
24478
|
+
async function watchProduction(c, ops) {
|
|
24479
|
+
const reading = await readProduction(c);
|
|
24480
|
+
const none = { reading, deployed: [], waiting: [], flagged: [] };
|
|
24481
|
+
if (reading.kind === "unreadable") {
|
|
24482
|
+
if (!c.firstReport || c.firstReport(`${c.scope}:production-unreadable`)) {
|
|
24483
|
+
c.emit.warn(`production health-check: ${reading.why} \u2014 not changing any ticket`, { step: "release" });
|
|
24484
|
+
}
|
|
24485
|
+
return none;
|
|
24486
|
+
}
|
|
24487
|
+
if (reading.kind === "mixed") {
|
|
24488
|
+
c.emit.emit(`production roles report different commits (${reading.commits.map((x) => x.slice(0, 8)).join(", ")}) \u2014 a rollout is in progress; waiting`, { step: "release" });
|
|
24489
|
+
return none;
|
|
24490
|
+
}
|
|
24491
|
+
const prod = reading.sha;
|
|
24492
|
+
const contained = (t) => {
|
|
24493
|
+
const sha = commitOf(t);
|
|
24494
|
+
return !!sha && (sameCommit(sha, prod) || c.isAncestor(sha, prod));
|
|
24495
|
+
};
|
|
24496
|
+
const queued = await ops.releasedToQa();
|
|
24497
|
+
const deployed = queued.filter(contained);
|
|
24498
|
+
const waiting = queued.filter((t) => !contained(t));
|
|
24499
|
+
if (deployed.length) {
|
|
24500
|
+
await ops.markDeployed(deployed, prod);
|
|
24501
|
+
c.emit.emit(`production reports ${prod.slice(0, 8)} \u2014 ${deployed.length} ticket(s) deployed: ${deployed.map(displayKey).join(", ")}`, { step: "release", data: { sha: prod } });
|
|
24502
|
+
}
|
|
24503
|
+
let flagged = [];
|
|
24504
|
+
if (ops.lastSeen() !== prod) {
|
|
24505
|
+
flagged = (await ops.recentlyDeployed()).filter((t) => commitOf(t) && !contained(t));
|
|
24506
|
+
if (flagged.length) {
|
|
24507
|
+
const names = flagged.map(displayKey).join(", ");
|
|
24508
|
+
c.emit.warn(`production now reports ${prod.slice(0, 8)}, which does not contain the work of ${names} \u2014 they stay deployed; a person decides`, { step: "release" });
|
|
24509
|
+
await c.attention?.raise({
|
|
24510
|
+
kind: "ci_run_failed",
|
|
24511
|
+
key: rollbackKey(c),
|
|
24512
|
+
message: `${c.scope}: production reports ${prod.slice(0, 8)}, which does not contain the work of ${names} (already deployed, left as they are)`,
|
|
24513
|
+
since: (/* @__PURE__ */ new Date()).toISOString(),
|
|
24514
|
+
ci: { blocking: false, repo: c.scope, version: prod.slice(0, 8) }
|
|
24515
|
+
});
|
|
24516
|
+
} else {
|
|
24517
|
+
c.attention?.clear(rollbackKey(c));
|
|
24518
|
+
}
|
|
24519
|
+
ops.noteSeen(prod);
|
|
24520
|
+
}
|
|
24521
|
+
return { reading, deployed, waiting, flagged };
|
|
24522
|
+
}
|
|
24523
|
+
async function sweepPipeline(c, latest, verified, ops) {
|
|
24524
|
+
let state = { kind: "idle" };
|
|
24525
|
+
if (latest) {
|
|
24526
|
+
const carried = verified.filter((t) => {
|
|
24527
|
+
const sha = commitOf(t);
|
|
24528
|
+
return !!sha && (sameCommit(sha, latest.sha) || c.isAncestor(sha, latest.sha));
|
|
24529
|
+
});
|
|
24530
|
+
state = await settlePipeline(c, latest, carried, ops.markReleasedToQa);
|
|
24531
|
+
}
|
|
24532
|
+
const production = await watchProduction(c, ops);
|
|
24533
|
+
return { state, production };
|
|
24534
|
+
}
|
|
24535
|
+
|
|
24536
|
+
// src/pipeline-sweep.ts
|
|
24537
|
+
var ROLLBACK_LOOKBACK_DAYS = 30;
|
|
24538
|
+
function latestPipelineRelease(dir, repo) {
|
|
24539
|
+
const ref = `${repo.branch.remote}/${repo.branch.base}`;
|
|
24540
|
+
const tag = latestReleaseTag(dir, repo.release.tagPattern ?? "v*", ref);
|
|
24541
|
+
if (tag) {
|
|
24542
|
+
const sha2 = tagCommit(dir, tag);
|
|
24543
|
+
return sha2 ? { sha: sha2, tag, version: tag.replace(/^v/, "") } : null;
|
|
24544
|
+
}
|
|
24545
|
+
const sha = resolve3(dir, ref);
|
|
24546
|
+
return sha ? { sha } : null;
|
|
24547
|
+
}
|
|
24548
|
+
async function missingStatusProblem(tracker) {
|
|
24549
|
+
const needs = tracker.contract.statuses.releasedToQa;
|
|
24550
|
+
if (await tracker.statusOptionExists(needs) !== false) return null;
|
|
24551
|
+
return `the tracker's status list has no "${needs}" status, which release.mode "pipeline" needs for tickets released to QA \u2014 a person adds it to the Issues app (docs/REPO_SPEC.md, release.pipeline)`;
|
|
24552
|
+
}
|
|
24553
|
+
async function sweepPipelineRoute(i) {
|
|
24554
|
+
const { repo, tracker, emit, scope } = i;
|
|
24555
|
+
const settings = repo.release.pipeline;
|
|
24556
|
+
if (!settings) return { stop: `release.mode "pipeline" has no release.pipeline settings in ${repo.file}` };
|
|
24557
|
+
if (!isPipelineCiProvider(repo.release.ci.provider)) {
|
|
24558
|
+
return { stop: `release.mode "pipeline" reads its runs from release.ci.provider "buildkite"; this repo names "${repo.release.ci.provider}"` };
|
|
24559
|
+
}
|
|
24560
|
+
const missing = await missingStatusProblem(tracker);
|
|
24561
|
+
if (missing) {
|
|
24562
|
+
emit.error(`${scope}: ${missing}`, { step: "release" });
|
|
24563
|
+
return { stop: missing };
|
|
24564
|
+
}
|
|
24565
|
+
const provider = pipelineProviderFor("buildkite", {
|
|
24566
|
+
token: (h) => {
|
|
24567
|
+
try {
|
|
24568
|
+
return readForgeToken(i.ship.forges, h, i.ship.stateDir);
|
|
24569
|
+
} catch {
|
|
24570
|
+
return null;
|
|
24571
|
+
}
|
|
24572
|
+
}
|
|
24573
|
+
});
|
|
24574
|
+
if (!provider) return { stop: "no buildkite provider" };
|
|
24575
|
+
const remote = ciRemoteOf(gitOk(i.dir, ["remote", "get-url", repo.branch.remote])) ?? { host: BUILDKITE_HOST, remote: scope };
|
|
24576
|
+
fetchRemote(i.dir, repo.branch.remote);
|
|
24577
|
+
const verifiedStatus = tracker.contract.statuses.verified;
|
|
24578
|
+
const verified = (await i.repoTickets()).filter((t) => t.status === verifiedStatus);
|
|
24579
|
+
const rel = i.state.release(i.scope);
|
|
24580
|
+
const ctx = {
|
|
24581
|
+
scope,
|
|
24582
|
+
settings,
|
|
24583
|
+
provider,
|
|
24584
|
+
query: { host: remote.host, remote: remote.remote, base: repo.branch.base },
|
|
24585
|
+
contract: tracker.contract,
|
|
24586
|
+
emit,
|
|
24587
|
+
attention: {
|
|
24588
|
+
raise: (item) => raiseShipAttention({ state: i.state, emit, route: i.route, ship: i.ship }, item),
|
|
24589
|
+
clear: (key) => clearShipAttention(i.state, key)
|
|
24590
|
+
},
|
|
24591
|
+
isAncestor: (a, b) => isAncestor(i.dir, a, b),
|
|
24592
|
+
commitDate: (sha) => commitDate(i.dir, sha),
|
|
24593
|
+
firstReport: i.firstReport
|
|
24594
|
+
};
|
|
24595
|
+
const { state } = await sweepPipeline(ctx, latestPipelineRelease(i.dir, repo), verified, {
|
|
24596
|
+
markReleasedToQa: async (tickets, r) => {
|
|
24597
|
+
await applyQaStamp(tracker, tickets, r.version, tracker.contract, emit, i.seat);
|
|
24598
|
+
},
|
|
24599
|
+
lastSeen: () => rel.pipelineProductionSeen(),
|
|
24600
|
+
noteSeen: (sha) => rel.notePipelineProductionSeen(sha),
|
|
24601
|
+
releasedToQa: () => tracker.ticketsAtStatus(tracker.contract.statuses.releasedToQa),
|
|
24602
|
+
recentlyDeployed: () => tracker.ticketsAtStatus(tracker.contract.statuses.deployed, [{
|
|
24603
|
+
columnName: "released_at",
|
|
24604
|
+
operator: "GTE",
|
|
24605
|
+
value: new Date(Date.now() - ROLLBACK_LOOKBACK_DAYS * 864e5).toISOString()
|
|
24606
|
+
}]),
|
|
24607
|
+
markDeployed: async (tickets) => {
|
|
24608
|
+
await applyStamp(tracker, tickets.map((ticket) => ({ ticket, reason: "production reports its commit" })), void 0, tracker.contract, emit, false, i.dir, i.seat);
|
|
24609
|
+
}
|
|
24610
|
+
});
|
|
24611
|
+
return state.kind === "in-flight" ? { inFlight: { why: state.why, ...state.url ? { url: state.url } : {} }, state } : { state };
|
|
24612
|
+
}
|
|
24613
|
+
|
|
24141
24614
|
// src/failure-alert.ts
|
|
24142
24615
|
var FAILURE_ALERT_MARKER = calloutHeader("CAUTION", "Failure Alert");
|
|
24143
24616
|
function findOpenFailureAlert(tickets, headline) {
|
|
@@ -30251,7 +30724,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
30251
30724
|
import { existsSync as existsSync58, readdirSync as readdirSync18, statSync as statSync18 } from "fs";
|
|
30252
30725
|
import { join as join62 } from "path";
|
|
30253
30726
|
function builtVersion() {
|
|
30254
|
-
return true ? "0.
|
|
30727
|
+
return true ? "0.172.0" : null;
|
|
30255
30728
|
}
|
|
30256
30729
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
30257
30730
|
function newestMtime(path) {
|
|
@@ -33926,6 +34399,27 @@ ${changed2.map((c) => ` - ${c}
|
|
|
33926
34399
|
}
|
|
33927
34400
|
if (releaseIdentity.kind === "ship") remit.warn(`release writes as the ship, not its own agent: ${releaseIdentity.reason}`, { step: "release" });
|
|
33928
34401
|
const tracker = new Tracker(c, cfg.ship, { apiKey: releaseIdentity.apiKey });
|
|
34402
|
+
let pipelineInFlight;
|
|
34403
|
+
if (repo.release.mode === "pipeline" && !dryRun) {
|
|
34404
|
+
const swept = await sweepPipelineRoute({
|
|
34405
|
+
route: c,
|
|
34406
|
+
ship: cfg.ship,
|
|
34407
|
+
scope,
|
|
34408
|
+
dir: target.dir,
|
|
34409
|
+
repo,
|
|
34410
|
+
tracker,
|
|
34411
|
+
state,
|
|
34412
|
+
emit: remit,
|
|
34413
|
+
seat: releaseSeat(c),
|
|
34414
|
+
repoTickets: async () => ticketsByRepo(c, await tracker.openTickets()).byRepo.get(target.name) ?? [],
|
|
34415
|
+
firstReport: (k) => firstReport(`${scope}:pipeline:${k}`)
|
|
34416
|
+
});
|
|
34417
|
+
if ("stop" in swept) {
|
|
34418
|
+
remit.warn(`${scope}: not releasing \u2014 ${swept.stop}`, { step: "release" });
|
|
34419
|
+
return { scope, tests: "skipped", outcome: "skipped", detail: swept.stop };
|
|
34420
|
+
}
|
|
34421
|
+
pipelineInFlight = swept.inFlight;
|
|
34422
|
+
}
|
|
33929
34423
|
if (!dryRun) {
|
|
33930
34424
|
const force2 = command === "deploy" || flag("force");
|
|
33931
34425
|
let seen = precheckTickets.get(c.route);
|
|
@@ -33984,7 +34478,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
33984
34478
|
base: repo.branch.base,
|
|
33985
34479
|
...remoteBase ? { ref: `${repo.branch.remote}/${repo.branch.base}`, guard: false } : {}
|
|
33986
34480
|
});
|
|
33987
|
-
const unstamped = planReleasedBranches(
|
|
34481
|
+
const unstamped = repo.release.mode === "pipeline" ? 0 : planReleasedBranches(
|
|
33988
34482
|
target.dir,
|
|
33989
34483
|
pre,
|
|
33990
34484
|
tracker.contract,
|
|
@@ -34142,6 +34636,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
34142
34636
|
ticket.updated_at = (await tracker.updateTicket(ticket.id, { [tracker.contract.columns.assignee]: claimed.get(ticket.id) ?? null })).updated_at;
|
|
34143
34637
|
claimed.delete(ticket.id);
|
|
34144
34638
|
},
|
|
34639
|
+
...pipelineInFlight ? { pipelineInFlight } : {},
|
|
34145
34640
|
onBasePushed: async (merged) => {
|
|
34146
34641
|
remit.enter("reconcile");
|
|
34147
34642
|
await applyMergeStamp(
|
|
@@ -34167,7 +34662,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
34167
34662
|
});
|
|
34168
34663
|
primaryRebuild = outcome.primaryRebuild;
|
|
34169
34664
|
const summary = summarizeOutcome(outcome, scope, !!repo.hooks.test && !flag("skip-tests"));
|
|
34170
|
-
if (outcome.deployed || outcome.confirmed || outcome.alreadyLive || outcome.integrated) {
|
|
34665
|
+
if (repo.release.mode !== "pipeline" && (outcome.deployed || outcome.confirmed || outcome.alreadyLive || outcome.integrated)) {
|
|
34171
34666
|
remit.enter("reconcile");
|
|
34172
34667
|
const plan = planStamp(
|
|
34173
34668
|
target.dir,
|
|
@@ -34187,6 +34682,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
34187
34682
|
remit.emit(`nothing stamped \u2014 ${outcome.stopped}`);
|
|
34188
34683
|
}
|
|
34189
34684
|
for (const m of outcome.decision.merges) {
|
|
34685
|
+
if (repo.release.mode === "pipeline") break;
|
|
34190
34686
|
if (m.skipReason !== "already-released" || !m.mergedSha) continue;
|
|
34191
34687
|
const tag = firstReleaseTagContaining(target.dir, m.mergedSha, repo.release.tagPattern ?? "v*");
|
|
34192
34688
|
if (!tag) continue;
|
|
@@ -34202,7 +34698,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
34202
34698
|
releaseSeat(c)
|
|
34203
34699
|
);
|
|
34204
34700
|
}
|
|
34205
|
-
for (const r of planReleasedBranches(
|
|
34701
|
+
for (const r of repo.release.mode === "pipeline" ? [] : planReleasedBranches(
|
|
34206
34702
|
target.dir,
|
|
34207
34703
|
tickets,
|
|
34208
34704
|
tracker.contract,
|
|
@@ -24829,6 +24829,7 @@ var RELEASE_KEYS = /* @__PURE__ */ new Set([
|
|
|
24829
24829
|
"ship",
|
|
24830
24830
|
"ci",
|
|
24831
24831
|
"verify",
|
|
24832
|
+
"pipeline",
|
|
24832
24833
|
"isolateFailures",
|
|
24833
24834
|
"rightOfWayMinutes",
|
|
24834
24835
|
"rebuildPrimary",
|
|
@@ -24840,6 +24841,7 @@ var RELEASE_KEYS = /* @__PURE__ */ new Set([
|
|
|
24840
24841
|
]);
|
|
24841
24842
|
var VERSIONINGS = ["auto", "none"];
|
|
24842
24843
|
var CI_KEYS = /* @__PURE__ */ new Set(["provider", "ref"]);
|
|
24844
|
+
var PIPELINE_KEYS = /* @__PURE__ */ new Set(["qa", "production", "pipeline", "qaTimeoutSeconds", "qaIntervalSeconds", "startTimeoutSeconds"]);
|
|
24843
24845
|
var VERIFY_KEYS = /* @__PURE__ */ new Set(["match", "timeoutSeconds", "intervalSeconds"]);
|
|
24844
24846
|
var ISOLATE_KEYS = /* @__PURE__ */ new Set(["maxCandidates"]);
|
|
24845
24847
|
function parseRebuildPrimary(raw, fail2) {
|
|
@@ -24860,7 +24862,19 @@ function parseIsolateMax(raw, where, fail2) {
|
|
|
24860
24862
|
return n;
|
|
24861
24863
|
}
|
|
24862
24864
|
var MATCHES = ["commit", "version"];
|
|
24863
|
-
var MODES = ["local", "integrate", "ci_manual", "ci_auto", "external"];
|
|
24865
|
+
var MODES = ["local", "integrate", "ci_manual", "ci_auto", "external", "pipeline"];
|
|
24866
|
+
function parsePipelineRoles(raw, where, fail2) {
|
|
24867
|
+
const url2 = (v, at) => {
|
|
24868
|
+
if (typeof v !== "string" || !/^https?:\/\/[^\s/]+/i.test(v.trim())) throw fail2(`${at} must be an http(s) address (got "${String(v)}")`);
|
|
24869
|
+
return v.trim().replace(/\/+$/, "");
|
|
24870
|
+
};
|
|
24871
|
+
if (typeof raw === "string") return [{ role: "app", url: url2(raw, where) }];
|
|
24872
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
24873
|
+
const roles = Object.entries(raw).map(([role, v]) => ({ role, url: url2(v, `${where}.${role}`) }));
|
|
24874
|
+
if (roles.length) return roles;
|
|
24875
|
+
}
|
|
24876
|
+
throw fail2(`${where} must be an address, or a map of role to address`);
|
|
24877
|
+
}
|
|
24864
24878
|
var PROVIDERS = ["github", "buildkite", "other", "none"];
|
|
24865
24879
|
function findRepoConfig(dir) {
|
|
24866
24880
|
for (const name of REPO_CONFIG_FILENAMES) {
|
|
@@ -25059,7 +25073,40 @@ function parseRepoConfig(text, file, opts = {}) {
|
|
|
25059
25073
|
`${file}: release.mode "external" means the crew does not release, but hooks.deploy is defined \u2014 remove one, or use ci_manual/ci_auto if the crew should be involved`
|
|
25060
25074
|
);
|
|
25061
25075
|
}
|
|
25062
|
-
if (mode
|
|
25076
|
+
if (mode === "pipeline" && hooks.deploy) {
|
|
25077
|
+
throw new RepoConfigError(
|
|
25078
|
+
`${file}: release.mode "pipeline" means a pipeline deploys, but hooks.deploy is defined \u2014 the crew never runs a deploy script in this mode. Remove it`
|
|
25079
|
+
);
|
|
25080
|
+
}
|
|
25081
|
+
rejectUnknown(raw.release?.pipeline, PIPELINE_KEYS, "release.pipeline", file, newer);
|
|
25082
|
+
let pipeline;
|
|
25083
|
+
if (raw.release?.pipeline !== void 0 && raw.release?.pipeline !== null) {
|
|
25084
|
+
const pr = raw.release.pipeline;
|
|
25085
|
+
const fail2 = (m) => new RepoConfigError(`${file}: ${m}`);
|
|
25086
|
+
if (typeof pr !== "object" || Array.isArray(pr)) throw fail2("release.pipeline must be a map");
|
|
25087
|
+
if (typeof pr.pipeline !== "string" || !pr.pipeline.trim()) throw fail2("release.pipeline.pipeline must name the CI pipeline (for Buildkite, org/slug)");
|
|
25088
|
+
const pnum = (v, key, dflt) => {
|
|
25089
|
+
if (v === void 0 || v === null) return dflt;
|
|
25090
|
+
const n = Number(v);
|
|
25091
|
+
if (!Number.isFinite(n) || n <= 0) throw fail2(`release.pipeline.${key} must be a positive number (got "${String(v)}")`);
|
|
25092
|
+
return n;
|
|
25093
|
+
};
|
|
25094
|
+
pipeline = {
|
|
25095
|
+
qa: parsePipelineRoles(pr.qa, "release.pipeline.qa", fail2),
|
|
25096
|
+
production: parsePipelineRoles(pr.production, "release.pipeline.production", fail2),
|
|
25097
|
+
pipeline: pr.pipeline.trim(),
|
|
25098
|
+
qaTimeoutSeconds: pnum(pr.qaTimeoutSeconds, "qaTimeoutSeconds", 600),
|
|
25099
|
+
qaIntervalSeconds: pnum(pr.qaIntervalSeconds, "qaIntervalSeconds", 15),
|
|
25100
|
+
startTimeoutSeconds: pnum(pr.startTimeoutSeconds, "startTimeoutSeconds", 1800)
|
|
25101
|
+
};
|
|
25102
|
+
}
|
|
25103
|
+
if (mode === "pipeline" && !pipeline) {
|
|
25104
|
+
throw new RepoConfigError(`${file}: release.mode "pipeline" needs release.pipeline (qa, production and pipeline)`);
|
|
25105
|
+
}
|
|
25106
|
+
if (mode !== "pipeline" && pipeline) {
|
|
25107
|
+
throw new RepoConfigError(`${file}: release.pipeline only applies to release.mode "pipeline" (got "${mode}")`);
|
|
25108
|
+
}
|
|
25109
|
+
if (mode !== "local" && mode !== "external" && mode !== "integrate" && mode !== "pipeline" && !hooks.released) {
|
|
25063
25110
|
throw new RepoConfigError(
|
|
25064
25111
|
`${file}: release.mode "${mode}" needs a hooks.released \u2014 the crew cannot observe a release it did not perform without one`
|
|
25065
25112
|
);
|
|
@@ -25177,6 +25224,7 @@ function parseRepoConfig(text, file, opts = {}) {
|
|
|
25177
25224
|
ship,
|
|
25178
25225
|
ci: { provider, ref: raw.release?.ci?.ref ? String(raw.release.ci.ref) : void 0 },
|
|
25179
25226
|
verify,
|
|
25227
|
+
...pipeline ? { pipeline } : {},
|
|
25180
25228
|
isolateFailures: isolateMax === void 0 ? void 0 : { maxCandidates: isolateMax },
|
|
25181
25229
|
rightOfWayMinutes: rightOfWay,
|
|
25182
25230
|
...parallelGatesRaw ? { parallelGates: true } : {},
|
|
@@ -111,6 +111,7 @@ Ask once, in a single message, with your best reading of the evidence beside eac
|
|
|
111
111
|
- `ci_manual`: Crew triggers CI and waits for it. Needs `hooks.released`.
|
|
112
112
|
- `local`: Crew runs a deploy command itself after merging and pushing, and the command's exit status is the result. Needs `hooks.deploy`. Right when a person ships by running a command today, including one that dispatches a pipeline and waits for it.
|
|
113
113
|
- `external`: Crew does not merge at all. A person or another tool merges pull requests. Needs `hooks.merged`; `hooks.pr` opens the pull request.
|
|
114
|
+
- `pipeline`: pushing the release commit starts a pipeline that deploys to a QA environment by itself, and a person releases production from the same pipeline. Crew pushes, follows the run, marks tickets released to QA, and marks them deployed when production reports their commit. Needs `release.pipeline` (QA and production addresses, the pipeline) and the Buildkite provider; no `hooks.deploy` or `hooks.released`. Do not propose it unless the repo's own instructions describe this two-step release.
|
|
114
115
|
For `local`, also confirm the exact command I run to ship.
|
|
115
116
|
2. **What single command prints what is live right now**, as a version or a commit sha? A registry query and a health endpoint are the usual answers. The `ci_*` modes cannot work without it, so ask whenever one of them is likely; for the other modes it is optional and not worth a question. It becomes `hooks.released`, with `release.verify.match` set to `version` or `commit` to match, and `release.verify.timeoutSeconds` sized to how long the release pipeline takes.
|
|
116
117
|
3. **Should Crew set versions**, if the evidence was mixed? If a lockfile or second file records the version, confirm it has to stay in step.
|
|
@@ -194,7 +195,7 @@ Release (keys under `release`):
|
|
|
194
195
|
|
|
195
196
|
| Key | Values and meaning |
|
|
196
197
|
| --- | --- |
|
|
197
|
-
| `mode` | `local` (default), `integrate`, `ci_manual`, `ci_auto`, `external
|
|
198
|
+
| `mode` | `local` (default), `integrate`, `ci_manual`, `ci_auto`, `external`, `pipeline` (needs `release.pipeline`: `qa`, `production`, `pipeline`). |
|
|
198
199
|
| `versioning` | `auto` (default) or `none`. |
|
|
199
200
|
| `versionFiles` | JSON files with a string `version` field that Crew rewrites. Default `[package.json]`. A plain-text file is refused. |
|
|
200
201
|
| `changelog` | Path of the changelog Crew writes. Default `CHANGELOG.md`. `false` for none. |
|
package/package.json
CHANGED