@the-vibe-company/armada 0.2.57 → 0.2.60
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 +16 -0
- package/dist/armada.js +305 -105
- 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,19 @@ 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
|
+
|
|
709
|
+
For commands that need a machine-specific linked folder, declare the setting by name:
|
|
710
|
+
|
|
711
|
+
```toml
|
|
712
|
+
[[deploy.target]]
|
|
713
|
+
name = "worker"
|
|
714
|
+
live_sha_command = 'cd "$DEPLOY_LINK_DIR" && hosting-cli live-sha'
|
|
715
|
+
requires_env = ["DEPLOY_LINK_DIR"]
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
On each coordinator machine, run `armada config set deploy.env.DEPLOY_LINK_DIR /path/to/linked-service` from the project checkout. Non-secret values are stored per project in `~/.config/armada/projects/<slug>.json` (or `$XDG_CONFIG_HOME/armada/projects/<slug>.json`), outside the repository. Machine values win over the process environment; only declared names are added to the target's live and smoke commands. Use `armada config unset deploy.env.DEPLOY_LINK_DIR` to return to the process environment. A damaged settings file produces a diagnostic and uses the process environment; `armada config set` repairs it. Keep secrets in Armada's vault and use `armada run` for commands that need them.
|
|
719
|
+
|
|
720
|
+
`armada doctor` names each target's missing settings and gives the exact `armada config set` fixes. Empty environment values count as missing. After a merge, a target missing a required setting emits one `deploy check skipped: <VAR> not set on this machine` warning and records `skipped (not configured on this machine)` without a merge hold or failure inbox item. A configured command that fails still pauses merges. After configuration, `armada deploy watch` can retry the skipped SHA. A machine-local skip preserves any real observation already recorded by another watcher for the same SHA.
|
|
721
|
+
|
|
706
722
|
`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,127 @@ 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 resolveDeployEnv(target, local, processEnv) {
|
|
2043
|
+
const env = {};
|
|
2044
|
+
const missing = [];
|
|
2045
|
+
for (const name of target.requiresEnv ?? []) {
|
|
2046
|
+
const value = Object.hasOwn(local, name) ? local[name] : Object.hasOwn(processEnv, name) ? processEnv[name] : undefined;
|
|
2047
|
+
if (value?.trim())
|
|
2048
|
+
env[name] = value;
|
|
2049
|
+
else
|
|
2050
|
+
missing.push(name);
|
|
2051
|
+
}
|
|
2052
|
+
return { env, missing };
|
|
2053
|
+
}
|
|
2054
|
+
function deployDetail(output) {
|
|
2055
|
+
const lines = output.trim().split(`
|
|
2056
|
+
`).slice(-30).join(`
|
|
2057
|
+
`);
|
|
2058
|
+
let size = 0;
|
|
2059
|
+
const tail = [];
|
|
2060
|
+
for (const ch of Array.from(lines).reverse()) {
|
|
2061
|
+
size += new TextEncoder().encode(ch).length;
|
|
2062
|
+
if (size > 4096)
|
|
2063
|
+
break;
|
|
2064
|
+
tail.push(ch);
|
|
2065
|
+
}
|
|
2066
|
+
return tail.reverse().join("");
|
|
2067
|
+
}
|
|
2068
|
+
async function watchDeploy(o) {
|
|
2069
|
+
const deadline = (o.startedAt ?? o.now()).getTime() + o.target.timeoutMinutes * 60000;
|
|
2070
|
+
let detail = "waiting for the merge commit";
|
|
2071
|
+
let liveSha = null;
|
|
2072
|
+
const record = (state) => o.record({
|
|
2073
|
+
target: o.target.name,
|
|
2074
|
+
sha: o.sha,
|
|
2075
|
+
state,
|
|
2076
|
+
detail: deployDetail(detail),
|
|
2077
|
+
pauseOnFailure: o.target.pauseOnFailure,
|
|
2078
|
+
liveSha
|
|
2079
|
+
});
|
|
2080
|
+
await record("waiting");
|
|
2081
|
+
while (o.now().getTime() < deadline) {
|
|
2082
|
+
if (o.healthy) {
|
|
2083
|
+
let verified = null;
|
|
2084
|
+
try {
|
|
2085
|
+
verified = await o.healthy();
|
|
2086
|
+
} catch {
|
|
2087
|
+
detail = "could not read shared deploy state; retrying";
|
|
2088
|
+
}
|
|
2089
|
+
if (verified) {
|
|
2090
|
+
liveSha = verified.sha;
|
|
2091
|
+
detail = verified.detail;
|
|
2092
|
+
await record("healthy");
|
|
2093
|
+
return "healthy";
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
let live = null;
|
|
2097
|
+
try {
|
|
2098
|
+
live = await o.live(deadline - o.now().getTime());
|
|
2099
|
+
} catch {
|
|
2100
|
+
detail = "could not read the deploy status; retrying";
|
|
2101
|
+
}
|
|
2102
|
+
if (live) {
|
|
2103
|
+
detail = live.detail;
|
|
2104
|
+
liveSha = live.sha;
|
|
2105
|
+
let includes = live.sha === o.sha;
|
|
2106
|
+
if (live.sha && !includes) {
|
|
2107
|
+
try {
|
|
2108
|
+
includes = await o.includes(o.sha, live.sha);
|
|
2109
|
+
} catch {
|
|
2110
|
+
detail = `${detail}
|
|
2111
|
+
could not compare the live commit; retrying`;
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
if (includes && (live.state === "failure" || live.state === "error")) {
|
|
2115
|
+
await record("deploy-failed");
|
|
2116
|
+
return "deploy-failed";
|
|
2117
|
+
}
|
|
2118
|
+
if (includes && live.sha && live.state === "success" && o.now().getTime() < deadline) {
|
|
2119
|
+
await record("live");
|
|
2120
|
+
let result;
|
|
2121
|
+
try {
|
|
2122
|
+
result = await o.smoke(live.sha, deadline - o.now().getTime());
|
|
2123
|
+
} catch {
|
|
2124
|
+
result = { ok: null, detail: "could not read or record shared smoke state; retrying" };
|
|
2125
|
+
}
|
|
2126
|
+
detail = result.detail;
|
|
2127
|
+
if (result.ok !== null) {
|
|
2128
|
+
const state = result.ok ? "healthy" : "smoke-failed";
|
|
2129
|
+
await record(state);
|
|
2130
|
+
return state;
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
await record("waiting");
|
|
2135
|
+
await o.sleep(Math.min(30000, Math.max(0, deadline - o.now().getTime())));
|
|
2136
|
+
}
|
|
2137
|
+
detail = `deploy deadline reached
|
|
2138
|
+
${detail}`;
|
|
2139
|
+
await record("timeout");
|
|
2140
|
+
return "timeout";
|
|
2141
|
+
}
|
|
2142
|
+
function deployLine(row, now) {
|
|
2143
|
+
const age = Math.max(0, Math.floor((now.getTime() - Date.parse(row.updatedAt)) / 60000));
|
|
2144
|
+
return `${row.target}: ${row.state === "skipped" ? "skipped (not configured on this machine)" : 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" : ""}` : ""}`;
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2026
2147
|
// ../../node_modules/.bun/smol-toml@1.9.0/node_modules/smol-toml/dist/error.js
|
|
2027
2148
|
/*!
|
|
2028
2149
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
@@ -3385,6 +3506,9 @@ function overlapLines(reading) {
|
|
|
3385
3506
|
}
|
|
3386
3507
|
|
|
3387
3508
|
// ../core/src/config.ts
|
|
3509
|
+
function deployEnvName(name) {
|
|
3510
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name) && !["__proto__", "constructor", "prototype", "ARMADA_DEPLOY_SHA", "ARMADA_DEPLOY_TARGET"].includes(name);
|
|
3511
|
+
}
|
|
3388
3512
|
var CONFIG_FILE = "armada.toml";
|
|
3389
3513
|
var PLAN_POLICIES = ["approve", "pre-approved"];
|
|
3390
3514
|
var routingLabelKey = (name) => name.normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{M}\p{N}]/gu, "");
|
|
@@ -3799,7 +3923,17 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
3799
3923
|
known.push([
|
|
3800
3924
|
path,
|
|
3801
3925
|
row,
|
|
3802
|
-
[
|
|
3926
|
+
[
|
|
3927
|
+
"name",
|
|
3928
|
+
"branch",
|
|
3929
|
+
"paths",
|
|
3930
|
+
"requires_env",
|
|
3931
|
+
"github_environment",
|
|
3932
|
+
"live_sha_command",
|
|
3933
|
+
"smoke",
|
|
3934
|
+
"timeout_minutes",
|
|
3935
|
+
"pause_on_failure"
|
|
3936
|
+
]
|
|
3803
3937
|
]);
|
|
3804
3938
|
const name = str(row, path, "name");
|
|
3805
3939
|
if (name.length > 200)
|
|
@@ -3816,7 +3950,16 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
3816
3950
|
problems.push(`"${path}.timeout_minutes" must be from 1 to 120`);
|
|
3817
3951
|
if (row.pause_on_failure !== undefined && typeof row.pause_on_failure !== "boolean")
|
|
3818
3952
|
problems.push(`"${path}.pause_on_failure" must be true or false`);
|
|
3953
|
+
if (row.paths !== undefined) {
|
|
3954
|
+
const problem = pathsProblem(row.paths);
|
|
3955
|
+
if (problem || Array.isArray(row.paths) && !row.paths.length)
|
|
3956
|
+
problems.push(`"${path}.paths": ${problem ?? "must not be empty"}`);
|
|
3957
|
+
}
|
|
3958
|
+
if (row.requires_env !== undefined && (!Array.isArray(row.requires_env) || row.requires_env.some((name) => typeof name !== "string" || !deployEnvName(name))))
|
|
3959
|
+
problems.push(`"${path}.requires_env" must be an array of environment variable names (excluding reserved names)`);
|
|
3819
3960
|
deployTargets.push({
|
|
3961
|
+
...Array.isArray(row.requires_env) ? { requiresEnv: [...new Set(row.requires_env)] } : {},
|
|
3962
|
+
...Array.isArray(row.paths) ? { paths: row.paths } : {},
|
|
3820
3963
|
name,
|
|
3821
3964
|
branch: optional("branch"),
|
|
3822
3965
|
githubEnvironment,
|
|
@@ -4174,9 +4317,13 @@ repository = ${q(p.repository)}
|
|
|
4174
4317
|
# [[deploy.target]]
|
|
4175
4318
|
# name = "api"
|
|
4176
4319
|
# branch = "main" # omit to watch any merged base branch
|
|
4320
|
+
# paths = ["cmd/**", "internal/**"] # optional: only watch merges touching these globs
|
|
4177
4321
|
# github_environment = "production"
|
|
4178
4322
|
## Alternative to github_environment (choose exactly one live source):
|
|
4179
|
-
## live_sha_command = "
|
|
4323
|
+
## live_sha_command = 'cd "$DEPLOY_LINK_DIR" && hosting-cli live-sha'
|
|
4324
|
+
## requires_env = ["DEPLOY_LINK_DIR"]
|
|
4325
|
+
## On each coordinator machine: armada config set deploy.env.DEPLOY_LINK_DIR /path/to/linked-service
|
|
4326
|
+
## Machine settings win over the process environment; missing settings skip without a hold.
|
|
4180
4327
|
# smoke = "curl -fsS https://example.test/health"
|
|
4181
4328
|
# timeout_minutes = 20 # 1–120; smoke shares this deadline
|
|
4182
4329
|
# pause_on_failure = true
|
|
@@ -7568,7 +7715,7 @@ function workersToTell(merged, workers, notifyPaths, coordinatorName) {
|
|
|
7568
7715
|
const tell = [];
|
|
7569
7716
|
const skipped = [];
|
|
7570
7717
|
const files = new Set(merged.files ?? []);
|
|
7571
|
-
const matches =
|
|
7718
|
+
const matches = import_picomatch2.default([...notifyPaths], { dot: true });
|
|
7572
7719
|
const globalFiles = [...files].filter((f) => matches(f));
|
|
7573
7720
|
for (const worker of workers) {
|
|
7574
7721
|
if (coordinatorName && worker.coordinator && worker.coordinator !== coordinatorName) {
|
|
@@ -8277,12 +8424,15 @@ async function mergePinned(ctx, pull, sha, ticket, beforeMerge) {
|
|
|
8277
8424
|
const view = `gh pr view ${pull.number} --repo ${ctx.config.github.repository}`;
|
|
8278
8425
|
if (!fresh)
|
|
8279
8426
|
throw new MergeStateError(`GitHub failed (${res.message}) and ${n} could not be read back (${readError || "not found"})${closeByHand}`, view, pull.number, ticket);
|
|
8280
|
-
|
|
8427
|
+
const mergeLocked = /merge already in progress/i.test(res.message);
|
|
8428
|
+
if (!res.transient && !mergeLocked)
|
|
8281
8429
|
throw new Refusal(`GitHub refused to merge ${n}: ${res.message}`, `armada merge ${pull.number} --dry-run`);
|
|
8282
8430
|
if (fresh.state !== "open")
|
|
8283
8431
|
throw new Refusal(`GitHub failed (${res.message}) and ${n} is now ${fresh.state}; not retrying`, view);
|
|
8284
8432
|
if (fresh.headSha !== sha)
|
|
8285
8433
|
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`);
|
|
8434
|
+
if (mergeLocked)
|
|
8435
|
+
throw new Refusal(`GitHub's merge lock is temporary (${res.message}); ${n} is still open at ${short(sha)}`, `armada merge ${pull.number}`, true);
|
|
8286
8436
|
const wait = MERGE_BACKOFF_MS[attempt];
|
|
8287
8437
|
if (wait === undefined)
|
|
8288
8438
|
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 +8749,9 @@ async function locked(ctx, input, run) {
|
|
|
8599
8749
|
async function after(ctx, c, merged, lines, handBackId, keepOpen, more, unlocked, override = "") {
|
|
8600
8750
|
ctx.onMerged?.(merged, c.ticket?.id ?? null);
|
|
8601
8751
|
await ctx.tick?.();
|
|
8602
|
-
const targets = (ctx.config.deploy?.targets ?? []
|
|
8752
|
+
const { targets, skipped } = selectDeployTargets(ctx.config.deploy?.targets ?? [], merged.baseRef, noticeFileCoverage(merged));
|
|
8753
|
+
for (const name of skipped)
|
|
8754
|
+
lines.push(`Skipped deploy to ${name}: no changed files match paths.`);
|
|
8603
8755
|
const deploy = targets.length ? { targets } : null;
|
|
8604
8756
|
const ticket = c.ticket;
|
|
8605
8757
|
let chorePending = false;
|
|
@@ -9152,99 +9304,6 @@ var missingKeys = (credentials) => STORED_KEYS.filter((k) => credentials[k.name]
|
|
|
9152
9304
|
function missingKeyMessage(key) {
|
|
9153
9305
|
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
9306
|
}
|
|
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
9307
|
// ../core/src/dotenv.ts
|
|
9249
9308
|
var ASSIGNMENT = /^\s*(export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/;
|
|
9250
9309
|
function shellWord2(raw) {
|
|
@@ -10902,6 +10961,58 @@ async function ensurePersonalConfig(paths) {
|
|
|
10902
10961
|
await writePrivate(paths, paths.config, PERSONAL_CONFIG_TEMPLATE, 420);
|
|
10903
10962
|
return true;
|
|
10904
10963
|
}
|
|
10964
|
+
var projectSettingsPath = (paths, project) => {
|
|
10965
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(project))
|
|
10966
|
+
throw new Error("invalid project slug");
|
|
10967
|
+
return join(paths.dir, "projects", `${project}.json`);
|
|
10968
|
+
};
|
|
10969
|
+
async function readDeployEnv(paths, project) {
|
|
10970
|
+
const empty = { env: {}, warning: null };
|
|
10971
|
+
if (!paths)
|
|
10972
|
+
return empty;
|
|
10973
|
+
const path = projectSettingsPath(paths, project);
|
|
10974
|
+
let text;
|
|
10975
|
+
try {
|
|
10976
|
+
text = await readFile(path, "utf8");
|
|
10977
|
+
} catch (err) {
|
|
10978
|
+
if (missing(err))
|
|
10979
|
+
return empty;
|
|
10980
|
+
return {
|
|
10981
|
+
env: {},
|
|
10982
|
+
warning: `cannot read project machine settings in ${path}: ${err.code ?? "unknown error"}; using the process environment`
|
|
10983
|
+
};
|
|
10984
|
+
}
|
|
10985
|
+
try {
|
|
10986
|
+
const raw = JSON.parse(text);
|
|
10987
|
+
if (!isTable3(raw) || !isTable3(raw.deploy) || !isTable3(raw.deploy.env))
|
|
10988
|
+
throw new Error;
|
|
10989
|
+
const env = {};
|
|
10990
|
+
for (const [name, value] of Object.entries(raw.deploy.env)) {
|
|
10991
|
+
if (!deployEnvName(name) || typeof value !== "string" || !value.trim() || value.includes("\x00"))
|
|
10992
|
+
throw new Error;
|
|
10993
|
+
env[name] = value;
|
|
10994
|
+
}
|
|
10995
|
+
return { env, warning: null };
|
|
10996
|
+
} catch {
|
|
10997
|
+
return {
|
|
10998
|
+
env: {},
|
|
10999
|
+
warning: `invalid project machine settings in ${path}; using the process environment. armada config set repairs this file`
|
|
11000
|
+
};
|
|
11001
|
+
}
|
|
11002
|
+
}
|
|
11003
|
+
async function updateDeployEnv(paths, project, name, value) {
|
|
11004
|
+
if (!deployEnvName(name))
|
|
11005
|
+
throw new Error("invalid deploy environment variable name");
|
|
11006
|
+
if (value !== null && (!value.trim() || value.includes("\x00")))
|
|
11007
|
+
throw new Error("deploy setting must be a non-empty string without NUL");
|
|
11008
|
+
const { env } = await readDeployEnv(paths, project);
|
|
11009
|
+
if (value === null)
|
|
11010
|
+
delete env[name];
|
|
11011
|
+
else
|
|
11012
|
+
env[name] = value;
|
|
11013
|
+
await writePrivate(paths, projectSettingsPath(paths, project), `${JSON.stringify({ deploy: { env } }, null, 2)}
|
|
11014
|
+
`, 384);
|
|
11015
|
+
}
|
|
10905
11016
|
function watchFiles(paths, project, name = "default") {
|
|
10906
11017
|
if (!COORDINATOR.test(name))
|
|
10907
11018
|
throw new Error("invalid coordinator name");
|
|
@@ -15767,7 +15878,7 @@ ${attachments.join(`
|
|
|
15767
15878
|
};
|
|
15768
15879
|
}
|
|
15769
15880
|
// package.json
|
|
15770
|
-
var version = "0.2.
|
|
15881
|
+
var version = "0.2.60";
|
|
15771
15882
|
|
|
15772
15883
|
// src/io.ts
|
|
15773
15884
|
class UsageError extends Error {
|
|
@@ -18186,6 +18297,29 @@ async function buildDoctor(io, armadaVersion, options = { readOnly: true }) {
|
|
|
18186
18297
|
...signIn,
|
|
18187
18298
|
...versionChecks(hostOf(credentials.armadaApi.url), api, armadaVersion, outdated),
|
|
18188
18299
|
...keyFileChecks(machine, credentials),
|
|
18300
|
+
...await (async () => {
|
|
18301
|
+
if (!config?.deploy?.targets.length)
|
|
18302
|
+
return [];
|
|
18303
|
+
const local = await readDeployEnv(machine.paths, config.project.slug);
|
|
18304
|
+
const checks = config.deploy.targets.map((target) => {
|
|
18305
|
+
const { missing } = resolveDeployEnv(target, local.env, io.env);
|
|
18306
|
+
return {
|
|
18307
|
+
id: `deploy-env:${target.name}`,
|
|
18308
|
+
level: missing.length ? "warning" : "ok",
|
|
18309
|
+
message: missing.length ? `${target.name}: ${missing.join(", ")} not set on this machine; deploy check will be skipped` : `${target.name}: required deploy settings are configured`,
|
|
18310
|
+
fix: missing.length ? missing.map((name) => `armada config set deploy.env.${name} <value> --config ${shellWord(join4(root, CONFIG_FILE))}`).join(`
|
|
18311
|
+
`) : null
|
|
18312
|
+
};
|
|
18313
|
+
});
|
|
18314
|
+
if (local.warning)
|
|
18315
|
+
checks.unshift({
|
|
18316
|
+
id: "deploy-machine-settings",
|
|
18317
|
+
level: "warning",
|
|
18318
|
+
message: local.warning,
|
|
18319
|
+
fix: checks.find((c) => c.fix)?.fix ?? "armada config set deploy.env.<VAR> <value>"
|
|
18320
|
+
});
|
|
18321
|
+
return checks;
|
|
18322
|
+
})(),
|
|
18189
18323
|
{
|
|
18190
18324
|
id: "linear-key",
|
|
18191
18325
|
level: credentials.sources.linearApiKey ? "ok" : "warning",
|
|
@@ -21182,6 +21316,22 @@ ${r.runId === null ? "Rerun" : `Run ${r.runId}`}: ${r.status === "refused" ? "re
|
|
|
21182
21316
|
return reruns.some((r) => r.status !== "requested") ? 1 : 0;
|
|
21183
21317
|
}
|
|
21184
21318
|
|
|
21319
|
+
// src/config.ts
|
|
21320
|
+
async function configCommand(io, config, args) {
|
|
21321
|
+
const [action, key, value, ...extra] = args.rest;
|
|
21322
|
+
const name = key?.startsWith("deploy.env.") ? key.slice("deploy.env.".length) : "";
|
|
21323
|
+
if (!deployEnvName(name) || extra.length || (action === "set" ? value === undefined : action !== "unset" || value !== undefined))
|
|
21324
|
+
throw new UsageError("use armada config set deploy.env.<VAR> <value> or armada config unset deploy.env.<VAR>");
|
|
21325
|
+
const paths = machinePaths(io.env);
|
|
21326
|
+
if (!paths)
|
|
21327
|
+
throw new UsageError("machine settings need HOME or XDG_CONFIG_HOME");
|
|
21328
|
+
await updateDeployEnv(paths, config.project.slug, name, action === "set" ? value : null);
|
|
21329
|
+
io.stdout(args.json ? `${JSON.stringify({ project: config.project.slug, key, action })}
|
|
21330
|
+
` : `${key} ${action === "set" ? "set" : "unset"} for ${config.project.slug} on this machine.
|
|
21331
|
+
`);
|
|
21332
|
+
return 0;
|
|
21333
|
+
}
|
|
21334
|
+
|
|
21185
21335
|
// src/deploy.ts
|
|
21186
21336
|
import { createHash as createHash7, randomUUID } from "node:crypto";
|
|
21187
21337
|
import { dirname as dirname7, join as join6 } from "node:path";
|
|
@@ -21208,12 +21358,41 @@ async function deployStatus(io, config, credentials) {
|
|
|
21208
21358
|
const [rows, holds] = await Promise.all([fleet.deployState(), fleet.holds()]);
|
|
21209
21359
|
return { rows, holds: holds.filter((h) => h.kind === "deploy") };
|
|
21210
21360
|
}
|
|
21211
|
-
async function
|
|
21361
|
+
async function skipUnconfigured(io, config, credentials, target, sha, missing) {
|
|
21362
|
+
io.stderr(`armada: ${target.name}: deploy check skipped: ${missing.join(", ")} not set on this machine
|
|
21363
|
+
`);
|
|
21364
|
+
const { fleet } = liveFleet(io, config, credentials);
|
|
21365
|
+
if (sha && fleet) {
|
|
21366
|
+
try {
|
|
21367
|
+
await recordDeploy(io, fleet.recordDeploy, {
|
|
21368
|
+
target: target.name,
|
|
21369
|
+
sha,
|
|
21370
|
+
state: "skipped",
|
|
21371
|
+
detail: `skipped (not configured on this machine): ${missing.join(", ")}`,
|
|
21372
|
+
pauseOnFailure: false
|
|
21373
|
+
});
|
|
21374
|
+
} catch {
|
|
21375
|
+
io.stderr(`armada: could not record skipped deploy state
|
|
21376
|
+
`);
|
|
21377
|
+
}
|
|
21378
|
+
}
|
|
21379
|
+
}
|
|
21380
|
+
async function startDeploys(io, config, credentials, configPath, sha, targets, json) {
|
|
21212
21381
|
const results = [];
|
|
21382
|
+
const local = await readDeployEnv(machinePaths(io.env), config.project.slug);
|
|
21383
|
+
if (local.warning)
|
|
21384
|
+
io.stderr(`armada: ${local.warning}
|
|
21385
|
+
`);
|
|
21213
21386
|
for (const name of targets) {
|
|
21214
21387
|
const target = config.deploy?.targets.find((t) => t.name === name);
|
|
21215
21388
|
if (!target)
|
|
21216
21389
|
continue;
|
|
21390
|
+
const { missing } = resolveDeployEnv(target, local.env, io.env);
|
|
21391
|
+
if (missing.length) {
|
|
21392
|
+
await skipUnconfigured(io, config, credentials, target, sha, missing);
|
|
21393
|
+
results.push({ target: name, started: false, next: null, skipped: true });
|
|
21394
|
+
continue;
|
|
21395
|
+
}
|
|
21217
21396
|
const args = ["deploy", "watch", "--sha", sha ?? "<merge-sha>", "--target", name, "--config", configPath];
|
|
21218
21397
|
const next = `armada ${args.map(shellWord).join(" ")}`;
|
|
21219
21398
|
let started = false;
|
|
@@ -21257,6 +21436,16 @@ async function deploy2(io, config, credentials, args, configPath) {
|
|
|
21257
21436
|
if (!fleet || credentials.armadaSignIn?.kind === "worker")
|
|
21258
21437
|
throw new UsageError(warning ?? "deploy watch needs an organization sign-in", "armada login");
|
|
21259
21438
|
const paths = machinePaths(io.env);
|
|
21439
|
+
const local = await readDeployEnv(paths, config.project.slug);
|
|
21440
|
+
if (local.warning)
|
|
21441
|
+
io.stderr(`armada: ${local.warning}
|
|
21442
|
+
`);
|
|
21443
|
+
const settings = resolveDeployEnv(target, local.env, io.env);
|
|
21444
|
+
if (settings.missing.length) {
|
|
21445
|
+
await skipUnconfigured(io, config, credentials, target, sha, settings.missing);
|
|
21446
|
+
io.backgroundReady?.(true);
|
|
21447
|
+
return 0;
|
|
21448
|
+
}
|
|
21260
21449
|
if (!paths)
|
|
21261
21450
|
throw new UsageError("deploy watch needs HOME or XDG_CONFIG_HOME for its PID file");
|
|
21262
21451
|
if (!io.exec)
|
|
@@ -21275,7 +21464,8 @@ async function deploy2(io, config, credentials, args, configPath) {
|
|
|
21275
21464
|
credentials.armadaSignIn?.kind === "api-key" ? credentials.armadaSignIn.key : credentials.armadaSignIn?.token,
|
|
21276
21465
|
credentials.linearApiKey,
|
|
21277
21466
|
credentials.githubToken,
|
|
21278
|
-
...config.secrets.names.map((name) => io.env[name])
|
|
21467
|
+
...config.secrets.names.map((name) => io.env[name]),
|
|
21468
|
+
...Object.values(settings.env)
|
|
21279
21469
|
].filter((value) => !!value);
|
|
21280
21470
|
const clean = (text) => redactSecrets(text, secrets);
|
|
21281
21471
|
const ancestry = new Map;
|
|
@@ -21318,7 +21508,7 @@ async function deploy2(io, config, credentials, args, configPath) {
|
|
|
21318
21508
|
timeoutMs: Math.max(1, Math.min(remainingMs, 60000)),
|
|
21319
21509
|
maxOutputBytes: 64 * 1024,
|
|
21320
21510
|
processGroup: true,
|
|
21321
|
-
env: { ...io.env, ARMADA_DEPLOY_SHA: liveSha, ARMADA_DEPLOY_TARGET: target.name }
|
|
21511
|
+
env: { ...io.env, ...settings.env, ARMADA_DEPLOY_SHA: liveSha, ARMADA_DEPLOY_TARGET: target.name }
|
|
21322
21512
|
});
|
|
21323
21513
|
return {
|
|
21324
21514
|
ok: result?.code === 0 && !result.timedOut,
|
|
@@ -21370,7 +21560,7 @@ ${result?.timedOut ? "command timed out" : `exit ${result?.code ?? 1}`}`)),
|
|
|
21370
21560
|
};
|
|
21371
21561
|
try {
|
|
21372
21562
|
const prior = (await fleet.deployState({ target: target.name, sha }))[0];
|
|
21373
|
-
if (prior && !["waiting", "live"].includes(prior.state)) {
|
|
21563
|
+
if (prior && !["waiting", "live", "skipped"].includes(prior.state)) {
|
|
21374
21564
|
io.backgroundReady?.(true);
|
|
21375
21565
|
io.stdout(`${target.name}: ${prior.state}
|
|
21376
21566
|
`);
|
|
@@ -21387,7 +21577,7 @@ ${result?.timedOut ? "command timed out" : `exit ${result?.code ?? 1}`}`)),
|
|
|
21387
21577
|
const result = await watchDeploy({
|
|
21388
21578
|
target,
|
|
21389
21579
|
sha,
|
|
21390
|
-
...prior ? { startedAt: new Date(prior.startedAt) } : {},
|
|
21580
|
+
...prior && prior.state !== "skipped" ? { startedAt: new Date(prior.startedAt) } : {},
|
|
21391
21581
|
now,
|
|
21392
21582
|
sleep: sleepOf2(io),
|
|
21393
21583
|
record: write,
|
|
@@ -25134,6 +25324,10 @@ async function done(io, config, credentials, a) {
|
|
|
25134
25324
|
|
|
25135
25325
|
// src/cli.ts
|
|
25136
25326
|
var COMMAND_HELP = {
|
|
25327
|
+
config: ` config set deploy.env.<VAR> <value>
|
|
25328
|
+
config unset deploy.env.<VAR>
|
|
25329
|
+
Set or remove a non-secret deploy setting for this project on this machine.
|
|
25330
|
+
`,
|
|
25137
25331
|
deploy: ` deploy status [--json]
|
|
25138
25332
|
deploy watch --sha <sha> --target <name>
|
|
25139
25333
|
Watch a declared deploy and smoke check; failures pause merges.
|
|
@@ -25491,6 +25685,7 @@ var TICKET_OPTION = new Set([
|
|
|
25491
25685
|
"unreserve"
|
|
25492
25686
|
]);
|
|
25493
25687
|
var CONFIG_OPTION = new Set([
|
|
25688
|
+
"config",
|
|
25494
25689
|
"acceptance",
|
|
25495
25690
|
"lint",
|
|
25496
25691
|
"job",
|
|
@@ -25566,6 +25761,7 @@ Files:
|
|
|
25566
25761
|
credentials KEY=value lines, mode 0600, written by \`armada auth login\` and
|
|
25567
25762
|
\`armada login\` (the sign-in: ARMADA_SESSION_TOKEN or ARMADA_API_KEY)
|
|
25568
25763
|
config.toml personal defaults: language, [dashboard] url, [api] url
|
|
25764
|
+
projects/<slug>.json non-secret deploy settings for this project and machine
|
|
25569
25765
|
coordinators.json coordinator role per project and checkout
|
|
25570
25766
|
watch/<project>[@<name>].* the coordinator's watch: its lock, what you were shown, who is in flight
|
|
25571
25767
|
releases.json daily release notices in status/inbox, with version and time.
|
|
@@ -26061,6 +26257,10 @@ async function dispatch(argv, io) {
|
|
|
26061
26257
|
});
|
|
26062
26258
|
return await heartbeat2(io, config, credentials, { ...args, config: path });
|
|
26063
26259
|
}
|
|
26260
|
+
if (args.command === "config") {
|
|
26261
|
+
const { path, text } = await findConfig(io, args.config, "config", args.project);
|
|
26262
|
+
return await configCommand(io, parseConfig(text, path), args);
|
|
26263
|
+
}
|
|
26064
26264
|
if (args.command === "deploy") {
|
|
26065
26265
|
const { path, text } = await findConfig(io, args.config, "deploy", args.project);
|
|
26066
26266
|
const config = parseConfig(text, path);
|