@the-vibe-company/armada 0.2.59 → 0.2.61
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 +13 -0
- package/dist/armada.js +382 -83
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -706,4 +706,17 @@ pause_on_failure = true
|
|
|
706
706
|
|
|
707
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
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
|
+
|
|
709
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
|
@@ -1488,7 +1488,7 @@ import { hostname as hostname2 } from "node:os";
|
|
|
1488
1488
|
import { isatty } from "node:tty";
|
|
1489
1489
|
|
|
1490
1490
|
// src/cli.ts
|
|
1491
|
-
import { basename as basename4, dirname as
|
|
1491
|
+
import { basename as basename4, dirname as dirname14, join as join11, resolve as resolve8 } from "node:path";
|
|
1492
1492
|
|
|
1493
1493
|
// ../core/src/merge.ts
|
|
1494
1494
|
var import_picomatch2 = __toESM(require_picomatch2(), 1);
|
|
@@ -2039,6 +2039,18 @@ function selectDeployTargets(targets, branch, coverage) {
|
|
|
2039
2039
|
}
|
|
2040
2040
|
return { targets: selected, skipped };
|
|
2041
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
|
+
}
|
|
2042
2054
|
function deployDetail(output) {
|
|
2043
2055
|
const lines = output.trim().split(`
|
|
2044
2056
|
`).slice(-30).join(`
|
|
@@ -2062,7 +2074,7 @@ async function watchDeploy(o) {
|
|
|
2062
2074
|
sha: o.sha,
|
|
2063
2075
|
state,
|
|
2064
2076
|
detail: deployDetail(detail),
|
|
2065
|
-
pauseOnFailure: o.target.pauseOnFailure,
|
|
2077
|
+
pauseOnFailure: state !== "not-runnable" && o.target.pauseOnFailure,
|
|
2066
2078
|
liveSha
|
|
2067
2079
|
});
|
|
2068
2080
|
await record("waiting");
|
|
@@ -2090,6 +2102,10 @@ async function watchDeploy(o) {
|
|
|
2090
2102
|
if (live) {
|
|
2091
2103
|
detail = live.detail;
|
|
2092
2104
|
liveSha = live.sha;
|
|
2105
|
+
if (live.notRunnable) {
|
|
2106
|
+
await record("not-runnable");
|
|
2107
|
+
return "not-runnable";
|
|
2108
|
+
}
|
|
2093
2109
|
let includes = live.sha === o.sha;
|
|
2094
2110
|
if (live.sha && !includes) {
|
|
2095
2111
|
try {
|
|
@@ -2112,6 +2128,10 @@ could not compare the live commit; retrying`;
|
|
|
2112
2128
|
result = { ok: null, detail: "could not read or record shared smoke state; retrying" };
|
|
2113
2129
|
}
|
|
2114
2130
|
detail = result.detail;
|
|
2131
|
+
if (result.notRunnable) {
|
|
2132
|
+
await record("not-runnable");
|
|
2133
|
+
return "not-runnable";
|
|
2134
|
+
}
|
|
2115
2135
|
if (result.ok !== null) {
|
|
2116
2136
|
const state = result.ok ? "healthy" : "smoke-failed";
|
|
2117
2137
|
await record(state);
|
|
@@ -2129,7 +2149,7 @@ ${detail}`;
|
|
|
2129
2149
|
}
|
|
2130
2150
|
function deployLine(row, now) {
|
|
2131
2151
|
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" : ""}` : ""}`;
|
|
2152
|
+
return `${row.target}: ${row.state === "skipped" ? "skipped (not configured on this machine)" : row.state === "not-runnable" ? "not runnable (configuration)" : 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
2153
|
}
|
|
2134
2154
|
|
|
2135
2155
|
// ../../node_modules/.bun/smol-toml@1.9.0/node_modules/smol-toml/dist/error.js
|
|
@@ -3134,10 +3154,53 @@ var RUNNER = /No space left on device|The runner has received a shutdown signal|
|
|
|
3134
3154
|
function ciLine(line) {
|
|
3135
3155
|
return line.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").replace(/^\d{4}-\d\d-\d\dT[\d:.]+Z\s?/, "").replace(/\r$/, "").slice(0, 1000);
|
|
3136
3156
|
}
|
|
3157
|
+
function summaryDependencies(check, log) {
|
|
3158
|
+
if (!log || log.warnings.length || check.conclusion !== "FAILURE" || !check.steps?.length)
|
|
3159
|
+
return [];
|
|
3160
|
+
const exitError = "##[error]Process completed with exit code 1.";
|
|
3161
|
+
const gateNotice = (text) => !text?.trim() || [exitError, "Process completed with exit code 1."].includes(text.trim());
|
|
3162
|
+
if (!gateNotice(check.summary) || check.annotations.some((a) => !gateNotice(a.title) || !gateNotice(a.message)))
|
|
3163
|
+
return [];
|
|
3164
|
+
if (log.lines.some((line) => line.length > 1000))
|
|
3165
|
+
return [];
|
|
3166
|
+
if (check.steps.filter((s) => s.conclusion === "failure").length !== 1)
|
|
3167
|
+
return [];
|
|
3168
|
+
const setup = check.steps[0];
|
|
3169
|
+
const complete = check.steps.at(-1);
|
|
3170
|
+
if (setup?.name !== "Set up job" || setup.number !== 1 || setup.conclusion !== "success" || complete?.name !== "Complete job" || complete.conclusion !== "success" || complete.number !== Math.max(...check.steps.map((s) => s.number)))
|
|
3171
|
+
return [];
|
|
3172
|
+
const userSteps = check.steps.slice(1, -1);
|
|
3173
|
+
if (userSteps.filter((s) => s.conclusion === "failure").length !== 1 || userSteps.some((s) => s.conclusion !== "failure" && s.conclusion !== "skipped"))
|
|
3174
|
+
return [];
|
|
3175
|
+
const lines = log.lines.map(ciLine).map((l) => l.trim()).filter(Boolean);
|
|
3176
|
+
if (lines.filter((l) => l.includes("##[error]")).join(`
|
|
3177
|
+
`) !== exitError)
|
|
3178
|
+
return [];
|
|
3179
|
+
if (lines.filter((l) => l.startsWith("##[group]Run ")).length !== 1)
|
|
3180
|
+
return [];
|
|
3181
|
+
const start = lines.findIndex((l) => l.startsWith('##[group]Run echo "Dependency failed: '));
|
|
3182
|
+
const end = lines.indexOf("##[endgroup]", start);
|
|
3183
|
+
const failed = lines.indexOf(exitError, end);
|
|
3184
|
+
if (start < 0 || end < 0 || failed < 0)
|
|
3185
|
+
return [];
|
|
3186
|
+
const script = lines.slice(start + 1, end).filter((l) => !l.startsWith("shell: "));
|
|
3187
|
+
if (script.pop() !== "exit 1" || !script.length)
|
|
3188
|
+
return [];
|
|
3189
|
+
const commands = script.map((l) => l.match(/^echo "Dependency failed: ([^"$`\\]+)"$/)?.[1]);
|
|
3190
|
+
if (commands.some((name) => !name))
|
|
3191
|
+
return [];
|
|
3192
|
+
if (lines[start] !== `##[group]Run ${script[0]}`)
|
|
3193
|
+
return [];
|
|
3194
|
+
const output = lines.slice(end + 1, failed);
|
|
3195
|
+
if (output.length !== commands.length || output.some((l, i) => l !== `Dependency failed: ${commands[i]}`))
|
|
3196
|
+
return [];
|
|
3197
|
+
return [...new Set(commands)];
|
|
3198
|
+
}
|
|
3137
3199
|
function explainChecks(checks, logs, config) {
|
|
3138
3200
|
const patterns = [...(config?.failurePatterns ?? []).map(failurePattern), ...TEST_PATTERNS];
|
|
3139
|
-
|
|
3201
|
+
const explanations = checks.map((check) => {
|
|
3140
3202
|
const log = check.id === null ? [] : (logs.get(check.id)?.lines ?? []).map(ciLine);
|
|
3203
|
+
const dependencyCandidate = log.some((line) => line.trim().startsWith('##[group]Run echo "Dependency failed: '));
|
|
3141
3204
|
const annotations = check.annotations.flatMap((a) => [a.title ?? "", ...a.message.split(`
|
|
3142
3205
|
`)]).map(ciLine);
|
|
3143
3206
|
const summary = (check.summary ?? "").split(`
|
|
@@ -3166,9 +3229,9 @@ function explainChecks(checks, logs, config) {
|
|
|
3166
3229
|
`))) : [];
|
|
3167
3230
|
const unknownNames = names.filter((name) => !matches(name).length && !blockMatches.length);
|
|
3168
3231
|
const matched = [...new Set([...names.flatMap(matches), ...blockMatches])];
|
|
3169
|
-
const known = !unknownNames.length ? matched[0] : undefined;
|
|
3232
|
+
const known = !dependencyCandidate && !unknownNames.length ? matched[0] : undefined;
|
|
3170
3233
|
const knownMatches = matched.map(({ ticket, pattern }) => ({ ticket, pattern }));
|
|
3171
|
-
const runnerOnly = runner && !unknownNames.length;
|
|
3234
|
+
const runnerOnly = !dependencyCandidate && runner && !unknownNames.length;
|
|
3172
3235
|
return {
|
|
3173
3236
|
check: check.name,
|
|
3174
3237
|
conclusion: check.conclusion,
|
|
@@ -3184,6 +3247,28 @@ function explainChecks(checks, logs, config) {
|
|
|
3184
3247
|
...check.superseded ? { superseded: true } : {}
|
|
3185
3248
|
};
|
|
3186
3249
|
});
|
|
3250
|
+
let changed = true;
|
|
3251
|
+
while (changed) {
|
|
3252
|
+
changed = false;
|
|
3253
|
+
for (const [i, check] of checks.entries()) {
|
|
3254
|
+
const explanation = explanations[i];
|
|
3255
|
+
if (explanation?.class !== "failure" || explanation.tests.length || check.runId === null || check.superseded)
|
|
3256
|
+
continue;
|
|
3257
|
+
const dependencies = summaryDependencies(check, check.id === null ? undefined : logs.get(check.id));
|
|
3258
|
+
if (!dependencies.length)
|
|
3259
|
+
continue;
|
|
3260
|
+
const covered = dependencies.every((name) => {
|
|
3261
|
+
const peers = checks.flatMap((c, j) => j !== i && c.name === name && c.runId === check.runId && c.headSha === check.headSha && !c.superseded ? [explanations[j]] : []);
|
|
3262
|
+
return peers.length > 0 && peers.every((e) => e && ["known", "runner", "dependent"].includes(e.class));
|
|
3263
|
+
});
|
|
3264
|
+
if (covered) {
|
|
3265
|
+
explanation.class = "dependent";
|
|
3266
|
+
explanation.dependencies = dependencies;
|
|
3267
|
+
changed = true;
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
return explanations;
|
|
3187
3272
|
}
|
|
3188
3273
|
function rerunDecision(explanations, attempt) {
|
|
3189
3274
|
const refuse = (reason) => ({ allowed: false, reason, tickets: [] });
|
|
@@ -3194,9 +3279,11 @@ function rerunDecision(explanations, attempt) {
|
|
|
3194
3279
|
const failures = explanations.filter((e) => !e.superseded);
|
|
3195
3280
|
if (!failures.length)
|
|
3196
3281
|
return refuse("No failing checks to rerun");
|
|
3197
|
-
const unknown = failures.filter((e) =>
|
|
3282
|
+
const unknown = failures.filter((e) => !["known", "runner", "dependent"].includes(e.class));
|
|
3198
3283
|
if (unknown.length)
|
|
3199
3284
|
return refuse(`unknown or external failures: ${unknown.map((e) => e.check).join("; ")}`);
|
|
3285
|
+
if (!failures.some((e) => e.class === "known" || e.class === "runner"))
|
|
3286
|
+
return refuse("No real failing checks to rerun");
|
|
3200
3287
|
if (failures.some((e) => e.class === "known" && !e.known))
|
|
3201
3288
|
return refuse("known failure has no root-cause ticket");
|
|
3202
3289
|
return {
|
|
@@ -3494,6 +3581,9 @@ function overlapLines(reading) {
|
|
|
3494
3581
|
}
|
|
3495
3582
|
|
|
3496
3583
|
// ../core/src/config.ts
|
|
3584
|
+
function deployEnvName(name) {
|
|
3585
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name) && !["__proto__", "constructor", "prototype", "ARMADA_DEPLOY_SHA", "ARMADA_DEPLOY_TARGET"].includes(name);
|
|
3586
|
+
}
|
|
3497
3587
|
var CONFIG_FILE = "armada.toml";
|
|
3498
3588
|
var PLAN_POLICIES = ["approve", "pre-approved"];
|
|
3499
3589
|
var routingLabelKey = (name) => name.normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{M}\p{N}]/gu, "");
|
|
@@ -3912,6 +4002,7 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
3912
4002
|
"name",
|
|
3913
4003
|
"branch",
|
|
3914
4004
|
"paths",
|
|
4005
|
+
"requires_env",
|
|
3915
4006
|
"github_environment",
|
|
3916
4007
|
"live_sha_command",
|
|
3917
4008
|
"smoke",
|
|
@@ -3939,7 +4030,10 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
3939
4030
|
if (problem || Array.isArray(row.paths) && !row.paths.length)
|
|
3940
4031
|
problems.push(`"${path}.paths": ${problem ?? "must not be empty"}`);
|
|
3941
4032
|
}
|
|
4033
|
+
if (row.requires_env !== undefined && (!Array.isArray(row.requires_env) || row.requires_env.some((name) => typeof name !== "string" || !deployEnvName(name))))
|
|
4034
|
+
problems.push(`"${path}.requires_env" must be an array of environment variable names (excluding reserved names)`);
|
|
3942
4035
|
deployTargets.push({
|
|
4036
|
+
...Array.isArray(row.requires_env) ? { requiresEnv: [...new Set(row.requires_env)] } : {},
|
|
3943
4037
|
...Array.isArray(row.paths) ? { paths: row.paths } : {},
|
|
3944
4038
|
name,
|
|
3945
4039
|
branch: optional("branch"),
|
|
@@ -4301,7 +4395,10 @@ repository = ${q(p.repository)}
|
|
|
4301
4395
|
# paths = ["cmd/**", "internal/**"] # optional: only watch merges touching these globs
|
|
4302
4396
|
# github_environment = "production"
|
|
4303
4397
|
## Alternative to github_environment (choose exactly one live source):
|
|
4304
|
-
## live_sha_command = "
|
|
4398
|
+
## live_sha_command = 'cd "$DEPLOY_LINK_DIR" && hosting-cli live-sha'
|
|
4399
|
+
## requires_env = ["DEPLOY_LINK_DIR"]
|
|
4400
|
+
## On each coordinator machine: armada config set deploy.env.DEPLOY_LINK_DIR /path/to/linked-service
|
|
4401
|
+
## Machine settings win over the process environment; missing settings skip without a hold.
|
|
4305
4402
|
# smoke = "curl -fsS https://example.test/health"
|
|
4306
4403
|
# timeout_minutes = 20 # 1–120; smoke shares this deadline
|
|
4307
4404
|
# pause_on_failure = true
|
|
@@ -7453,6 +7550,22 @@ async function fetchJobLog(opts) {
|
|
|
7453
7550
|
return { lines: [], warnings };
|
|
7454
7551
|
}
|
|
7455
7552
|
}
|
|
7553
|
+
async function fetchJobSteps(opts) {
|
|
7554
|
+
return httpRequest(`${GITHUB_REST}/repos/${opts.repository}/actions/jobs/${opts.jobId}`, { headers: { Authorization: `Bearer ${opts.token}`, Accept: "application/vnd.github+json" } }, { ...opts, retry: true, retryStatus, service: "GitHub" }, async (res) => {
|
|
7555
|
+
if (!res.ok)
|
|
7556
|
+
throw new GithubError(`GitHub Actions HTTP ${res.status} reading job steps`);
|
|
7557
|
+
const job = await res.json();
|
|
7558
|
+
if (!job || job.id !== opts.jobId || job.run_id !== opts.runId || job.head_sha !== opts.sha || job.name !== opts.name || job.status !== "completed" || job.conclusion !== "failure" || !Array.isArray(job.steps) || !job.steps.length || job.steps.some((s) => !s || typeof s.name !== "string" || s.conclusion !== null && typeof s.conclusion !== "string" || !Number.isSafeInteger(s.number) || (s.number ?? 0) < 1))
|
|
7559
|
+
throw new GithubError("GitHub Actions returned incomplete or mismatched job steps");
|
|
7560
|
+
if (new Set(job.steps.map((s) => s.number)).size !== job.steps.length)
|
|
7561
|
+
throw new GithubError("GitHub Actions returned duplicate step numbers");
|
|
7562
|
+
return job.steps.map((s) => ({
|
|
7563
|
+
name: s.name,
|
|
7564
|
+
conclusion: s.conclusion,
|
|
7565
|
+
number: s.number
|
|
7566
|
+
}));
|
|
7567
|
+
});
|
|
7568
|
+
}
|
|
7456
7569
|
async function fetchRunAttempt(opts) {
|
|
7457
7570
|
return (await fetchWorkflowRun(opts)).attempt;
|
|
7458
7571
|
}
|
|
@@ -10939,6 +11052,58 @@ async function ensurePersonalConfig(paths) {
|
|
|
10939
11052
|
await writePrivate(paths, paths.config, PERSONAL_CONFIG_TEMPLATE, 420);
|
|
10940
11053
|
return true;
|
|
10941
11054
|
}
|
|
11055
|
+
var projectSettingsPath = (paths, project) => {
|
|
11056
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(project))
|
|
11057
|
+
throw new Error("invalid project slug");
|
|
11058
|
+
return join(paths.dir, "projects", `${project}.json`);
|
|
11059
|
+
};
|
|
11060
|
+
async function readDeployEnv(paths, project) {
|
|
11061
|
+
const empty = { env: {}, warning: null };
|
|
11062
|
+
if (!paths)
|
|
11063
|
+
return empty;
|
|
11064
|
+
const path = projectSettingsPath(paths, project);
|
|
11065
|
+
let text;
|
|
11066
|
+
try {
|
|
11067
|
+
text = await readFile(path, "utf8");
|
|
11068
|
+
} catch (err) {
|
|
11069
|
+
if (missing(err))
|
|
11070
|
+
return empty;
|
|
11071
|
+
return {
|
|
11072
|
+
env: {},
|
|
11073
|
+
warning: `cannot read project machine settings in ${path}: ${err.code ?? "unknown error"}; using the process environment`
|
|
11074
|
+
};
|
|
11075
|
+
}
|
|
11076
|
+
try {
|
|
11077
|
+
const raw = JSON.parse(text);
|
|
11078
|
+
if (!isTable3(raw) || !isTable3(raw.deploy) || !isTable3(raw.deploy.env))
|
|
11079
|
+
throw new Error;
|
|
11080
|
+
const env = {};
|
|
11081
|
+
for (const [name, value] of Object.entries(raw.deploy.env)) {
|
|
11082
|
+
if (!deployEnvName(name) || typeof value !== "string" || !value.trim() || value.includes("\x00"))
|
|
11083
|
+
throw new Error;
|
|
11084
|
+
env[name] = value;
|
|
11085
|
+
}
|
|
11086
|
+
return { env, warning: null };
|
|
11087
|
+
} catch {
|
|
11088
|
+
return {
|
|
11089
|
+
env: {},
|
|
11090
|
+
warning: `invalid project machine settings in ${path}; using the process environment. armada config set repairs this file`
|
|
11091
|
+
};
|
|
11092
|
+
}
|
|
11093
|
+
}
|
|
11094
|
+
async function updateDeployEnv(paths, project, name, value) {
|
|
11095
|
+
if (!deployEnvName(name))
|
|
11096
|
+
throw new Error("invalid deploy environment variable name");
|
|
11097
|
+
if (value !== null && (!value.trim() || value.includes("\x00")))
|
|
11098
|
+
throw new Error("deploy setting must be a non-empty string without NUL");
|
|
11099
|
+
const { env } = await readDeployEnv(paths, project);
|
|
11100
|
+
if (value === null)
|
|
11101
|
+
delete env[name];
|
|
11102
|
+
else
|
|
11103
|
+
env[name] = value;
|
|
11104
|
+
await writePrivate(paths, projectSettingsPath(paths, project), `${JSON.stringify({ deploy: { env } }, null, 2)}
|
|
11105
|
+
`, 384);
|
|
11106
|
+
}
|
|
10942
11107
|
function watchFiles(paths, project, name = "default") {
|
|
10943
11108
|
if (!COORDINATOR.test(name))
|
|
10944
11109
|
throw new Error("invalid coordinator name");
|
|
@@ -15804,7 +15969,7 @@ ${attachments.join(`
|
|
|
15804
15969
|
};
|
|
15805
15970
|
}
|
|
15806
15971
|
// package.json
|
|
15807
|
-
var version = "0.2.
|
|
15972
|
+
var version = "0.2.61";
|
|
15808
15973
|
|
|
15809
15974
|
// src/io.ts
|
|
15810
15975
|
class UsageError extends Error {
|
|
@@ -17354,7 +17519,7 @@ class ClaudeCodeAdapter {
|
|
|
17354
17519
|
}
|
|
17355
17520
|
|
|
17356
17521
|
// src/doctor.ts
|
|
17357
|
-
import { join as join4 } from "node:path";
|
|
17522
|
+
import { dirname as dirname4, join as join4, resolve as resolve2 } from "node:path";
|
|
17358
17523
|
|
|
17359
17524
|
// src/local-tools.ts
|
|
17360
17525
|
import { stripVTControlCharacters as stripVTControlCharacters3 } from "node:util";
|
|
@@ -17823,8 +17988,8 @@ function keyFileChecks(machine, credentials) {
|
|
|
17823
17988
|
}
|
|
17824
17989
|
];
|
|
17825
17990
|
}
|
|
17826
|
-
async function projectConfig(
|
|
17827
|
-
const text = await
|
|
17991
|
+
async function projectConfig(view) {
|
|
17992
|
+
const text = await view.readFile(CONFIG_FILE);
|
|
17828
17993
|
if (text === null)
|
|
17829
17994
|
return null;
|
|
17830
17995
|
try {
|
|
@@ -18193,11 +18358,20 @@ async function localRuntimeChecks(io, config, options = { readOnly: true }) {
|
|
|
18193
18358
|
];
|
|
18194
18359
|
}
|
|
18195
18360
|
async function buildDoctor(io, armadaVersion, options = { readOnly: true }) {
|
|
18196
|
-
const
|
|
18361
|
+
const selected = options.configPath || io.env.ARMADA_CONFIG?.trim();
|
|
18362
|
+
const configPath = selected ? resolve2(io.cwd, selected) : null;
|
|
18363
|
+
const checkout = configPath ? dirname4(configPath) : io.cwd;
|
|
18364
|
+
const root = (io.exec ? await gitRoot(io.exec, checkout) : null) ?? checkout;
|
|
18365
|
+
const repository = fsRepoView(root);
|
|
18366
|
+
const view = configPath ? {
|
|
18367
|
+
...repository,
|
|
18368
|
+
readFile: (path) => path === CONFIG_FILE ? io.readFile(configPath) : repository.readFile(path)
|
|
18369
|
+
} : repository;
|
|
18370
|
+
const configFlag = configPath ? ` --config ${shellWord(configPath)}` : "";
|
|
18197
18371
|
const upgrade = (err) => err instanceof ArmadaApiError && err.upgrade ? err : null;
|
|
18198
18372
|
let outdated = null;
|
|
18199
18373
|
let loaded;
|
|
18200
|
-
const config = await projectConfig(
|
|
18374
|
+
const config = await projectConfig(view);
|
|
18201
18375
|
try {
|
|
18202
18376
|
loaded = await loadCredentials(io, config ? { project: config.project.slug } : {});
|
|
18203
18377
|
} catch (err) {
|
|
@@ -18218,11 +18392,34 @@ async function buildDoctor(io, armadaVersion, options = { readOnly: true }) {
|
|
|
18218
18392
|
}
|
|
18219
18393
|
const signing = await readSigning(io, root);
|
|
18220
18394
|
const checks = [
|
|
18221
|
-
...await checkRepository(
|
|
18395
|
+
...await checkRepository(view, armadaVersion),
|
|
18222
18396
|
...config ? optionalFeatures(config) : [],
|
|
18223
18397
|
...signIn,
|
|
18224
18398
|
...versionChecks(hostOf(credentials.armadaApi.url), api, armadaVersion, outdated),
|
|
18225
18399
|
...keyFileChecks(machine, credentials),
|
|
18400
|
+
...await (async () => {
|
|
18401
|
+
if (!config?.deploy?.targets.length)
|
|
18402
|
+
return [];
|
|
18403
|
+
const local = await readDeployEnv(machine.paths, config.project.slug);
|
|
18404
|
+
const checks = config.deploy.targets.map((target) => {
|
|
18405
|
+
const { missing } = resolveDeployEnv(target, local.env, io.env);
|
|
18406
|
+
return {
|
|
18407
|
+
id: `deploy-env:${target.name}`,
|
|
18408
|
+
level: missing.length ? "warning" : "ok",
|
|
18409
|
+
message: missing.length ? `${target.name}: ${missing.join(", ")} not set on this machine; deploy check will be skipped` : `${target.name}: required deploy settings are configured`,
|
|
18410
|
+
fix: missing.length ? missing.map((name) => `armada config set deploy.env.${name} <value>${configFlag}`).join(`
|
|
18411
|
+
`) : null
|
|
18412
|
+
};
|
|
18413
|
+
});
|
|
18414
|
+
if (local.warning)
|
|
18415
|
+
checks.unshift({
|
|
18416
|
+
id: "deploy-machine-settings",
|
|
18417
|
+
level: "warning",
|
|
18418
|
+
message: local.warning,
|
|
18419
|
+
fix: checks.find((c) => c.fix)?.fix ?? `armada config set deploy.env.<VAR> <value>${configFlag}`
|
|
18420
|
+
});
|
|
18421
|
+
return checks;
|
|
18422
|
+
})(),
|
|
18226
18423
|
{
|
|
18227
18424
|
id: "linear-key",
|
|
18228
18425
|
level: credentials.sources.linearApiKey ? "ok" : "warning",
|
|
@@ -18252,7 +18449,7 @@ async function buildDoctor(io, armadaVersion, options = { readOnly: true }) {
|
|
|
18252
18449
|
fix: null
|
|
18253
18450
|
}
|
|
18254
18451
|
] : [],
|
|
18255
|
-
...await localRuntimeChecks(io, config, { ...options, configPath: join4(root, CONFIG_FILE) }),
|
|
18452
|
+
...await localRuntimeChecks(io, config, { ...options, configPath: configPath ?? join4(root, CONFIG_FILE) }),
|
|
18256
18453
|
...config ? await reviewRuntimeChecks(io, root) : [],
|
|
18257
18454
|
...await secretChecks(api, config, credentials)
|
|
18258
18455
|
];
|
|
@@ -18291,8 +18488,8 @@ function renderDoctor(r) {
|
|
|
18291
18488
|
`)}
|
|
18292
18489
|
`;
|
|
18293
18490
|
}
|
|
18294
|
-
async function doctor(io, json, armadaVersion, deep = false) {
|
|
18295
|
-
const report = await buildDoctor(io, armadaVersion, { readOnly: json, deep });
|
|
18491
|
+
async function doctor(io, json, armadaVersion, deep = false, configPath) {
|
|
18492
|
+
const report = await buildDoctor(io, armadaVersion, { readOnly: json, deep, configPath });
|
|
18296
18493
|
io.stdout(json ? `${JSON.stringify(report, null, 2)}
|
|
18297
18494
|
` : renderDoctor(report));
|
|
18298
18495
|
return report.errors ? 1 : 0;
|
|
@@ -19833,7 +20030,7 @@ ${result.stderr}`, secrets) + detail : `Command failed; diagnostics withheld bec
|
|
|
19833
20030
|
}
|
|
19834
20031
|
|
|
19835
20032
|
// src/attach.ts
|
|
19836
|
-
import { resolve as
|
|
20033
|
+
import { resolve as resolve3 } from "node:path";
|
|
19837
20034
|
async function attachItems(io, config, credentials, target) {
|
|
19838
20035
|
const ticket = target.ticket.toUpperCase();
|
|
19839
20036
|
if (!/^[A-Z][A-Z0-9]*-\d+$/.test(ticket))
|
|
@@ -19859,7 +20056,7 @@ async function attachItems(io, config, credentials, target) {
|
|
|
19859
20056
|
} else {
|
|
19860
20057
|
if (!io.readBinaryFile)
|
|
19861
20058
|
throw new UsageError("this CLI cannot read attachment files");
|
|
19862
|
-
const bytes = await io.readBinaryFile(
|
|
20059
|
+
const bytes = await io.readBinaryFile(resolve3(io.cwd, item), MAX_ATTACHMENT_BYTES);
|
|
19863
20060
|
if (!bytes)
|
|
19864
20061
|
throw new UsageError(`attachment file not found: ${item}`);
|
|
19865
20062
|
const contentType = attachmentImageType(bytes) ?? "";
|
|
@@ -19896,7 +20093,7 @@ async function attachCommand(io, config, credentials, args) {
|
|
|
19896
20093
|
}
|
|
19897
20094
|
|
|
19898
20095
|
// src/brief.ts
|
|
19899
|
-
import { dirname as
|
|
20096
|
+
import { dirname as dirname7, join as join5 } from "node:path";
|
|
19900
20097
|
|
|
19901
20098
|
// src/plan-approval.ts
|
|
19902
20099
|
function preApprovalReason(options) {
|
|
@@ -19941,7 +20138,7 @@ async function preparePreApproval(io, config, credentials, briefTicket, reason)
|
|
|
19941
20138
|
}
|
|
19942
20139
|
|
|
19943
20140
|
// src/watch.ts
|
|
19944
|
-
import { dirname as
|
|
20141
|
+
import { dirname as dirname6 } from "node:path";
|
|
19945
20142
|
|
|
19946
20143
|
// src/inbox.ts
|
|
19947
20144
|
var DEFAULT_WAIT_SECONDS = 300;
|
|
@@ -20110,7 +20307,7 @@ async function inbox2(io, config, credentials, a) {
|
|
|
20110
20307
|
}
|
|
20111
20308
|
|
|
20112
20309
|
// src/job.ts
|
|
20113
|
-
import { dirname as
|
|
20310
|
+
import { dirname as dirname5 } from "node:path";
|
|
20114
20311
|
function definition(config, name) {
|
|
20115
20312
|
const job = Object.hasOwn(config.jobs ?? {}, name) ? config.jobs[name] : undefined;
|
|
20116
20313
|
if (!job)
|
|
@@ -20175,7 +20372,7 @@ async function jobCommand(io, config, credentials, args, configPath) {
|
|
|
20175
20372
|
if (!fleet)
|
|
20176
20373
|
throw new UsageError("jobs need a sign-in to Armada", "armada login");
|
|
20177
20374
|
const now = () => io.now?.() ?? new Date;
|
|
20178
|
-
const root =
|
|
20375
|
+
const root = dirname5(configPath);
|
|
20179
20376
|
const print = (jobs) => io.stdout(args.json ? `${JSON.stringify(jobs, null, 2)}
|
|
20180
20377
|
` : jobs.length ? jobs.map((j) => renderJob(j, config, now())).join("") : `No jobs.
|
|
20181
20378
|
`);
|
|
@@ -20621,9 +20818,9 @@ function watchDeadline(until, clock, expire, schedule = (run, ms) => {
|
|
|
20621
20818
|
async function watchUntil(io, config, credentials, json, configPath, options) {
|
|
20622
20819
|
requireSignIn(credentials);
|
|
20623
20820
|
const project = config.project.slug;
|
|
20624
|
-
const name = await coordinatorName(io, project,
|
|
20821
|
+
const name = await coordinatorName(io, project, dirname6(configPath));
|
|
20625
20822
|
const scope = options.scope ?? (name === "default" ? "all" : "mine");
|
|
20626
|
-
io = { ...io, coordinatorRoot:
|
|
20823
|
+
io = { ...io, coordinatorRoot: dirname6(configPath), env: { ...io.env, ARMADA_COORDINATOR: name } };
|
|
20627
20824
|
const paths = machinePaths(io.env);
|
|
20628
20825
|
const pid = io.pid ?? process.pid;
|
|
20629
20826
|
const controller = new AbortController;
|
|
@@ -20690,13 +20887,13 @@ async function watchUntil(io, config, credentials, json, configPath, options) {
|
|
|
20690
20887
|
if (!fleet)
|
|
20691
20888
|
throw new Refusal(`the inbox is on Armada, which cannot be reached: ${warning ?? "no answer"}`, "armada whoami");
|
|
20692
20889
|
const before = paths ? await readWatchState(paths, project, name) : null;
|
|
20693
|
-
await remember(io, project, { root:
|
|
20890
|
+
await remember(io, project, { root: dirname6(configPath), stopped: null });
|
|
20694
20891
|
if (until && !io.sleep)
|
|
20695
20892
|
cancelDeadline = watchDeadline(until, () => now(io), () => {
|
|
20696
20893
|
timedOut = true;
|
|
20697
20894
|
controller.abort(new Error("watch duration ended"));
|
|
20698
20895
|
});
|
|
20699
|
-
const watchingFleet = refreshingJobsFleet(watchingIo, observingFleet(watchingIo, fleet, config), config,
|
|
20896
|
+
const watchingFleet = refreshingJobsFleet(watchingIo, observingFleet(watchingIo, fleet, config), config, dirname6(configPath), controller.signal);
|
|
20700
20897
|
const common = {
|
|
20701
20898
|
until,
|
|
20702
20899
|
project,
|
|
@@ -20729,7 +20926,7 @@ async function watchUntil(io, config, credentials, json, configPath, options) {
|
|
|
20729
20926
|
},
|
|
20730
20927
|
onRetry: (message) => io.stderr(`armada: warning: ${message}
|
|
20731
20928
|
`),
|
|
20732
|
-
release: pendingRelease(watchingIo, version, before?.seen ?? [], fsRepoView(
|
|
20929
|
+
release: pendingRelease(watchingIo, version, before?.seen ?? [], fsRepoView(dirname6(configPath)))
|
|
20733
20930
|
};
|
|
20734
20931
|
if (options.follow) {
|
|
20735
20932
|
const cursor = options.cursor ?? before?.cursor ?? eventCursor(0, now(io).toISOString());
|
|
@@ -20816,8 +21013,8 @@ async function hookStop(io, rest, findConfig) {
|
|
|
20816
21013
|
const cwd = typeof input.cwd === "string" && input.cwd ? input.cwd : io.cwd;
|
|
20817
21014
|
const { path, text } = await findConfig({ ...io, cwd });
|
|
20818
21015
|
const project = parseConfig(text, path).project.slug;
|
|
20819
|
-
const { state, running } = await watchOf({ ...io, coordinatorRoot:
|
|
20820
|
-
const d = stopHookDecision({ project, root:
|
|
21016
|
+
const { state, running } = await watchOf({ ...io, coordinatorRoot: dirname6(path) }, project);
|
|
21017
|
+
const d = stopHookDecision({ project, root: dirname6(path), state, watching: running, env: io.env });
|
|
20821
21018
|
if (d.block)
|
|
20822
21019
|
io.stdout(`${JSON.stringify({ decision: "block", reason: d.reason })}
|
|
20823
21020
|
`);
|
|
@@ -20949,7 +21146,7 @@ async function brief2(io, config, credentials, a, version, configPath) {
|
|
|
20949
21146
|
if (!credentials.linearApiKey)
|
|
20950
21147
|
throw missingKey(LINEAR_KEY);
|
|
20951
21148
|
const extraPath = config.brief.extra;
|
|
20952
|
-
const conventions = extraPath ? { path: extraPath, text: await io.readFile(join5(
|
|
21149
|
+
const conventions = extraPath ? { path: extraPath, text: await io.readFile(join5(dirname7(configPath), extraPath)).catch(() => null) } : null;
|
|
20953
21150
|
const { fleet } = liveFleet(io, config, credentials);
|
|
20954
21151
|
let b;
|
|
20955
21152
|
try {
|
|
@@ -21032,6 +21229,7 @@ ${next.line}
|
|
|
21032
21229
|
var LABELS = {
|
|
21033
21230
|
known: "known flaky test",
|
|
21034
21231
|
runner: "runner problem",
|
|
21232
|
+
dependent: "ignored as a dependent summary",
|
|
21035
21233
|
failure: "failure",
|
|
21036
21234
|
external: "external check"
|
|
21037
21235
|
};
|
|
@@ -21043,6 +21241,8 @@ function renderCiWhy(sha, explanations) {
|
|
|
21043
21241
|
lines.push("", `${e.check}: ${e.superseded ? "superseded by a newer head" : LABELS[e.class]} (${e.conclusion.toLowerCase()}${e.attempt ? `, workflow attempt ${e.attempt}` : ""})`);
|
|
21044
21242
|
if (e.tests.length)
|
|
21045
21243
|
lines.push(` Tests: ${e.tests.join("; ")}`);
|
|
21244
|
+
if (e.dependencies?.length)
|
|
21245
|
+
lines.push(` Dependencies: ${e.dependencies.join("; ")}`);
|
|
21046
21246
|
lines.push(...e.error.map((l) => ` ${l}`));
|
|
21047
21247
|
if (!e.error.length && !e.superseded)
|
|
21048
21248
|
lines.push(" No error details available; open the check link.");
|
|
@@ -21117,11 +21317,26 @@ async function ciWhy(io, config, credentials, args) {
|
|
|
21117
21317
|
check.attempt = attempts.get(check.runId);
|
|
21118
21318
|
}
|
|
21119
21319
|
}
|
|
21320
|
+
for (const check of reading.checks) {
|
|
21321
|
+
if (check.app !== "github-actions" || check.superseded || check.id === null || check.runId === null || !logs.get(check.id)?.lines.some((l) => l.includes('##[group]Run echo "Dependency failed: ')))
|
|
21322
|
+
continue;
|
|
21323
|
+
try {
|
|
21324
|
+
check.steps = await fetchJobSteps({
|
|
21325
|
+
...opts,
|
|
21326
|
+
jobId: check.id,
|
|
21327
|
+
runId: check.runId,
|
|
21328
|
+
sha: check.headSha,
|
|
21329
|
+
name: check.name
|
|
21330
|
+
});
|
|
21331
|
+
} catch {
|
|
21332
|
+
warnings.push(`job ${check.id}: dependency step evidence unavailable; treating summary as an unknown failure`);
|
|
21333
|
+
}
|
|
21334
|
+
}
|
|
21120
21335
|
const original = explainChecks(reading.checks, logs, config.ci);
|
|
21121
21336
|
const explanations = [...original];
|
|
21122
21337
|
const reruns = [];
|
|
21123
21338
|
if (args.options.rerun) {
|
|
21124
|
-
explanations.sort((a, b) => Number(
|
|
21339
|
+
explanations.sort((a, b) => Number(["known", "runner", "dependent"].includes(a.class)) - Number(["known", "runner", "dependent"].includes(b.class)));
|
|
21125
21340
|
const groups = new Map;
|
|
21126
21341
|
for (const id of reading.runIds)
|
|
21127
21342
|
groups.set(id, []);
|
|
@@ -21219,9 +21434,25 @@ ${r.runId === null ? "Rerun" : `Run ${r.runId}`}: ${r.status === "refused" ? "re
|
|
|
21219
21434
|
return reruns.some((r) => r.status !== "requested") ? 1 : 0;
|
|
21220
21435
|
}
|
|
21221
21436
|
|
|
21437
|
+
// src/config.ts
|
|
21438
|
+
async function configCommand(io, config, args) {
|
|
21439
|
+
const [action, key, value, ...extra] = args.rest;
|
|
21440
|
+
const name = key?.startsWith("deploy.env.") ? key.slice("deploy.env.".length) : "";
|
|
21441
|
+
if (!deployEnvName(name) || extra.length || (action === "set" ? value === undefined : action !== "unset" || value !== undefined))
|
|
21442
|
+
throw new UsageError("use armada config set deploy.env.<VAR> <value> or armada config unset deploy.env.<VAR>");
|
|
21443
|
+
const paths = machinePaths(io.env);
|
|
21444
|
+
if (!paths)
|
|
21445
|
+
throw new UsageError("machine settings need HOME or XDG_CONFIG_HOME");
|
|
21446
|
+
await updateDeployEnv(paths, config.project.slug, name, action === "set" ? value : null);
|
|
21447
|
+
io.stdout(args.json ? `${JSON.stringify({ project: config.project.slug, key, action })}
|
|
21448
|
+
` : `${key} ${action === "set" ? "set" : "unset"} for ${config.project.slug} on this machine.
|
|
21449
|
+
`);
|
|
21450
|
+
return 0;
|
|
21451
|
+
}
|
|
21452
|
+
|
|
21222
21453
|
// src/deploy.ts
|
|
21223
21454
|
import { createHash as createHash7, randomUUID } from "node:crypto";
|
|
21224
|
-
import { dirname as
|
|
21455
|
+
import { dirname as dirname8, join as join6 } from "node:path";
|
|
21225
21456
|
var hash = (s) => createHash7("sha256").update(s).digest("base64url");
|
|
21226
21457
|
var sleepOf2 = (io) => io.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
21227
21458
|
async function recordDeploy(io, write, input) {
|
|
@@ -21245,18 +21476,50 @@ async function deployStatus(io, config, credentials) {
|
|
|
21245
21476
|
const [rows, holds] = await Promise.all([fleet.deployState(), fleet.holds()]);
|
|
21246
21477
|
return { rows, holds: holds.filter((h) => h.kind === "deploy") };
|
|
21247
21478
|
}
|
|
21248
|
-
async function
|
|
21479
|
+
async function skipUnconfigured(io, config, credentials, target, sha, missing) {
|
|
21480
|
+
io.stderr(`armada: ${target.name}: deploy check skipped: ${missing.join(", ")} not set on this machine
|
|
21481
|
+
`);
|
|
21482
|
+
const { fleet } = liveFleet(io, config, credentials);
|
|
21483
|
+
if (sha && fleet) {
|
|
21484
|
+
try {
|
|
21485
|
+
await recordDeploy(io, fleet.recordDeploy, {
|
|
21486
|
+
target: target.name,
|
|
21487
|
+
sha,
|
|
21488
|
+
state: "skipped",
|
|
21489
|
+
detail: `skipped (not configured on this machine): ${missing.join(", ")}`,
|
|
21490
|
+
pauseOnFailure: false
|
|
21491
|
+
});
|
|
21492
|
+
} catch {
|
|
21493
|
+
io.stderr(`armada: could not record skipped deploy state
|
|
21494
|
+
`);
|
|
21495
|
+
}
|
|
21496
|
+
}
|
|
21497
|
+
}
|
|
21498
|
+
async function startDeploys(io, config, credentials, configPath, sha, targets, json) {
|
|
21249
21499
|
const results = [];
|
|
21500
|
+
const local = await readDeployEnv(machinePaths(io.env), config.project.slug);
|
|
21501
|
+
if (local.warning)
|
|
21502
|
+
io.stderr(`armada: ${local.warning}
|
|
21503
|
+
`);
|
|
21250
21504
|
for (const name of targets) {
|
|
21251
21505
|
const target = config.deploy?.targets.find((t) => t.name === name);
|
|
21252
21506
|
if (!target)
|
|
21253
21507
|
continue;
|
|
21508
|
+
const { missing, env } = resolveDeployEnv(target, local.env, io.env);
|
|
21509
|
+
if (missing.length) {
|
|
21510
|
+
await skipUnconfigured(io, config, credentials, target, sha, missing);
|
|
21511
|
+
results.push({ target: name, started: false, next: null, skipped: true });
|
|
21512
|
+
continue;
|
|
21513
|
+
}
|
|
21254
21514
|
const args = ["deploy", "watch", "--sha", sha ?? "<merge-sha>", "--target", name, "--config", configPath];
|
|
21255
21515
|
const next = `armada ${args.map(shellWord).join(" ")}`;
|
|
21256
21516
|
let started = false;
|
|
21257
21517
|
try {
|
|
21258
21518
|
const paths = machinePaths(io.env);
|
|
21259
|
-
started = (sha ? await io.startBackground?.(args,
|
|
21519
|
+
started = (sha ? await io.startBackground?.(args, {
|
|
21520
|
+
env: { ...io.env, ...env },
|
|
21521
|
+
...paths ? { logPath: join6(paths.dir, "watch", `deploy-${hash(`${config.project.slug}/${name}/${sha}`)}.log`) } : {}
|
|
21522
|
+
}) : false) ?? false;
|
|
21260
21523
|
} catch {}
|
|
21261
21524
|
results.push({ target: name, started, next: started ? null : next });
|
|
21262
21525
|
if (!json)
|
|
@@ -21294,6 +21557,16 @@ async function deploy2(io, config, credentials, args, configPath) {
|
|
|
21294
21557
|
if (!fleet || credentials.armadaSignIn?.kind === "worker")
|
|
21295
21558
|
throw new UsageError(warning ?? "deploy watch needs an organization sign-in", "armada login");
|
|
21296
21559
|
const paths = machinePaths(io.env);
|
|
21560
|
+
const local = await readDeployEnv(paths, config.project.slug);
|
|
21561
|
+
if (local.warning)
|
|
21562
|
+
io.stderr(`armada: ${local.warning}
|
|
21563
|
+
`);
|
|
21564
|
+
const settings = resolveDeployEnv(target, local.env, io.env);
|
|
21565
|
+
if (settings.missing.length) {
|
|
21566
|
+
await skipUnconfigured(io, config, credentials, target, sha, settings.missing);
|
|
21567
|
+
io.backgroundReady?.(true);
|
|
21568
|
+
return 0;
|
|
21569
|
+
}
|
|
21297
21570
|
if (!paths)
|
|
21298
21571
|
throw new UsageError("deploy watch needs HOME or XDG_CONFIG_HOME for its PID file");
|
|
21299
21572
|
if (!io.exec)
|
|
@@ -21312,7 +21585,8 @@ async function deploy2(io, config, credentials, args, configPath) {
|
|
|
21312
21585
|
credentials.armadaSignIn?.kind === "api-key" ? credentials.armadaSignIn.key : credentials.armadaSignIn?.token,
|
|
21313
21586
|
credentials.linearApiKey,
|
|
21314
21587
|
credentials.githubToken,
|
|
21315
|
-
...config.secrets.names.map((name) => io.env[name])
|
|
21588
|
+
...config.secrets.names.map((name) => io.env[name]),
|
|
21589
|
+
...Object.values(settings.env)
|
|
21316
21590
|
].filter((value) => !!value);
|
|
21317
21591
|
const clean = (text) => redactSecrets(text, secrets);
|
|
21318
21592
|
const ancestry = new Map;
|
|
@@ -21330,7 +21604,7 @@ async function deploy2(io, config, credentials, args, configPath) {
|
|
|
21330
21604
|
base,
|
|
21331
21605
|
head
|
|
21332
21606
|
}) : (await io.exec?.("git", ["merge-base", "--is-ancestor", base, head], {
|
|
21333
|
-
cwd:
|
|
21607
|
+
cwd: dirname8(configPath),
|
|
21334
21608
|
timeoutMs: 1e4
|
|
21335
21609
|
}))?.code === 0;
|
|
21336
21610
|
if (credentials.githubToken || answer)
|
|
@@ -21348,20 +21622,30 @@ async function deploy2(io, config, credentials, args, configPath) {
|
|
|
21348
21622
|
return fleet.recordDeploy({ ...candidate, detail: clean(candidate.detail) });
|
|
21349
21623
|
}, input);
|
|
21350
21624
|
const holder = `deploy-${randomUUID()}`;
|
|
21351
|
-
const cwd =
|
|
21625
|
+
const cwd = dirname8(configPath);
|
|
21626
|
+
let configurationDetail = "";
|
|
21352
21627
|
const command = async (command, liveSha, remainingMs) => {
|
|
21353
21628
|
const result = await io.exec?.("sh", ["-c", command], {
|
|
21354
21629
|
cwd,
|
|
21355
21630
|
timeoutMs: Math.max(1, Math.min(remainingMs, 60000)),
|
|
21356
21631
|
maxOutputBytes: 64 * 1024,
|
|
21357
21632
|
processGroup: true,
|
|
21358
|
-
env: { ...io.env, ARMADA_DEPLOY_SHA: liveSha, ARMADA_DEPLOY_TARGET: target.name }
|
|
21633
|
+
env: { ...io.env, ...settings.env, ARMADA_DEPLOY_SHA: liveSha, ARMADA_DEPLOY_TARGET: target.name }
|
|
21634
|
+
}).catch((err) => {
|
|
21635
|
+
if (err.code !== "ENOENT" && err.code !== "ENOTDIR")
|
|
21636
|
+
throw err;
|
|
21637
|
+
return { code: 127, stdout: "", stderr: err.message, timedOut: false };
|
|
21359
21638
|
});
|
|
21639
|
+
const notRunnable = !!result && !result.timedOut && result.code !== 0 && (result.code === 127 || /(?:^|\n)[^\n]*(?:sh|bash|dash|zsh):[^\n]*(?:[A-Za-z_][A-Za-z0-9_]*: (?:set [A-Za-z_][A-Za-z0-9_]*|parameter (?:null or )?not set|unbound variable)|cd:[^\n]*(?:can't cd|cannot|No such file|not a directory))/i.test(result.stderr) || [...command.matchAll(/\$\{([A-Za-z_][A-Za-z0-9_]*):?\?/g)].some((match) => result.stderr.includes(`${match[1]}:`)));
|
|
21640
|
+
const detail = deployDetail(clean(`${result?.stdout ?? ""}
|
|
21641
|
+
${result?.stderr ?? ""}
|
|
21642
|
+
${result?.timedOut ? "command timed out" : `exit ${result?.code ?? 1}`}`));
|
|
21643
|
+
if (notRunnable)
|
|
21644
|
+
configurationDetail = detail;
|
|
21360
21645
|
return {
|
|
21361
21646
|
ok: result?.code === 0 && !result.timedOut,
|
|
21362
|
-
detail
|
|
21363
|
-
|
|
21364
|
-
${result?.timedOut ? "command timed out" : `exit ${result?.code ?? 1}`}`)),
|
|
21647
|
+
detail,
|
|
21648
|
+
notRunnable,
|
|
21365
21649
|
stdout: result?.stdout ?? ""
|
|
21366
21650
|
};
|
|
21367
21651
|
};
|
|
@@ -21391,9 +21675,9 @@ ${result?.timedOut ? "command timed out" : `exit ${result?.code ?? 1}`}`)),
|
|
|
21391
21675
|
target: target.name,
|
|
21392
21676
|
sha: liveSha,
|
|
21393
21677
|
liveSha,
|
|
21394
|
-
state: result.ok ? "healthy" : "smoke-failed",
|
|
21678
|
+
state: result.notRunnable ? "not-runnable" : result.ok ? "healthy" : "smoke-failed",
|
|
21395
21679
|
detail: result.detail,
|
|
21396
|
-
pauseOnFailure: target.pauseOnFailure
|
|
21680
|
+
pauseOnFailure: !result.notRunnable && target.pauseOnFailure
|
|
21397
21681
|
});
|
|
21398
21682
|
return result;
|
|
21399
21683
|
} finally {
|
|
@@ -21407,7 +21691,7 @@ ${result?.timedOut ? "command timed out" : `exit ${result?.code ?? 1}`}`)),
|
|
|
21407
21691
|
};
|
|
21408
21692
|
try {
|
|
21409
21693
|
const prior = (await fleet.deployState({ target: target.name, sha }))[0];
|
|
21410
|
-
if (prior && !["waiting", "live"].includes(prior.state)) {
|
|
21694
|
+
if (prior && !["waiting", "live", "skipped", "not-runnable"].includes(prior.state)) {
|
|
21411
21695
|
io.backgroundReady?.(true);
|
|
21412
21696
|
io.stdout(`${target.name}: ${prior.state}
|
|
21413
21697
|
`);
|
|
@@ -21424,7 +21708,7 @@ ${result?.timedOut ? "command timed out" : `exit ${result?.code ?? 1}`}`)),
|
|
|
21424
21708
|
const result = await watchDeploy({
|
|
21425
21709
|
target,
|
|
21426
21710
|
sha,
|
|
21427
|
-
...prior ? { startedAt: new Date(prior.startedAt) } : {},
|
|
21711
|
+
...prior && !["skipped", "not-runnable"].includes(prior.state) ? { startedAt: new Date(prior.startedAt) } : {},
|
|
21428
21712
|
now,
|
|
21429
21713
|
sleep: sleepOf2(io),
|
|
21430
21714
|
record: write,
|
|
@@ -21445,13 +21729,18 @@ ${result?.timedOut ? "command timed out" : `exit ${result?.code ?? 1}`}`)),
|
|
|
21445
21729
|
return {
|
|
21446
21730
|
sha: result.ok && /^[0-9a-f]{40}$/.test(liveSha) ? liveSha : null,
|
|
21447
21731
|
state: result.ok && /^[0-9a-f]{40}$/.test(liveSha) ? "success" : "pending",
|
|
21448
|
-
detail: result.detail
|
|
21732
|
+
detail: result.detail,
|
|
21733
|
+
notRunnable: result.notRunnable
|
|
21449
21734
|
};
|
|
21450
21735
|
}
|
|
21451
21736
|
});
|
|
21452
|
-
|
|
21737
|
+
if (result === "not-runnable")
|
|
21738
|
+
io.stderr(`armada: warning: ${target.name}: deploy check not runnable on this machine (configuration)
|
|
21739
|
+
${configurationDetail}
|
|
21453
21740
|
`);
|
|
21454
|
-
|
|
21741
|
+
io.stdout(`${target.name}: ${result === "not-runnable" ? "not runnable (configuration)" : result}
|
|
21742
|
+
`);
|
|
21743
|
+
return result === "healthy" || result === "not-runnable" ? 0 : 1;
|
|
21455
21744
|
} catch (err) {
|
|
21456
21745
|
io.backgroundReady?.(false);
|
|
21457
21746
|
io.stderr(`armada: deploy watcher failed: ${clean(err instanceof Error ? err.message : "unexpected failure")}
|
|
@@ -21637,10 +21926,10 @@ import { join as join9 } from "node:path";
|
|
|
21637
21926
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
21638
21927
|
import { rm as rm3 } from "node:fs/promises";
|
|
21639
21928
|
import { hostname, tmpdir } from "node:os";
|
|
21640
|
-
import { dirname as
|
|
21929
|
+
import { dirname as dirname11, join as join8 } from "node:path";
|
|
21641
21930
|
|
|
21642
21931
|
// src/after-merge.ts
|
|
21643
|
-
import { dirname as
|
|
21932
|
+
import { dirname as dirname10, resolve as resolve5 } from "node:path";
|
|
21644
21933
|
|
|
21645
21934
|
// src/deferred-launch.ts
|
|
21646
21935
|
async function launchDeferredAfterMerge(outcome, config, fleet, launch) {
|
|
@@ -21688,7 +21977,7 @@ async function launchDeferredAfterMerge(outcome, config, fleet, launch) {
|
|
|
21688
21977
|
|
|
21689
21978
|
// src/launch.ts
|
|
21690
21979
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
21691
|
-
import { basename, dirname as
|
|
21980
|
+
import { basename, dirname as dirname9, join as join7, resolve as resolve4 } from "node:path";
|
|
21692
21981
|
async function launch(io, config, credentials, args, version, configPath) {
|
|
21693
21982
|
if (args.options["when-unblocked"] || args.options.after !== undefined)
|
|
21694
21983
|
return deferLaunch(io, config, credentials, args);
|
|
@@ -21886,7 +22175,7 @@ async function prepareLaunch(io, config, credentials, args, version, configPath,
|
|
|
21886
22175
|
gaps.push(error instanceof UsageError ? error.message : "could not read the repository state");
|
|
21887
22176
|
}
|
|
21888
22177
|
runtime = runtimeFor({ ...io, cwd: repo }, config, runtimeName);
|
|
21889
|
-
const conventions = config.brief.extra ? { path: config.brief.extra, text: await io.readFile(join7(
|
|
22178
|
+
const conventions = config.brief.extra ? { path: config.brief.extra, text: await io.readFile(join7(dirname9(configPath), config.brief.extra)) } : null;
|
|
21890
22179
|
const sharedResources = await reservationsForBrief(() => fleet.reservations(), config.reservations.length > 0);
|
|
21891
22180
|
const npm = await checkPublished(version, io.fetch ?? fetch);
|
|
21892
22181
|
if (npm.state === "missing") {
|
|
@@ -22210,7 +22499,7 @@ async function readNotes(io, path) {
|
|
|
22210
22499
|
throw new UsageError("--notes - needs standard input");
|
|
22211
22500
|
text = await io.readStdin();
|
|
22212
22501
|
} else
|
|
22213
|
-
text = await io.readFile(
|
|
22502
|
+
text = await io.readFile(resolve4(io.cwd, path));
|
|
22214
22503
|
} catch {
|
|
22215
22504
|
throw new UsageError("could not read --notes; supply a readable file or - for standard input");
|
|
22216
22505
|
}
|
|
@@ -22245,7 +22534,7 @@ async function launchPlan(io, json, input) {
|
|
|
22245
22534
|
cwd: repo,
|
|
22246
22535
|
timeoutMs: 1e4
|
|
22247
22536
|
});
|
|
22248
|
-
const mainRoot = common.code === 0 && common.stdout.trim().startsWith("/") ?
|
|
22537
|
+
const mainRoot = common.code === 0 && common.stdout.trim().startsWith("/") ? dirname9(common.stdout.trim()) : repo;
|
|
22249
22538
|
const remote = await execute("git", ["ls-remote", "--symref", "origin", "HEAD"], { cwd: repo, timeoutMs: 20000 });
|
|
22250
22539
|
base = remote.code === 0 ? remote.stdout.match(/^ref:\s+refs\/heads\/(\S+)\s+HEAD/m)?.[1] ?? null : null;
|
|
22251
22540
|
if (!base)
|
|
@@ -22445,7 +22734,7 @@ async function afterMerge(io, config, credentials, outcome, opts) {
|
|
|
22445
22734
|
rest: [request.ticket],
|
|
22446
22735
|
json: false,
|
|
22447
22736
|
options: request.profile ? { profile: request.profile, reason: "deferred launch requested by the coordinator" } : {}
|
|
22448
|
-
}, version, opts.configPath ??
|
|
22737
|
+
}, version, opts.configPath ?? resolve5(io.cwd, "armada.toml"));
|
|
22449
22738
|
if (code !== 0)
|
|
22450
22739
|
throw new UsageError("the launcher did not start a worker");
|
|
22451
22740
|
return printed.join("");
|
|
@@ -22473,7 +22762,7 @@ async function archiveWorker(io, config, credentials, outcome, opts) {
|
|
|
22473
22762
|
const who = `${outcome.ticket.id} (${[a.runtime, a.handle].filter(Boolean).join(" · ") || "session unknown"})`;
|
|
22474
22763
|
return result(false, `No runtime guide is installed for ${a.runtime ?? "the worker's runtime"}, so Armada has nothing to archive for ${who}: a local session or subagent ends with its task; stop it yourself if it still runs.`);
|
|
22475
22764
|
}
|
|
22476
|
-
const configPath = opts.configPath ?
|
|
22765
|
+
const configPath = opts.configPath ? resolve5(io.cwd, opts.configPath) : null;
|
|
22477
22766
|
const recovery = `armada stop ${shellWord(outcome.ticket.id)} --merged-pr ${shellWord(outcome.pr.url)}${a.source === "armada" && a.claim?.releasedAt ? ` --claim-key ${archiveClaimKey(claimRef(a.claim))}` : ""}${configPath ? ` --config ${shellWord(configPath)}` : ""}`;
|
|
22478
22767
|
const failure = (detail) => {
|
|
22479
22768
|
const safe = redactRuntimeText(detail).replace(/\s+/g, " ").trim();
|
|
@@ -22497,7 +22786,7 @@ async function archiveWorker(io, config, credentials, outcome, opts) {
|
|
|
22497
22786
|
if (!fleet)
|
|
22498
22787
|
return failure("Armada is unavailable");
|
|
22499
22788
|
const ref = claimRef(h);
|
|
22500
|
-
const adapter = runtimeFor(configPath ? { ...io, cwd:
|
|
22789
|
+
const adapter = runtimeFor(configPath ? { ...io, cwd: dirname10(configPath) } : io, config, h.runtime);
|
|
22501
22790
|
const archived = await guarded(fleet, ref, "ended", () => adapter.archive(ref, { reason: "merged", whenWorking: "wait", waitMs: 600000 }));
|
|
22502
22791
|
if (!archived.archived && !archived.alreadyGone)
|
|
22503
22792
|
return failure("the runtime did not confirm archive");
|
|
@@ -22948,7 +23237,7 @@ async function merge2(io, config, credentials, a, configPath, guards) {
|
|
|
22948
23237
|
if (!exec)
|
|
22949
23238
|
throw new UsageError("armada merge needs to run git and gh");
|
|
22950
23239
|
const linearApiKey = credentials.linearApiKey;
|
|
22951
|
-
const repoDir =
|
|
23240
|
+
const repoDir = dirname11(configPath);
|
|
22952
23241
|
const fetchOpt = httpOptions(io);
|
|
22953
23242
|
const gh = { token, repository: config.github.repository, ...fetchOpt };
|
|
22954
23243
|
const linearOpts = { apiKey: linearApiKey, labels: config.tracker.labels, ...fetchOpt };
|
|
@@ -24174,7 +24463,7 @@ ${"─".repeat(60)}
|
|
|
24174
24463
|
|
|
24175
24464
|
// src/relaunch.ts
|
|
24176
24465
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
24177
|
-
import { basename as basename2, dirname as
|
|
24466
|
+
import { basename as basename2, dirname as dirname12, join as join10 } from "node:path";
|
|
24178
24467
|
async function relaunch(io, config, credentials, args, version, configPath) {
|
|
24179
24468
|
const [input, ...extra] = args.rest;
|
|
24180
24469
|
const o = args.options;
|
|
@@ -24313,7 +24602,7 @@ async function relaunch(io, config, credentials, args, version, configPath) {
|
|
|
24313
24602
|
const configHome = io.env.XDG_CONFIG_HOME ?? (io.env.HOME ? join10(io.env.HOME, ".config") : null);
|
|
24314
24603
|
const path = io.env.HERDR_CONFIG_PATH ?? (configHome ? join10(configHome, "herdr", "config.toml") : null);
|
|
24315
24604
|
const text = path ? await io.readFile(path).catch(() => null) : null;
|
|
24316
|
-
const directory = workspace?.path && old.runtime === "herdr" ?
|
|
24605
|
+
const directory = workspace?.path && old.runtime === "herdr" ? dirname12(workspace.path) : dirname12(herdrWorktreePath(herdrWorktreesDirectory(io.env, text), basename2(prepared.repo), prepared.spec.branch));
|
|
24317
24606
|
prepared.spec.herdrTarget = {
|
|
24318
24607
|
path: join10(directory, `armada-relaunch-${ticket.toLowerCase()}-${suffix}`),
|
|
24319
24608
|
agent: `relaunch-${ticket.toLowerCase()}-${suffix}`.slice(0, 31)
|
|
@@ -24564,7 +24853,7 @@ async function unreserveCommand(io, config, credentials, args) {
|
|
|
24564
24853
|
}
|
|
24565
24854
|
|
|
24566
24855
|
// src/secrets.ts
|
|
24567
|
-
import { dirname as
|
|
24856
|
+
import { dirname as dirname13, relative as relative3, resolve as resolve6 } from "node:path";
|
|
24568
24857
|
var NAME_HINT = "upper snake case, e.g. OPENAI_API_KEY";
|
|
24569
24858
|
var hhmm2 = (iso) => `${iso.slice(0, 16).replace("T", " ")} UTC`;
|
|
24570
24859
|
function signInOf(config, credentials) {
|
|
@@ -24644,7 +24933,7 @@ Next: armada secrets set <NAME> (an owner or admin), or the Keys page of Armada
|
|
|
24644
24933
|
async function exportRefusal(io, path) {
|
|
24645
24934
|
if (!io.exec)
|
|
24646
24935
|
return "git cannot be run here to check that the file is ignored";
|
|
24647
|
-
const cwd =
|
|
24936
|
+
const cwd = dirname13(path);
|
|
24648
24937
|
const tracked = await io.exec("git", ["ls-files", "--error-unmatch", "--", path], { cwd }).catch(() => null);
|
|
24649
24938
|
if (tracked?.code === 0)
|
|
24650
24939
|
return `git tracks ${path}: secrets written there would be committed`;
|
|
@@ -24751,7 +25040,7 @@ When set, re-run with armada run -- <command>. Never paste a key into chat.
|
|
|
24751
25040
|
const file = args.options.file;
|
|
24752
25041
|
if (!file)
|
|
24753
25042
|
throw new UsageError("secrets export needs --file <path>, a file git ignores (e.g. .env.local)");
|
|
24754
|
-
const path =
|
|
25043
|
+
const path = resolve6(io.cwd, file);
|
|
24755
25044
|
const refusal = await exportRefusal(io, path);
|
|
24756
25045
|
if (refusal)
|
|
24757
25046
|
throw new UsageError(refusal, "a path git ignores, e.g. .env.local listed in .gitignore");
|
|
@@ -25041,7 +25330,7 @@ async function upgrade(io, running, root) {
|
|
|
25041
25330
|
}
|
|
25042
25331
|
|
|
25043
25332
|
// src/validate.ts
|
|
25044
|
-
import { basename as basename3, resolve as
|
|
25333
|
+
import { basename as basename3, resolve as resolve7 } from "node:path";
|
|
25045
25334
|
async function readExcerpt(io, raw) {
|
|
25046
25335
|
const match = /^(.*):(\d+)-(\d+)$/.exec(raw);
|
|
25047
25336
|
const file = match?.[1] ?? raw;
|
|
@@ -25050,7 +25339,7 @@ async function readExcerpt(io, raw) {
|
|
|
25050
25339
|
const usage = `armada validate "<headline>" --excerpt '${file.replaceAll("'", "'\\''")}':1-40`;
|
|
25051
25340
|
if (!file || !Number.isSafeInteger(from) || from < 1 || to !== null && (!Number.isSafeInteger(to) || to < from))
|
|
25052
25341
|
throw new UsageError(`--excerpt needs <file>[:from-to], with a one-based inclusive range: ${usage}`);
|
|
25053
|
-
const text = await io.readFile(
|
|
25342
|
+
const text = await io.readFile(resolve7(io.cwd, file));
|
|
25054
25343
|
if (text === null)
|
|
25055
25344
|
throw new UsageError(`cannot read excerpt file: ${file}`);
|
|
25056
25345
|
const lines = excerptLines(text);
|
|
@@ -25065,7 +25354,7 @@ async function readExcerpt(io, raw) {
|
|
|
25065
25354
|
async function validationFiles(io, options) {
|
|
25066
25355
|
const excerpts = await Promise.all(attachList(options.excerpt).map((raw) => readExcerpt(io, raw)));
|
|
25067
25356
|
const file = options["details-file"];
|
|
25068
|
-
const details = file ? await io.readFile(
|
|
25357
|
+
const details = file ? await io.readFile(resolve7(io.cwd, file)) : null;
|
|
25069
25358
|
if (file && details === null)
|
|
25070
25359
|
throw new UsageError(`cannot read details file: ${file}`);
|
|
25071
25360
|
return { excerpts, details };
|
|
@@ -25171,6 +25460,10 @@ async function done(io, config, credentials, a) {
|
|
|
25171
25460
|
|
|
25172
25461
|
// src/cli.ts
|
|
25173
25462
|
var COMMAND_HELP = {
|
|
25463
|
+
config: ` config set deploy.env.<VAR> <value>
|
|
25464
|
+
config unset deploy.env.<VAR>
|
|
25465
|
+
Set or remove a non-secret deploy setting for this project on this machine.
|
|
25466
|
+
`,
|
|
25174
25467
|
deploy: ` deploy status [--json]
|
|
25175
25468
|
deploy watch --sha <sha> --target <name>
|
|
25176
25469
|
Watch a declared deploy and smoke check; failures pause merges.
|
|
@@ -25528,6 +25821,7 @@ var TICKET_OPTION = new Set([
|
|
|
25528
25821
|
"unreserve"
|
|
25529
25822
|
]);
|
|
25530
25823
|
var CONFIG_OPTION = new Set([
|
|
25824
|
+
"config",
|
|
25531
25825
|
"acceptance",
|
|
25532
25826
|
"lint",
|
|
25533
25827
|
"job",
|
|
@@ -25603,6 +25897,7 @@ Files:
|
|
|
25603
25897
|
credentials KEY=value lines, mode 0600, written by \`armada auth login\` and
|
|
25604
25898
|
\`armada login\` (the sign-in: ARMADA_SESSION_TOKEN or ARMADA_API_KEY)
|
|
25605
25899
|
config.toml personal defaults: language, [dashboard] url, [api] url
|
|
25900
|
+
projects/<slug>.json non-secret deploy settings for this project and machine
|
|
25606
25901
|
coordinators.json coordinator role per project and checkout
|
|
25607
25902
|
watch/<project>[@<name>].* the coordinator's watch: its lock, what you were shown, who is in flight
|
|
25608
25903
|
releases.json daily release notices in status/inbox, with version and time.
|
|
@@ -25888,21 +26183,21 @@ async function findConfig(io, explicit, command = "status", project = null) {
|
|
|
25888
26183
|
selected = join11(checkout.root, CONFIG_FILE);
|
|
25889
26184
|
}
|
|
25890
26185
|
if (selected) {
|
|
25891
|
-
const path =
|
|
26186
|
+
const path = resolve8(io.cwd, selected);
|
|
25892
26187
|
const text = await io.readFile(path);
|
|
25893
26188
|
if (text === null)
|
|
25894
26189
|
throw new UsageError(`${path} does not exist`, `armada ${command} --config <file>, with the path of an ${CONFIG_FILE}`);
|
|
25895
|
-
io.coordinatorRoot =
|
|
26190
|
+
io.coordinatorRoot = dirname14(path);
|
|
25896
26191
|
return { path, text };
|
|
25897
26192
|
}
|
|
25898
|
-
for (let dir =
|
|
26193
|
+
for (let dir = resolve8(io.cwd);; dir = dirname14(dir)) {
|
|
25899
26194
|
const path = join11(dir, CONFIG_FILE);
|
|
25900
26195
|
const text = await io.readFile(path);
|
|
25901
26196
|
if (text !== null) {
|
|
25902
|
-
io.coordinatorRoot =
|
|
26197
|
+
io.coordinatorRoot = dirname14(path);
|
|
25903
26198
|
return { path, text };
|
|
25904
26199
|
}
|
|
25905
|
-
if (
|
|
26200
|
+
if (dirname14(dir) === dir)
|
|
25906
26201
|
break;
|
|
25907
26202
|
}
|
|
25908
26203
|
throw new UsageError(`no ${CONFIG_FILE} found in ${io.cwd} or any parent directory, so this is not a repository Armada runs`, `armada init to set this repository up, armada ${command} --config <file> to use another ${CONFIG_FILE}, or armada status --all to see the registered projects`);
|
|
@@ -25926,7 +26221,7 @@ async function status2(io, args) {
|
|
|
25926
26221
|
...httpOptions(io),
|
|
25927
26222
|
...io.now ? { now: io.now } : {}
|
|
25928
26223
|
});
|
|
25929
|
-
const behind = await skillsBehind(fsRepoView(
|
|
26224
|
+
const behind = await skillsBehind(fsRepoView(dirname14(path))).catch(() => null);
|
|
25930
26225
|
if (behind)
|
|
25931
26226
|
report.warnings.push(skillsBehindLine(behind, version));
|
|
25932
26227
|
let deploys = null;
|
|
@@ -25986,7 +26281,7 @@ async function run(argv, io) {
|
|
|
25986
26281
|
if (args.all)
|
|
25987
26282
|
return await noticeRelease(io, version);
|
|
25988
26283
|
const { path } = await findConfig(io, args.config, command, args.project);
|
|
25989
|
-
await noticeRelease(io, version, fsRepoView(
|
|
26284
|
+
await noticeRelease(io, version, fsRepoView(dirname14(path)));
|
|
25990
26285
|
})().catch(() => {});
|
|
25991
26286
|
return code;
|
|
25992
26287
|
}
|
|
@@ -26098,6 +26393,10 @@ async function dispatch(argv, io) {
|
|
|
26098
26393
|
});
|
|
26099
26394
|
return await heartbeat2(io, config, credentials, { ...args, config: path });
|
|
26100
26395
|
}
|
|
26396
|
+
if (args.command === "config") {
|
|
26397
|
+
const { path, text } = await findConfig(io, args.config, "config", args.project);
|
|
26398
|
+
return await configCommand(io, parseConfig(text, path), args);
|
|
26399
|
+
}
|
|
26101
26400
|
if (args.command === "deploy") {
|
|
26102
26401
|
const { path, text } = await findConfig(io, args.config, "deploy", args.project);
|
|
26103
26402
|
const config = parseConfig(text, path);
|
|
@@ -26143,7 +26442,7 @@ async function dispatch(argv, io) {
|
|
|
26143
26442
|
const { credentials } = await loadCredentials(io, scope ? { worker: scope } : { project: config.project.slug });
|
|
26144
26443
|
if (command === "inbox")
|
|
26145
26444
|
await recordPresence(io, config, credentials);
|
|
26146
|
-
return await worker(command === "stop" ? { ...io, cwd:
|
|
26445
|
+
return await worker(command === "stop" ? { ...io, cwd: dirname14(path) } : io, config, credentials, args);
|
|
26147
26446
|
}
|
|
26148
26447
|
if (args.command === "coordinator") {
|
|
26149
26448
|
const { text } = await findConfig(io, args.config, "coordinator", args.project);
|
|
@@ -26154,7 +26453,7 @@ async function dispatch(argv, io) {
|
|
|
26154
26453
|
if (args.command === "peek") {
|
|
26155
26454
|
const { path, text } = await findConfig(io, args.config, "peek", args.project);
|
|
26156
26455
|
const config = parseConfig(text, path);
|
|
26157
|
-
const selectedIo = { ...io, cwd:
|
|
26456
|
+
const selectedIo = { ...io, cwd: dirname14(path) };
|
|
26158
26457
|
const local = await loadCredentials(selectedIo, {
|
|
26159
26458
|
armada: false,
|
|
26160
26459
|
worker: {
|
|
@@ -26240,7 +26539,7 @@ async function dispatch(argv, io) {
|
|
|
26240
26539
|
}
|
|
26241
26540
|
if (args.command === "doctor") {
|
|
26242
26541
|
noExtra(args.rest);
|
|
26243
|
-
return await doctor(io, args.json, version, args.options.deep === "true");
|
|
26542
|
+
return await doctor(io, args.json, version, args.options.deep === "true", args.config ?? undefined);
|
|
26244
26543
|
}
|
|
26245
26544
|
if (args.command === "upgrade") {
|
|
26246
26545
|
noExtra(args.rest);
|
|
@@ -26250,8 +26549,8 @@ async function dispatch(argv, io) {
|
|
|
26250
26549
|
const { credentials } = await loadCredentials(io, { armada: false });
|
|
26251
26550
|
if (credentials.armadaSignIn?.kind === "worker" || !credentials.armadaSignIn && credentials.workerTickets.length || io.env.ARMADA_TICKET?.trim())
|
|
26252
26551
|
throw new UsageError("workers keep their launch's pinned version; the coordinator runs armada upgrade");
|
|
26253
|
-
const root = await gitRoot(requireExec(io),
|
|
26254
|
-
if (basename4(path) !== CONFIG_FILE || root !==
|
|
26552
|
+
const root = await gitRoot(requireExec(io), dirname14(path));
|
|
26553
|
+
if (basename4(path) !== CONFIG_FILE || root !== dirname14(path))
|
|
26255
26554
|
throw new UsageError("armada upgrade needs armada.toml at the selected repository's Git root; use that checkout's armada.toml");
|
|
26256
26555
|
if (credentials.armadaSignIn)
|
|
26257
26556
|
try {
|
|
@@ -26518,7 +26817,7 @@ async function inspectProcess(exec, pid, system = {
|
|
|
26518
26817
|
import { spawn as spawn2 } from "node:child_process";
|
|
26519
26818
|
import { closeSync, fstatSync, mkdirSync, mkdtempSync, openSync, readSync, rmSync } from "node:fs";
|
|
26520
26819
|
import { constants, tmpdir as tmpdir3 } from "node:os";
|
|
26521
|
-
import { dirname as
|
|
26820
|
+
import { dirname as dirname15, join as join12 } from "node:path";
|
|
26522
26821
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
26523
26822
|
var spawnInherited = (command, args, { cwd, env, output }) => new Promise((done, fail) => {
|
|
26524
26823
|
const child = spawn2(command, args, { cwd, env, stdio: output ? ["inherit", "pipe", "pipe"] : "inherit" });
|
|
@@ -26556,7 +26855,7 @@ var startBackground = (args, options) => new Promise((resolve) => {
|
|
|
26556
26855
|
let log;
|
|
26557
26856
|
try {
|
|
26558
26857
|
if (options?.logPath) {
|
|
26559
|
-
mkdirSync(
|
|
26858
|
+
mkdirSync(dirname15(options.logPath), { recursive: true, mode: 448 });
|
|
26560
26859
|
log = openSync(options.logPath, "a", 384);
|
|
26561
26860
|
}
|
|
26562
26861
|
} catch {
|
|
@@ -26564,7 +26863,7 @@ var startBackground = (args, options) => new Promise((resolve) => {
|
|
|
26564
26863
|
}
|
|
26565
26864
|
const child = spawn2(process.execPath, [...process.execArgv, process.argv[1], ...args], {
|
|
26566
26865
|
cwd: process.cwd(),
|
|
26567
|
-
env: process.env,
|
|
26866
|
+
env: options?.env ?? process.env,
|
|
26568
26867
|
detached: true,
|
|
26569
26868
|
stdio: ["ignore", log ?? "ignore", log ?? "ignore", "ipc"]
|
|
26570
26869
|
});
|