@the-vibe-company/armada 0.2.57 → 0.2.59
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 +3 -0
- package/dist/armada.js +136 -99
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -693,6 +693,7 @@ Declare optional `[[deploy.target]]` entries in `armada.toml`:
|
|
|
693
693
|
[[deploy.target]]
|
|
694
694
|
name = "api"
|
|
695
695
|
branch = "main" # omit for the merged PR's base branch
|
|
696
|
+
paths = ["cmd/**", "internal/**"] # optional repository-relative globs
|
|
696
697
|
# Exactly one source of the live commit:
|
|
697
698
|
github_environment = "production"
|
|
698
699
|
# live_sha_command = "curl -fsS https://example.test/version"
|
|
@@ -703,4 +704,6 @@ pause_on_failure = true
|
|
|
703
704
|
|
|
704
705
|
`armada merge` starts a background deploy watcher and prints `Watching the deploy of <sha> to <target>`. Deployment failures, smoke failures and timeouts create one inbox item and a shared deploy hold for that target. A later healthy deploy clears the failures it covers. Use `--through-hold "<why>"` to merge the repair. `pause_on_failure = false` keeps the inbox warning without pausing merges.
|
|
705
706
|
|
|
707
|
+
With `paths`, a merge that touches none of the globs prints one skip line and starts no watcher or deploy hold. Globs match repository-relative paths, including dot files. Missing or incomplete changed-file coverage (including renames whose original path is unknown) keeps the watcher. Omit `paths` to watch every merge on the target's branch. For an affected target, the live commit must equal the merged commit or be a verified descendant; smoke then runs as usual.
|
|
708
|
+
|
|
706
709
|
`armada deploy status` shows each target's latest state and any open deploy hold; `armada status` includes deploy states. Commands run at the repository root with `ARMADA_DEPLOY_SHA` and `ARMADA_DEPLOY_TARGET`, bounded to one minute and the deploy deadline. Declare `armada run -- <command>` when a command needs project secrets. Watchers share smoke results for the same live SHA. If background startup fails, the merge prints a command to run in a persistent terminal. See the [deployment runbook](docs/runbook.md#check-deployments-after-merges) for recovery and logs.
|
package/dist/armada.js
CHANGED
|
@@ -1491,7 +1491,7 @@ import { isatty } from "node:tty";
|
|
|
1491
1491
|
import { basename as basename4, dirname as dirname13, join as join11, resolve as resolve7 } from "node:path";
|
|
1492
1492
|
|
|
1493
1493
|
// ../core/src/merge.ts
|
|
1494
|
-
var
|
|
1494
|
+
var import_picomatch2 = __toESM(require_picomatch2(), 1);
|
|
1495
1495
|
|
|
1496
1496
|
// ../core/src/http.ts
|
|
1497
1497
|
class HttpRequestError extends Error {
|
|
@@ -2023,6 +2023,115 @@ async function waitForApproval({ api, code, sleep, now }) {
|
|
|
2023
2023
|
throw new ArmadaApiError("the code expired before it was approved", LOGIN_NEXT);
|
|
2024
2024
|
}
|
|
2025
2025
|
|
|
2026
|
+
// ../core/src/deploy.ts
|
|
2027
|
+
var import_picomatch = __toESM(require_picomatch2(), 1);
|
|
2028
|
+
function selectDeployTargets(targets, branch, coverage) {
|
|
2029
|
+
const selected = [];
|
|
2030
|
+
const skipped = [];
|
|
2031
|
+
for (const target of targets) {
|
|
2032
|
+
if (target.branch !== null && target.branch !== branch)
|
|
2033
|
+
continue;
|
|
2034
|
+
const matches = target.paths ? import_picomatch.default(target.paths, { dot: true }) : null;
|
|
2035
|
+
if (matches && coverage.files !== null && coverage.filesComplete && !coverage.files.some((file) => matches(file)))
|
|
2036
|
+
skipped.push(target.name);
|
|
2037
|
+
else
|
|
2038
|
+
selected.push(target.name);
|
|
2039
|
+
}
|
|
2040
|
+
return { targets: selected, skipped };
|
|
2041
|
+
}
|
|
2042
|
+
function deployDetail(output) {
|
|
2043
|
+
const lines = output.trim().split(`
|
|
2044
|
+
`).slice(-30).join(`
|
|
2045
|
+
`);
|
|
2046
|
+
let size = 0;
|
|
2047
|
+
const tail = [];
|
|
2048
|
+
for (const ch of Array.from(lines).reverse()) {
|
|
2049
|
+
size += new TextEncoder().encode(ch).length;
|
|
2050
|
+
if (size > 4096)
|
|
2051
|
+
break;
|
|
2052
|
+
tail.push(ch);
|
|
2053
|
+
}
|
|
2054
|
+
return tail.reverse().join("");
|
|
2055
|
+
}
|
|
2056
|
+
async function watchDeploy(o) {
|
|
2057
|
+
const deadline = (o.startedAt ?? o.now()).getTime() + o.target.timeoutMinutes * 60000;
|
|
2058
|
+
let detail = "waiting for the merge commit";
|
|
2059
|
+
let liveSha = null;
|
|
2060
|
+
const record = (state) => o.record({
|
|
2061
|
+
target: o.target.name,
|
|
2062
|
+
sha: o.sha,
|
|
2063
|
+
state,
|
|
2064
|
+
detail: deployDetail(detail),
|
|
2065
|
+
pauseOnFailure: o.target.pauseOnFailure,
|
|
2066
|
+
liveSha
|
|
2067
|
+
});
|
|
2068
|
+
await record("waiting");
|
|
2069
|
+
while (o.now().getTime() < deadline) {
|
|
2070
|
+
if (o.healthy) {
|
|
2071
|
+
let verified = null;
|
|
2072
|
+
try {
|
|
2073
|
+
verified = await o.healthy();
|
|
2074
|
+
} catch {
|
|
2075
|
+
detail = "could not read shared deploy state; retrying";
|
|
2076
|
+
}
|
|
2077
|
+
if (verified) {
|
|
2078
|
+
liveSha = verified.sha;
|
|
2079
|
+
detail = verified.detail;
|
|
2080
|
+
await record("healthy");
|
|
2081
|
+
return "healthy";
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
let live = null;
|
|
2085
|
+
try {
|
|
2086
|
+
live = await o.live(deadline - o.now().getTime());
|
|
2087
|
+
} catch {
|
|
2088
|
+
detail = "could not read the deploy status; retrying";
|
|
2089
|
+
}
|
|
2090
|
+
if (live) {
|
|
2091
|
+
detail = live.detail;
|
|
2092
|
+
liveSha = live.sha;
|
|
2093
|
+
let includes = live.sha === o.sha;
|
|
2094
|
+
if (live.sha && !includes) {
|
|
2095
|
+
try {
|
|
2096
|
+
includes = await o.includes(o.sha, live.sha);
|
|
2097
|
+
} catch {
|
|
2098
|
+
detail = `${detail}
|
|
2099
|
+
could not compare the live commit; retrying`;
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
if (includes && (live.state === "failure" || live.state === "error")) {
|
|
2103
|
+
await record("deploy-failed");
|
|
2104
|
+
return "deploy-failed";
|
|
2105
|
+
}
|
|
2106
|
+
if (includes && live.sha && live.state === "success" && o.now().getTime() < deadline) {
|
|
2107
|
+
await record("live");
|
|
2108
|
+
let result;
|
|
2109
|
+
try {
|
|
2110
|
+
result = await o.smoke(live.sha, deadline - o.now().getTime());
|
|
2111
|
+
} catch {
|
|
2112
|
+
result = { ok: null, detail: "could not read or record shared smoke state; retrying" };
|
|
2113
|
+
}
|
|
2114
|
+
detail = result.detail;
|
|
2115
|
+
if (result.ok !== null) {
|
|
2116
|
+
const state = result.ok ? "healthy" : "smoke-failed";
|
|
2117
|
+
await record(state);
|
|
2118
|
+
return state;
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
await record("waiting");
|
|
2123
|
+
await o.sleep(Math.min(30000, Math.max(0, deadline - o.now().getTime())));
|
|
2124
|
+
}
|
|
2125
|
+
detail = `deploy deadline reached
|
|
2126
|
+
${detail}`;
|
|
2127
|
+
await record("timeout");
|
|
2128
|
+
return "timeout";
|
|
2129
|
+
}
|
|
2130
|
+
function deployLine(row, now) {
|
|
2131
|
+
const age = Math.max(0, Math.floor((now.getTime() - Date.parse(row.updatedAt)) / 60000));
|
|
2132
|
+
return `${row.target}: ${row.state} ${row.sha}${row.state === "waiting" || row.state === "live" ? ` — watching since ${row.startedAt.slice(11, 16)}, no news for ${age} min${age >= 2 ? "; watcher may have stopped" : ""}` : ""}`;
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2026
2135
|
// ../../node_modules/.bun/smol-toml@1.9.0/node_modules/smol-toml/dist/error.js
|
|
2027
2136
|
/*!
|
|
2028
2137
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
@@ -3799,7 +3908,16 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
3799
3908
|
known.push([
|
|
3800
3909
|
path,
|
|
3801
3910
|
row,
|
|
3802
|
-
[
|
|
3911
|
+
[
|
|
3912
|
+
"name",
|
|
3913
|
+
"branch",
|
|
3914
|
+
"paths",
|
|
3915
|
+
"github_environment",
|
|
3916
|
+
"live_sha_command",
|
|
3917
|
+
"smoke",
|
|
3918
|
+
"timeout_minutes",
|
|
3919
|
+
"pause_on_failure"
|
|
3920
|
+
]
|
|
3803
3921
|
]);
|
|
3804
3922
|
const name = str(row, path, "name");
|
|
3805
3923
|
if (name.length > 200)
|
|
@@ -3816,7 +3934,13 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
3816
3934
|
problems.push(`"${path}.timeout_minutes" must be from 1 to 120`);
|
|
3817
3935
|
if (row.pause_on_failure !== undefined && typeof row.pause_on_failure !== "boolean")
|
|
3818
3936
|
problems.push(`"${path}.pause_on_failure" must be true or false`);
|
|
3937
|
+
if (row.paths !== undefined) {
|
|
3938
|
+
const problem = pathsProblem(row.paths);
|
|
3939
|
+
if (problem || Array.isArray(row.paths) && !row.paths.length)
|
|
3940
|
+
problems.push(`"${path}.paths": ${problem ?? "must not be empty"}`);
|
|
3941
|
+
}
|
|
3819
3942
|
deployTargets.push({
|
|
3943
|
+
...Array.isArray(row.paths) ? { paths: row.paths } : {},
|
|
3820
3944
|
name,
|
|
3821
3945
|
branch: optional("branch"),
|
|
3822
3946
|
githubEnvironment,
|
|
@@ -4174,6 +4298,7 @@ repository = ${q(p.repository)}
|
|
|
4174
4298
|
# [[deploy.target]]
|
|
4175
4299
|
# name = "api"
|
|
4176
4300
|
# branch = "main" # omit to watch any merged base branch
|
|
4301
|
+
# paths = ["cmd/**", "internal/**"] # optional: only watch merges touching these globs
|
|
4177
4302
|
# github_environment = "production"
|
|
4178
4303
|
## Alternative to github_environment (choose exactly one live source):
|
|
4179
4304
|
## live_sha_command = "curl -fsS https://example.test/version"
|
|
@@ -7568,7 +7693,7 @@ function workersToTell(merged, workers, notifyPaths, coordinatorName) {
|
|
|
7568
7693
|
const tell = [];
|
|
7569
7694
|
const skipped = [];
|
|
7570
7695
|
const files = new Set(merged.files ?? []);
|
|
7571
|
-
const matches =
|
|
7696
|
+
const matches = import_picomatch2.default([...notifyPaths], { dot: true });
|
|
7572
7697
|
const globalFiles = [...files].filter((f) => matches(f));
|
|
7573
7698
|
for (const worker of workers) {
|
|
7574
7699
|
if (coordinatorName && worker.coordinator && worker.coordinator !== coordinatorName) {
|
|
@@ -8277,12 +8402,15 @@ async function mergePinned(ctx, pull, sha, ticket, beforeMerge) {
|
|
|
8277
8402
|
const view = `gh pr view ${pull.number} --repo ${ctx.config.github.repository}`;
|
|
8278
8403
|
if (!fresh)
|
|
8279
8404
|
throw new MergeStateError(`GitHub failed (${res.message}) and ${n} could not be read back (${readError || "not found"})${closeByHand}`, view, pull.number, ticket);
|
|
8280
|
-
|
|
8405
|
+
const mergeLocked = /merge already in progress/i.test(res.message);
|
|
8406
|
+
if (!res.transient && !mergeLocked)
|
|
8281
8407
|
throw new Refusal(`GitHub refused to merge ${n}: ${res.message}`, `armada merge ${pull.number} --dry-run`);
|
|
8282
8408
|
if (fresh.state !== "open")
|
|
8283
8409
|
throw new Refusal(`GitHub failed (${res.message}) and ${n} is now ${fresh.state}; not retrying`, view);
|
|
8284
8410
|
if (fresh.headSha !== sha)
|
|
8285
8411
|
throw new Refusal(`GitHub failed (${res.message}) and the head of ${n} moved to ${fresh.headSha}; not retrying`, `armada merge ${pull.number} --dry-run, once its worker hands back the new head`);
|
|
8412
|
+
if (mergeLocked)
|
|
8413
|
+
throw new Refusal(`GitHub's merge lock is temporary (${res.message}); ${n} is still open at ${short(sha)}`, `armada merge ${pull.number}`, true);
|
|
8286
8414
|
const wait = MERGE_BACKOFF_MS[attempt];
|
|
8287
8415
|
if (wait === undefined)
|
|
8288
8416
|
throw new Refusal(`GitHub kept failing (${res.message}) after ${attempt + 1} attempts; ${n} is still open and nothing was merged`, `armada merge ${pull.number} again once GitHub answers`, true);
|
|
@@ -8599,7 +8727,9 @@ async function locked(ctx, input, run) {
|
|
|
8599
8727
|
async function after(ctx, c, merged, lines, handBackId, keepOpen, more, unlocked, override = "") {
|
|
8600
8728
|
ctx.onMerged?.(merged, c.ticket?.id ?? null);
|
|
8601
8729
|
await ctx.tick?.();
|
|
8602
|
-
const targets = (ctx.config.deploy?.targets ?? []
|
|
8730
|
+
const { targets, skipped } = selectDeployTargets(ctx.config.deploy?.targets ?? [], merged.baseRef, noticeFileCoverage(merged));
|
|
8731
|
+
for (const name of skipped)
|
|
8732
|
+
lines.push(`Skipped deploy to ${name}: no changed files match paths.`);
|
|
8603
8733
|
const deploy = targets.length ? { targets } : null;
|
|
8604
8734
|
const ticket = c.ticket;
|
|
8605
8735
|
let chorePending = false;
|
|
@@ -9152,99 +9282,6 @@ var missingKeys = (credentials) => STORED_KEYS.filter((k) => credentials[k.name]
|
|
|
9152
9282
|
function missingKeyMessage(key) {
|
|
9153
9283
|
return `${key.variable} is not set. Set it in the environment, run \`armada auth login\` to store it on this machine (${key.hint}), or sign in with \`armada login\` to an Armada that keeps your organization's keys.`;
|
|
9154
9284
|
}
|
|
9155
|
-
// ../core/src/deploy.ts
|
|
9156
|
-
function deployDetail(output) {
|
|
9157
|
-
const lines = output.trim().split(`
|
|
9158
|
-
`).slice(-30).join(`
|
|
9159
|
-
`);
|
|
9160
|
-
let size = 0;
|
|
9161
|
-
const tail = [];
|
|
9162
|
-
for (const ch of Array.from(lines).reverse()) {
|
|
9163
|
-
size += new TextEncoder().encode(ch).length;
|
|
9164
|
-
if (size > 4096)
|
|
9165
|
-
break;
|
|
9166
|
-
tail.push(ch);
|
|
9167
|
-
}
|
|
9168
|
-
return tail.reverse().join("");
|
|
9169
|
-
}
|
|
9170
|
-
async function watchDeploy(o) {
|
|
9171
|
-
const deadline = (o.startedAt ?? o.now()).getTime() + o.target.timeoutMinutes * 60000;
|
|
9172
|
-
let detail = "waiting for the merge commit";
|
|
9173
|
-
let liveSha = null;
|
|
9174
|
-
const record = (state) => o.record({
|
|
9175
|
-
target: o.target.name,
|
|
9176
|
-
sha: o.sha,
|
|
9177
|
-
state,
|
|
9178
|
-
detail: deployDetail(detail),
|
|
9179
|
-
pauseOnFailure: o.target.pauseOnFailure,
|
|
9180
|
-
liveSha
|
|
9181
|
-
});
|
|
9182
|
-
await record("waiting");
|
|
9183
|
-
while (o.now().getTime() < deadline) {
|
|
9184
|
-
if (o.healthy) {
|
|
9185
|
-
let verified = null;
|
|
9186
|
-
try {
|
|
9187
|
-
verified = await o.healthy();
|
|
9188
|
-
} catch {
|
|
9189
|
-
detail = "could not read shared deploy state; retrying";
|
|
9190
|
-
}
|
|
9191
|
-
if (verified) {
|
|
9192
|
-
liveSha = verified.sha;
|
|
9193
|
-
detail = verified.detail;
|
|
9194
|
-
await record("healthy");
|
|
9195
|
-
return "healthy";
|
|
9196
|
-
}
|
|
9197
|
-
}
|
|
9198
|
-
let live = null;
|
|
9199
|
-
try {
|
|
9200
|
-
live = await o.live(deadline - o.now().getTime());
|
|
9201
|
-
} catch {
|
|
9202
|
-
detail = "could not read the deploy status; retrying";
|
|
9203
|
-
}
|
|
9204
|
-
if (live) {
|
|
9205
|
-
detail = live.detail;
|
|
9206
|
-
liveSha = live.sha;
|
|
9207
|
-
let includes = live.sha === o.sha;
|
|
9208
|
-
if (live.sha && !includes) {
|
|
9209
|
-
try {
|
|
9210
|
-
includes = await o.includes(o.sha, live.sha);
|
|
9211
|
-
} catch {
|
|
9212
|
-
detail = `${detail}
|
|
9213
|
-
could not compare the live commit; retrying`;
|
|
9214
|
-
}
|
|
9215
|
-
}
|
|
9216
|
-
if (includes && (live.state === "failure" || live.state === "error")) {
|
|
9217
|
-
await record("deploy-failed");
|
|
9218
|
-
return "deploy-failed";
|
|
9219
|
-
}
|
|
9220
|
-
if (includes && live.sha && live.state === "success" && o.now().getTime() < deadline) {
|
|
9221
|
-
await record("live");
|
|
9222
|
-
let result;
|
|
9223
|
-
try {
|
|
9224
|
-
result = await o.smoke(live.sha, deadline - o.now().getTime());
|
|
9225
|
-
} catch {
|
|
9226
|
-
result = { ok: null, detail: "could not read or record shared smoke state; retrying" };
|
|
9227
|
-
}
|
|
9228
|
-
detail = result.detail;
|
|
9229
|
-
if (result.ok !== null) {
|
|
9230
|
-
const state = result.ok ? "healthy" : "smoke-failed";
|
|
9231
|
-
await record(state);
|
|
9232
|
-
return state;
|
|
9233
|
-
}
|
|
9234
|
-
}
|
|
9235
|
-
}
|
|
9236
|
-
await record("waiting");
|
|
9237
|
-
await o.sleep(Math.min(30000, Math.max(0, deadline - o.now().getTime())));
|
|
9238
|
-
}
|
|
9239
|
-
detail = `deploy deadline reached
|
|
9240
|
-
${detail}`;
|
|
9241
|
-
await record("timeout");
|
|
9242
|
-
return "timeout";
|
|
9243
|
-
}
|
|
9244
|
-
function deployLine(row, now) {
|
|
9245
|
-
const age = Math.max(0, Math.floor((now.getTime() - Date.parse(row.updatedAt)) / 60000));
|
|
9246
|
-
return `${row.target}: ${row.state} ${row.sha}${row.state === "waiting" || row.state === "live" ? ` — watching since ${row.startedAt.slice(11, 16)}, no news for ${age} min${age >= 2 ? "; watcher may have stopped" : ""}` : ""}`;
|
|
9247
|
-
}
|
|
9248
9285
|
// ../core/src/dotenv.ts
|
|
9249
9286
|
var ASSIGNMENT = /^\s*(export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/;
|
|
9250
9287
|
function shellWord2(raw) {
|
|
@@ -15767,7 +15804,7 @@ ${attachments.join(`
|
|
|
15767
15804
|
};
|
|
15768
15805
|
}
|
|
15769
15806
|
// package.json
|
|
15770
|
-
var version = "0.2.
|
|
15807
|
+
var version = "0.2.59";
|
|
15771
15808
|
|
|
15772
15809
|
// src/io.ts
|
|
15773
15810
|
class UsageError extends Error {
|