@intentius/sql-yodeler 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/apply-steps/index.d.ts +73 -21
- package/dist/apply-steps/index.js +171 -49
- package/dist/apply-steps/index.js.map +1 -1
- package/dist/approval-mode/index.d.ts +7 -0
- package/dist/approval-mode/index.js +10 -3
- package/dist/approval-mode/index.js.map +1 -1
- package/dist/chant/apply.d.ts +15 -3
- package/dist/chant/apply.js +22 -3
- package/dist/chant/apply.js.map +1 -1
- package/dist/ci/render.d.ts +7 -2
- package/dist/ci/render.js +13 -3
- package/dist/ci/render.js.map +1 -1
- package/dist/commands/apply.d.ts +2 -0
- package/dist/commands/apply.js +196 -87
- package/dist/commands/apply.js.map +1 -1
- package/dist/commands/approve.d.ts +51 -1
- package/dist/commands/approve.js +177 -14
- package/dist/commands/approve.js.map +1 -1
- package/dist/commands/cleanup.d.ts +1 -0
- package/dist/commands/cleanup.js +11 -7
- package/dist/commands/cleanup.js.map +1 -1
- package/dist/commands/create.d.ts +31 -0
- package/dist/commands/create.js +171 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/drift.js +8 -8
- package/dist/commands/drift.js.map +1 -1
- package/dist/commands/emulator.d.ts +17 -0
- package/dist/commands/emulator.js +78 -0
- package/dist/commands/emulator.js.map +1 -0
- package/dist/commands/index.js +4 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init.js +7 -5
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/override.js +46 -22
- package/dist/commands/override.js.map +1 -1
- package/dist/commands/plan.js +20 -20
- package/dist/commands/plan.js.map +1 -1
- package/dist/commands/revert.js +10 -7
- package/dist/commands/revert.js.map +1 -1
- package/dist/config/define.d.ts +5 -5
- package/dist/mcp/tools.d.ts +2 -2
- package/dist/mcp/tools.js +7 -5
- package/dist/mcp/tools.js.map +1 -1
- package/dist/notify/index.d.ts +30 -95
- package/dist/notify/index.js +50 -153
- package/dist/notify/index.js.map +1 -1
- package/dist/notify/verify.d.ts +17 -31
- package/dist/notify/verify.js +16 -47
- package/dist/notify/verify.js.map +1 -1
- package/dist/pr/forge.d.ts +33 -38
- package/dist/pr/forge.js +74 -97
- package/dist/pr/forge.js.map +1 -1
- package/dist/pr/issue.d.ts +16 -33
- package/dist/pr/issue.js +17 -88
- package/dist/pr/issue.js.map +1 -1
- package/dist/pr/model.d.ts +5 -3
- package/dist/pr/model.js +12 -6
- package/dist/pr/model.js.map +1 -1
- package/dist/pr/render.js +7 -6
- package/dist/pr/render.js.map +1 -1
- package/dist/pr/tenants.js +2 -2
- package/dist/pr/tenants.js.map +1 -1
- package/dist/release/index.d.ts +63 -0
- package/dist/release/index.js +122 -0
- package/dist/release/index.js.map +1 -0
- package/dist/report/audit.d.ts +18 -19
- package/dist/report/audit.js +57 -27
- package/dist/report/audit.js.map +1 -1
- package/dist/report/model.js +18 -5
- package/dist/report/model.js.map +1 -1
- package/dist/tenants/wave.d.ts +9 -3
- package/dist/tenants/wave.js +4 -5
- package/dist/tenants/wave.js.map +1 -1
- package/dist/versioned/approval.js +1 -1
- package/dist/versioned/approval.js.map +1 -1
- package/dist/versioned/policy.d.ts +44 -24
- package/dist/versioned/policy.js +70 -37
- package/dist/versioned/policy.js.map +1 -1
- package/dist/waves/index.d.ts +9 -13
- package/dist/waves/index.js +12 -36
- package/dist/waves/index.js.map +1 -1
- package/package.json +7 -7
- package/schemas/apply.schema.json +2 -0
- package/schemas/cleanup.schema.json +1 -0
- package/schemas/event.schema.json +218 -25
- package/schemas/init.schema.json +1 -0
- package/schemas/plan.schema.json +3 -1
- package/schemas/revert.schema.json +2 -1
- package/dist/pr/comment.d.ts +0 -32
- package/dist/pr/comment.js +0 -99
- package/dist/pr/comment.js.map +0 -1
package/README.md
CHANGED
|
@@ -22,16 +22,16 @@ export const events = table`
|
|
|
22
22
|
|
|
23
23
|
Each export is one object in the database's own DDL; `${db}` is a reference, so the build orders the objects and checks them against a pinned server's catalog. [Declaring the schema](docs/schema.md) has the whole form, both dialects.
|
|
24
24
|
|
|
25
|
-
SQL Yodeler is built on [chant](https://intentius.io/chant/), a declarative infrastructure-as-code toolkit in TypeScript.
|
|
25
|
+
SQL Yodeler is built on [chant](https://intentius.io/chant/), a declarative infrastructure-as-code toolkit in TypeScript. The `yodel` CLI covers every step, and runs chant's CLI underneath: `yodel create` makes a project from a template, `yodel emulator up` starts a local database, and `yodel approve` records an approval. Before a project exists, run it as `npx @intentius/sql-yodeler`; inside one, as `npx yodel`.
|
|
26
26
|
|
|
27
27
|
## Getting started
|
|
28
28
|
|
|
29
29
|
[Your first migration](docs/getting-started.md) goes from an empty directory to two applied migrations on a local ClickHouse, with every command and its output. In short:
|
|
30
30
|
|
|
31
31
|
```sh
|
|
32
|
-
npx @intentius/
|
|
32
|
+
npx @intentius/sql-yodeler@latest create my-schema --clickhouse --database events
|
|
33
33
|
cd my-schema && npm install && git init -b main && git add -A && git commit -m "chore: a new yodel project"
|
|
34
|
-
npx
|
|
34
|
+
npx yodel emulator up # ClickHouse and Postgres in Docker
|
|
35
35
|
curl -s http://127.0.0.1:8123 --data-binary "CREATE USER IF NOT EXISTS reader IDENTIFIED WITH no_password SETTINGS readonly = 1"
|
|
36
36
|
curl -s http://127.0.0.1:8123 --data-binary "GRANT SELECT, SHOW ON *.* TO reader"
|
|
37
37
|
export DEV_CLICKHOUSE_READER_USER=reader DEV_CLICKHOUSE_READER_PASSWORD= DEV_CLICKHOUSE_WRITER_USER=default DEV_CLICKHOUSE_WRITER_PASSWORD=
|
|
@@ -44,9 +44,9 @@ YODEL_CREDENTIALS=writer npx yodel apply dev
|
|
|
44
44
|
|
|
45
45
|
yodel refuses an environment whose reader and writer are one user, so dev reads with a read-only user, `reader`, and applies with the emulator's `default` user, picked by `YODEL_CREDENTIALS=writer`. The template's `just up` makes the reader and prints these variables for a `.env` file, and `just apply` sets the writer.
|
|
46
46
|
|
|
47
|
-
For Postgres, use
|
|
47
|
+
For Postgres, use `--postgres --schema app`.
|
|
48
48
|
|
|
49
|
-
Each template gives `chant.config.ts` with a profile per environment (`dev`, `prod`), `yodel.config.ts`, a migrate Op per environment (`yodel apply` behind a gate bound to the plan digest), a `WatchOp` per environment for drift on a schedule, and pipelines for GitHub Actions, GitLab CI and Forgejo Actions: `yodel lint` and the plan comment on pull requests with read-only credentials, `yodel apply` on a push to main with the writer, and the drift watch on its cron with the reader. `yodel ci` (`npm run ci`) renders the pipelines from the installed package, so upgrading yodel and rendering again brings its pipeline fixes, and the project's own jobs, declared in a module `yodel.config.ts` `ci.jobs` names, are kept.
|
|
49
|
+
Each template gives `chant.config.ts` with a profile per environment (`dev`, `prod`), `yodel.config.ts`, a migrate Op per environment (`yodel apply` behind a gate bound to the plan digest), a `WatchOp` per environment for drift on a schedule, and pipelines for GitHub Actions, GitLab CI and Forgejo Actions: `yodel lint` and the plan comment on pull requests with read-only credentials, `yodel apply` on a push to main with the writer, and the drift watch on its cron with the reader. `yodel ci` (`npm run ci`) renders the pipelines from the installed package, so upgrading yodel and rendering again brings its pipeline fixes, and the project's own jobs, declared in a module `yodel.config.ts` `ci.jobs` names, are kept. `yodel create --help` lists its options; the template's README covers the credentials and each forge's setup, and so does [Setting up each forge](docs/forges.md).
|
|
50
50
|
|
|
51
51
|
## Documentation
|
|
52
52
|
|
|
@@ -109,7 +109,7 @@ export const op = Op({
|
|
|
109
109
|
});
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
`yodel apply prod` stops at the gate
|
|
112
|
+
`yodel apply prod` stops at the gate and prints the command that approves its plan, `npx yodel approve prod --plan <digest>`: run it at a terminal, then run `yodel apply prod` again. `yodel apply prod --json` also gives chant's own approve command, `chantApprove`, for a script that records approvals itself. `yodel apply prod --plan` prints the pending migrations and the digest without applying.
|
|
113
113
|
|
|
114
114
|
## yodel lint
|
|
115
115
|
|
|
@@ -130,7 +130,7 @@ The reason is required. `yodel apply` records each silence (step, rule, reason)
|
|
|
130
130
|
|
|
131
131
|
`yodel lint --env <env>` also reads the environment's history: an applied migration whose files changed since it ran is a `checksum` error, a pending migration's edit a warning. `yodel.config.ts` sets rule levels: `lint: { rules: { "ch-mutation": "warning", "pg-lock": "off" } }`; the integrity rules cannot be lowered. `yodel lint --rules` lists the rules and their levels.
|
|
132
132
|
|
|
133
|
-
`yodel lint --replay <env>` also replays every migration, in order, into `<env>`'s server (a throwaway emulator, `npx
|
|
133
|
+
`yodel lint --replay <env>` also replays every migration, in order, into `<env>`'s server (a throwaway emulator, `npx yodel emulator up`) and compares each with its recorded schema; the first that differs fails the run (rule `replay`, exit 3), named. The databases or schemas the history names must not exist there yet: otherwise it exits 4 and runs nothing, unless `--reset`, which drops them first (never point it at a server whose data matters). `--keep` leaves the replayed database in place to look at.
|
|
134
134
|
|
|
135
135
|
## Contributing
|
|
136
136
|
|
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Steps around apply (#64): per environment, `yodel.config.ts`
|
|
3
3
|
* `environments.<env>.steps.before` and `.after`, SQL checks or commands
|
|
4
|
-
* run around the versioned apply.
|
|
4
|
+
* run around the versioned apply, as chant's Op waves stage hooks (#206).
|
|
5
5
|
*
|
|
6
|
-
* -
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* succeeded.
|
|
6
|
+
* - Each step is a hook ({@link stepHooks}). A SQL check runs `yodel apply
|
|
7
|
+
* <env> --step-sql`, which yodel runs in process ({@link runStepHooks}); a
|
|
8
|
+
* command runs `sh -c`. `yodel ci` writes them into yodel-waves.json,
|
|
9
|
+
* with `hooks.apply.runBy: "apply"`, and chant reads them there at the
|
|
10
|
+
* base commit, as it reads the gate policy.
|
|
11
|
+
* - `before` SQL checks are `before.plan` hooks: chant runs them when it
|
|
12
|
+
* plans the wave, and one that fails with `onFailure: "approve"` holds the
|
|
13
|
+
* wave for a person, whatever its gate, before the apply is called. Every
|
|
14
|
+
* `before` step is also a `before.apply` hook, and every `after` step an
|
|
15
|
+
* `after.apply` hook: the apply runs those under its lock, through
|
|
16
|
+
* chant's runner, before the first migration and once the last one
|
|
17
|
+
* succeeded. A command, which may have side effects, runs once per apply,
|
|
18
|
+
* under the lock, never when the wave is planned (#107).
|
|
19
|
+
* - In order: a step that fails stops the ones after it, unless its
|
|
20
|
+
* `onFailure` is `approve`. A `before` step that fails refuses the run
|
|
21
|
+
* (exit 4); an `after` step that fails fails it (exit 1), the migrations
|
|
18
22
|
* applied.
|
|
23
|
+
* - Outside the waves (`yodel apply <env>`) the same hooks are made from
|
|
24
|
+
* yodel.config.ts at the base commit ({@link stepsAtBase}, {@link
|
|
25
|
+
* stepsHooksFile}): the SQL checks run before the gate, and every step
|
|
26
|
+
* under the lock, where the Op's approval lets a held one through.
|
|
19
27
|
* - Every outcome is in the history: the `before` steps' on each
|
|
20
28
|
* migration's `started` row, the `after` steps' on the last migration's
|
|
21
29
|
* `succeeded` row (`note.steps`), and `yodel report` lists them.
|
|
22
30
|
*/
|
|
31
|
+
import type { OpWaveApplyHooksRun, OpWaveHookMoment, OpWaveHooks, OpWaveHooksFile } from "@intentius/chant/op";
|
|
23
32
|
import type { ApplyStep, ApplySteps } from "../config/define.js";
|
|
24
33
|
import { YodelError, type Project } from "../project.js";
|
|
25
34
|
import type { VersionedDriver } from "../versioned/driver.js";
|
|
@@ -44,22 +53,65 @@ export interface StepsAtBase {
|
|
|
44
53
|
}
|
|
45
54
|
/** `env`'s steps from yodel.config.ts at the base commit. */
|
|
46
55
|
export declare function stepsAtBase(project: Pick<Project, "dir" | "yodel">, env: string, processEnv?: NodeJS.ProcessEnv): Promise<StepsAtBase>;
|
|
56
|
+
/** The flag a SQL step's hook runs `yodel apply <env>` with; {@link runStepHooks} runs it in process. */
|
|
57
|
+
export declare const STEP_SQL_FLAG = "--step-sql";
|
|
47
58
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
59
|
+
* `steps` as stage hooks: the `before` SQL checks before the plan, every
|
|
60
|
+
* `before` step before the apply and every `after` step after it, the
|
|
61
|
+
* apply-stage ones run by the apply. Undefined for no steps.
|
|
51
62
|
*/
|
|
52
|
-
export declare function
|
|
63
|
+
export declare function stepHooks(steps: ApplySteps | undefined): OpWaveHooks | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* The hooks file for an apply outside the waves: `env`'s steps as {@link
|
|
66
|
+
* stepHooks} has them, by moment. `approved`: an approval of the plan stands
|
|
67
|
+
* (the Op's gate passed), so a held step does not stop the apply.
|
|
68
|
+
*/
|
|
69
|
+
export declare function stepsHooksFile(steps: ApplySteps | undefined, env: string, options: {
|
|
70
|
+
approved: boolean;
|
|
71
|
+
base?: string;
|
|
72
|
+
}): OpWaveHooksFile;
|
|
73
|
+
/** A SQL step's hook argv, read back: the step it runs, or undefined for any other argv. */
|
|
74
|
+
export declare function sqlStepOfArgv(argv: readonly string[]): (ApplyStep & {
|
|
75
|
+
sql: string;
|
|
76
|
+
when: StepWhen;
|
|
77
|
+
}) | undefined;
|
|
78
|
+
/** Runs one SQL step on `driver`, judged like a pre-migration check. */
|
|
79
|
+
export declare function runSqlStep(driver: Pick<VersionedDriver, "readCheck">, step: ApplyStep & {
|
|
80
|
+
sql: string;
|
|
81
|
+
}): Promise<{
|
|
82
|
+
passed: boolean;
|
|
83
|
+
detail: string;
|
|
84
|
+
}>;
|
|
85
|
+
/** What {@link runStepHooks} ran: chant's verdict, and each step's outcome as the history records it. */
|
|
86
|
+
export interface StepHooksRun {
|
|
87
|
+
run: OpWaveApplyHooksRun;
|
|
88
|
+
outcomes: StepOutcome[];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Runs one moment's hooks of `file` through chant's runner, under the
|
|
92
|
+
* apply's lock (or before the gate, for `before-plan`): a SQL step in
|
|
93
|
+
* process on `driver`, a command with `YODEL_ENV` and `YODEL_STEP` set and
|
|
94
|
+
* its last line kept for the history. With `skip`, runs none and tells
|
|
95
|
+
* chant why (an apply that changes nothing).
|
|
96
|
+
*/
|
|
97
|
+
export declare function runStepHooks(file: OpWaveHooksFile, moment: OpWaveHookMoment, ctx: {
|
|
98
|
+
driver: Pick<VersionedDriver, "readCheck">;
|
|
53
99
|
dir: string;
|
|
54
100
|
env: string;
|
|
55
101
|
processEnv?: NodeJS.ProcessEnv;
|
|
56
|
-
|
|
57
|
-
|
|
102
|
+
log?: (line: string) => void;
|
|
103
|
+
skip?: string;
|
|
104
|
+
}): Promise<StepHooksRun>;
|
|
58
105
|
/** One line for an outcome. */
|
|
59
106
|
export declare const describeStep: (o: StepOutcome) => string;
|
|
60
107
|
/** The `before` steps that failed with `onFailure: "approve"`: the run waits for a person. */
|
|
61
108
|
export declare const heldSteps: (outcomes: readonly StepOutcome[]) => string[];
|
|
62
|
-
/**
|
|
63
|
-
|
|
109
|
+
/**
|
|
110
|
+
* The refusal for a moment's hooks that did not let the apply go on, or
|
|
111
|
+
* undefined: a `before` step that failed (exit 4, nothing applied), a held
|
|
112
|
+
* one with no approval standing (exit 3), an `after` step that failed (exit
|
|
113
|
+
* 1, the migrations applied).
|
|
114
|
+
*/
|
|
115
|
+
export declare function stepsRefusal(env: string, ran: StepHooksRun, when: string, approve?: string): YodelError | undefined;
|
|
64
116
|
/** The steps a history row's note records, if any. */
|
|
65
117
|
export declare function stepsOfNote(note: string): StepOutcome[];
|
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Steps around apply (#64): per environment, `yodel.config.ts`
|
|
3
3
|
* `environments.<env>.steps.before` and `.after`, SQL checks or commands
|
|
4
|
-
* run around the versioned apply.
|
|
4
|
+
* run around the versioned apply, as chant's Op waves stage hooks (#206).
|
|
5
5
|
*
|
|
6
|
-
* -
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* succeeded.
|
|
6
|
+
* - Each step is a hook ({@link stepHooks}). A SQL check runs `yodel apply
|
|
7
|
+
* <env> --step-sql`, which yodel runs in process ({@link runStepHooks}); a
|
|
8
|
+
* command runs `sh -c`. `yodel ci` writes them into yodel-waves.json,
|
|
9
|
+
* with `hooks.apply.runBy: "apply"`, and chant reads them there at the
|
|
10
|
+
* base commit, as it reads the gate policy.
|
|
11
|
+
* - `before` SQL checks are `before.plan` hooks: chant runs them when it
|
|
12
|
+
* plans the wave, and one that fails with `onFailure: "approve"` holds the
|
|
13
|
+
* wave for a person, whatever its gate, before the apply is called. Every
|
|
14
|
+
* `before` step is also a `before.apply` hook, and every `after` step an
|
|
15
|
+
* `after.apply` hook: the apply runs those under its lock, through
|
|
16
|
+
* chant's runner, before the first migration and once the last one
|
|
17
|
+
* succeeded. A command, which may have side effects, runs once per apply,
|
|
18
|
+
* under the lock, never when the wave is planned (#107).
|
|
19
|
+
* - In order: a step that fails stops the ones after it, unless its
|
|
20
|
+
* `onFailure` is `approve`. A `before` step that fails refuses the run
|
|
21
|
+
* (exit 4); an `after` step that fails fails it (exit 1), the migrations
|
|
18
22
|
* applied.
|
|
23
|
+
* - Outside the waves (`yodel apply <env>`) the same hooks are made from
|
|
24
|
+
* yodel.config.ts at the base commit ({@link stepsAtBase}, {@link
|
|
25
|
+
* stepsHooksFile}): the SQL checks run before the gate, and every step
|
|
26
|
+
* under the lock, where the Op's approval lets a held one through.
|
|
19
27
|
* - Every outcome is in the history: the `before` steps' on each
|
|
20
28
|
* migration's `started` row, the `after` steps' on the last migration's
|
|
21
29
|
* `succeeded` row (`note.steps`), and `yodel report` lists them.
|
|
22
30
|
*/
|
|
23
31
|
import { spawnSync } from "node:child_process";
|
|
24
32
|
import { loadYodelConfigAtBase } from "../config/base.js";
|
|
25
|
-
import { EXIT_REFUSED } from "../exit.js";
|
|
33
|
+
import { EXIT_OUTSTANDING, EXIT_REFUSED } from "../exit.js";
|
|
26
34
|
import { judgeCheck } from "../migrations/checks.js";
|
|
27
35
|
import { YodelError } from "../project.js";
|
|
28
36
|
/** `env`'s steps from yodel.config.ts at the base commit. */
|
|
@@ -40,56 +48,170 @@ export async function stepsAtBase(project, env, processEnv = process.env) {
|
|
|
40
48
|
const differs = JSON.stringify(tree ?? null) !== JSON.stringify(steps ?? null);
|
|
41
49
|
return { steps, sha: at.sha, ...(differs ? { note: `steps: ${env}'s steps are read at the base commit ${at.sha.slice(0, 12)}, not from this change` } : {}) };
|
|
42
50
|
}
|
|
51
|
+
/** The flag a SQL step's hook runs `yodel apply <env>` with; {@link runStepHooks} runs it in process. */
|
|
52
|
+
export const STEP_SQL_FLAG = "--step-sql";
|
|
53
|
+
/** One step as a hook: a SQL check through `yodel apply {target} --step-sql`, a command through `sh -c`. */
|
|
54
|
+
function stepHook(step, when) {
|
|
55
|
+
const command = step.sql !== undefined
|
|
56
|
+
? ["yodel", "apply", "{target}", STEP_SQL_FLAG, step.sql, "--step", step.name, "--step-when", when, ...(step.expect !== undefined ? ["--step-expect", JSON.stringify(step.expect)] : []), ...(step.onFailure === "approve" ? ["--step-on-failure", "approve"] : [])]
|
|
57
|
+
: ["sh", "-c", step.command ?? ""];
|
|
58
|
+
// chant has no approve after the apply: an after step that fails fails the run, whatever it says.
|
|
59
|
+
return { name: step.name, command, perRun: true, ...(when === "before" && step.onFailure === "approve" ? { onFailure: "approve" } : {}) };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `steps` as stage hooks: the `before` SQL checks before the plan, every
|
|
63
|
+
* `before` step before the apply and every `after` step after it, the
|
|
64
|
+
* apply-stage ones run by the apply. Undefined for no steps.
|
|
65
|
+
*/
|
|
66
|
+
export function stepHooks(steps) {
|
|
67
|
+
const before = steps?.before ?? [];
|
|
68
|
+
const after = steps?.after ?? [];
|
|
69
|
+
if (before.length === 0 && after.length === 0)
|
|
70
|
+
return undefined;
|
|
71
|
+
const checks = before.filter((s) => s.sql !== undefined);
|
|
72
|
+
return {
|
|
73
|
+
apply: { runBy: "apply" },
|
|
74
|
+
before: { ...(checks.length > 0 ? { plan: checks.map((s) => stepHook(s, "before")) } : {}), ...(before.length > 0 ? { apply: before.map((s) => stepHook(s, "before")) } : {}) },
|
|
75
|
+
...(after.length > 0 ? { after: { apply: after.map((s) => stepHook(s, "after")) } } : {}),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The hooks file for an apply outside the waves: `env`'s steps as {@link
|
|
80
|
+
* stepHooks} has them, by moment. `approved`: an approval of the plan stands
|
|
81
|
+
* (the Op's gate passed), so a held step does not stop the apply.
|
|
82
|
+
*/
|
|
83
|
+
export function stepsHooksFile(steps, env, options) {
|
|
84
|
+
const hooks = stepHooks(steps);
|
|
85
|
+
const byMoment = {
|
|
86
|
+
...(hooks?.before?.plan ? { "before-plan": hooks.before.plan } : {}),
|
|
87
|
+
...(hooks?.before?.apply ? { "before-apply": hooks.before.apply } : {}),
|
|
88
|
+
...(hooks?.after?.apply ? { "after-apply": hooks.after.apply } : {}),
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
version: 1,
|
|
92
|
+
opWaves: "yodel-apply",
|
|
93
|
+
op: `migrate-${env}`,
|
|
94
|
+
wave: env,
|
|
95
|
+
number: 0,
|
|
96
|
+
...(options.base ? { base: options.base } : {}),
|
|
97
|
+
approved: options.approved,
|
|
98
|
+
runBy: "apply",
|
|
99
|
+
runs: [{ target: env, op: `migrate-${env}` }],
|
|
100
|
+
runsFile: "",
|
|
101
|
+
hooks: byMoment,
|
|
102
|
+
outcomes: [],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
43
105
|
const lastLine = (text) => text.trim().split("\n").at(-1)?.slice(0, 200) ?? "";
|
|
106
|
+
/** A SQL step's hook argv, read back: the step it runs, or undefined for any other argv. */
|
|
107
|
+
export function sqlStepOfArgv(argv) {
|
|
108
|
+
if (argv[0] !== "yodel" || argv[1] !== "apply")
|
|
109
|
+
return undefined;
|
|
110
|
+
const at = (flag) => {
|
|
111
|
+
const i = argv.indexOf(flag);
|
|
112
|
+
return i >= 0 ? argv[i + 1] : undefined;
|
|
113
|
+
};
|
|
114
|
+
const sql = at(STEP_SQL_FLAG);
|
|
115
|
+
const name = at("--step");
|
|
116
|
+
if (sql === undefined || name === undefined)
|
|
117
|
+
return undefined;
|
|
118
|
+
const expect = at("--step-expect");
|
|
119
|
+
const parsed = expect !== undefined ? JSON.parse(expect) : undefined;
|
|
120
|
+
return {
|
|
121
|
+
name,
|
|
122
|
+
sql,
|
|
123
|
+
when: at("--step-when") === "after" ? "after" : "before",
|
|
124
|
+
...(parsed !== undefined ? { expect: parsed } : {}),
|
|
125
|
+
...(at("--step-on-failure") === "approve" ? { onFailure: "approve" } : {}),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** Runs one SQL step on `driver`, judged like a pre-migration check. */
|
|
129
|
+
export async function runSqlStep(driver, step) {
|
|
130
|
+
try {
|
|
131
|
+
const judged = judgeCheck({ name: step.name, sql: step.sql, ...(step.expect !== undefined ? { expect: step.expect } : {}) }, await driver.readCheck(step.sql, {}));
|
|
132
|
+
return { passed: judged.passed, detail: judged.detail };
|
|
133
|
+
}
|
|
134
|
+
catch (e) {
|
|
135
|
+
return { passed: false, detail: `the query failed: ${(e instanceof Error ? e.message : String(e)).split("\n")[0] ?? ""}` };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
44
138
|
/**
|
|
45
|
-
* Runs
|
|
46
|
-
*
|
|
47
|
-
*
|
|
139
|
+
* Runs one moment's hooks of `file` through chant's runner, under the
|
|
140
|
+
* apply's lock (or before the gate, for `before-plan`): a SQL step in
|
|
141
|
+
* process on `driver`, a command with `YODEL_ENV` and `YODEL_STEP` set and
|
|
142
|
+
* its last line kept for the history. With `skip`, runs none and tells
|
|
143
|
+
* chant why (an apply that changes nothing).
|
|
48
144
|
*/
|
|
49
|
-
export async function
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
continue;
|
|
145
|
+
export async function runStepHooks(file, moment, ctx) {
|
|
146
|
+
const { runOpWaveApplyHooks } = await import("@intentius/chant/op");
|
|
147
|
+
const when = moment.startsWith("after") ? "after" : "before";
|
|
148
|
+
const hooks = file.hooks[moment] ?? [];
|
|
149
|
+
// chant's runner is synchronous and a SQL step is not: each SQL step runs here first, in order, and the runner reads its verdict.
|
|
150
|
+
const checked = new Map();
|
|
151
|
+
if (ctx.skip === undefined) {
|
|
152
|
+
for (const hook of hooks) {
|
|
153
|
+
const step = sqlStepOfArgv(hook.command);
|
|
154
|
+
if (step)
|
|
155
|
+
checked.set(hook.name ?? step.name, await runSqlStep(ctx.driver, step));
|
|
62
156
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
157
|
+
}
|
|
158
|
+
const details = [];
|
|
159
|
+
const exec = (argv, cwd, env) => {
|
|
160
|
+
const step = sqlStepOfArgv(argv);
|
|
161
|
+
if (step) {
|
|
162
|
+
const got = checked.get(step.name) ?? { passed: false, detail: "the check did not run" };
|
|
163
|
+
details.push({ kind: "sql", detail: got.detail });
|
|
164
|
+
return got.passed ? 0 : 1;
|
|
66
165
|
}
|
|
67
|
-
const ran = spawnSync(
|
|
68
|
-
cwd
|
|
166
|
+
const ran = spawnSync(argv[0] ?? "sh", argv.slice(1), {
|
|
167
|
+
cwd,
|
|
69
168
|
encoding: "utf8",
|
|
70
|
-
env: { ...(ctx.processEnv ?? process.env), YODEL_ENV: ctx.env, YODEL_STEP: when },
|
|
169
|
+
env: { ...(ctx.processEnv ?? process.env), ...env, YODEL_ENV: ctx.env, YODEL_STEP: when },
|
|
71
170
|
timeout: 10 * 60_000,
|
|
72
171
|
});
|
|
73
172
|
const said = lastLine(`${ran.stdout}\n${ran.stderr}`);
|
|
74
|
-
const code = ran.status ?? 1;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
173
|
+
const code = ran.error ? 127 : (ran.status ?? 1);
|
|
174
|
+
details.push({ kind: "command", detail: `exit ${ran.error ? "(did not run)" : String(code)}${said ? `: ${said}` : ""}` });
|
|
175
|
+
return code;
|
|
176
|
+
};
|
|
177
|
+
const run = runOpWaveApplyHooks(file, moment, { cwd: ctx.dir, exec, log: ctx.log ?? (() => undefined), ...(ctx.skip !== undefined ? { skip: ctx.skip } : {}) });
|
|
178
|
+
const onFailureOf = new Map(hooks.map((h) => [h.name ?? h.command.join(" "), h.onFailure ?? "fail"]));
|
|
179
|
+
const outcomes = run.outcomes
|
|
180
|
+
.filter((o) => o.outcome !== "skipped")
|
|
181
|
+
.map((o, i) => ({
|
|
182
|
+
name: o.name,
|
|
183
|
+
when,
|
|
184
|
+
kind: details[i]?.kind ?? "command",
|
|
185
|
+
passed: o.outcome === "passed",
|
|
186
|
+
detail: details[i]?.detail ?? `exit ${String(o.exit)}`,
|
|
187
|
+
onFailure: onFailureOf.get(o.name) ?? "fail",
|
|
188
|
+
}));
|
|
189
|
+
return { run, outcomes };
|
|
78
190
|
}
|
|
79
191
|
/** One line for an outcome. */
|
|
80
192
|
export const describeStep = (o) => o.deferred ? `${o.when} step ${o.name} will run under the lock (${o.detail})` : `${o.when} step ${o.name} ${o.passed ? "passed" : o.onFailure === "approve" ? "failed, held for approval" : "failed"} (${o.detail})`;
|
|
81
193
|
/** The `before` steps that failed with `onFailure: "approve"`: the run waits for a person. */
|
|
82
194
|
export const heldSteps = (outcomes) => outcomes.filter((o) => !o.passed && o.when === "before" && o.onFailure === "approve").map((o) => o.name);
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
195
|
+
/**
|
|
196
|
+
* The refusal for a moment's hooks that did not let the apply go on, or
|
|
197
|
+
* undefined: a `before` step that failed (exit 4, nothing applied), a held
|
|
198
|
+
* one with no approval standing (exit 3), an `after` step that failed (exit
|
|
199
|
+
* 1, the migrations applied).
|
|
200
|
+
*/
|
|
201
|
+
export function stepsRefusal(env, ran, when, approve) {
|
|
202
|
+
if (ran.run.proceed)
|
|
87
203
|
return undefined;
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
204
|
+
const lines = (os) => os.map((o) => ` ${describeStep(o)}`).join("\n");
|
|
205
|
+
const failed = ran.outcomes.filter((o) => !o.passed && o.onFailure === "fail");
|
|
206
|
+
if (ran.run.moment === "after-apply")
|
|
207
|
+
return new YodelError(`${env}: the migrations are applied, and an after step failed ${when}:\n${lines(failed)}`, 1);
|
|
208
|
+
if (ran.run.failed || failed.length > 0) {
|
|
209
|
+
return new YodelError(`refused: a before step of ${env} failed ${when}; nothing was applied:\n${lines(failed)}\n` +
|
|
210
|
+
`Fix the cause and run again, or, for a check a person may wave through, give the step onFailure: "approve" (at the base commit).`, EXIT_REFUSED);
|
|
211
|
+
}
|
|
212
|
+
const held = ran.outcomes.filter((o) => !o.passed && o.onFailure === "approve");
|
|
213
|
+
const why = held.length > 0 ? lines(held) : ran.run.held.map((h) => ` ${h}`).join("\n");
|
|
214
|
+
return new YodelError(`refused: a before step of ${env} failed with onFailure approve ${when}, and no approval of this plan stands; nothing was applied:\n${why}${approve ? `\nApprove it with: ${approve}` : ""}`, EXIT_OUTSTANDING);
|
|
93
215
|
}
|
|
94
216
|
/** The steps a history row's note records, if any. */
|
|
95
217
|
export function stepsOfNote(note) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/apply-steps/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,YAA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function sealedPort(port: GateLedgerPort, cwd: string, base: stri
|
|
|
74
74
|
export declare function portFor(port: GateLedgerPort, mode: ApprovalMode, cwd: string, base: string | undefined): Promise<GateLedgerPort>;
|
|
75
75
|
/** What a printed approve command needs for `mode`: `--sign` under sealed. */
|
|
76
76
|
export declare const signFlag: (mode: ApprovalMode) => string;
|
|
77
|
+
/**
|
|
78
|
+
* The command yodel prints for a person to approve `digest` for `env`
|
|
79
|
+
* (#202): `yodel approve <env> --plan <digest>`, with `--sign` under
|
|
80
|
+
* sealed. The JSON outputs carry chant's own command beside it, as
|
|
81
|
+
* `chantApprove`, for scripts.
|
|
82
|
+
*/
|
|
83
|
+
export declare const approveCommand: (env: string, digest: string | undefined, mode?: ApprovalMode) => string;
|
|
77
84
|
/** One sentence on which approvals count under `mode`, for the plan and the pull request comment. */
|
|
78
85
|
export declare function describeApprovalMode(mode: ApprovalMode, code?: (s: string) => string): string;
|
|
@@ -94,12 +94,19 @@ export async function portFor(port, mode, cwd, base) {
|
|
|
94
94
|
}
|
|
95
95
|
/** What a printed approve command needs for `mode`: `--sign` under sealed. */
|
|
96
96
|
export const signFlag = (mode) => (mode === "sealed" ? " --sign" : "");
|
|
97
|
+
/**
|
|
98
|
+
* The command yodel prints for a person to approve `digest` for `env`
|
|
99
|
+
* (#202): `yodel approve <env> --plan <digest>`, with `--sign` under
|
|
100
|
+
* sealed. The JSON outputs carry chant's own command beside it, as
|
|
101
|
+
* `chantApprove`, for scripts.
|
|
102
|
+
*/
|
|
103
|
+
export const approveCommand = (env, digest, mode = "ledger") => `yodel approve ${env}${digest !== undefined ? ` --plan ${digest}` : ""}${signFlag(mode)}`;
|
|
97
104
|
/** One sentence on which approvals count under `mode`, for the plan and the pull request comment. */
|
|
98
105
|
export function describeApprovalMode(mode, code = (s) => s) {
|
|
99
106
|
if (mode === "sealed")
|
|
100
|
-
return `Approvals count only sealed (approval ${code("sealed")}): ${code("
|
|
107
|
+
return `Approvals count only sealed (approval ${code("sealed")}): ${code("yodel approve --sign")}, with a key ${code(SIGNERS_FILE)} at the base commit lists for the approver.`;
|
|
101
108
|
if (mode === "pr-review")
|
|
102
|
-
return `Approval ${code("pr-review")}: an approving review of this pull request's head, by a writer other than its author, approves the plan that head records; ${code("
|
|
103
|
-
return `Approval ${code("ledger")}: any ${code("
|
|
109
|
+
return `Approval ${code("pr-review")}: an approving review of this pull request's head, by a writer other than its author, approves the plan that head records; ${code("yodel approve")} of the digest counts too.`;
|
|
110
|
+
return `Approval ${code("ledger")}: any approval of the digest (${code("yodel approve")}) counts.`;
|
|
104
111
|
}
|
|
105
112
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/approval-mode/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AAE1D,kFAAkF;AAClF,MAAM,CAAC,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAErD,6FAA6F;AAC7F,MAAM,UAAU,YAAY,CAAC,MAA+B,EAAE,GAAW;IACvE,OAAO,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,IAAI,QAAQ,CAAC;AAC1F,CAAC;AAED,wHAAwH;AACxH,MAAM,UAAU,kBAAkB,CAAC,MAA+B,EAAE,GAAW;IAC7E,MAAM,GAAG,GAAG,MAAM,EAAE,YAAY,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC;IACnE,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC;I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,EAAE,CAAC,CAAC;AAE7F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,MAA0B,EAAE,OAAqB,QAAQ,EAAU,EAAE,CAC/G,iBAAiB,GAAG,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;AAE5F,qGAAqG;AACrG,MAAM,UAAU,oBAAoB,CAAC,IAAkB,EAAE,OAA8B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7F,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,yCAAyC,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,IAAI,CAAC,YAAY,CAAC,6CAA6C,CAAC;IACvM,IAAI,IAAI,KAAK,WAAW;QAAE,OAAO,YAAY,IAAI,CAAC,WAAW,CAAC,8HAA8H,IAAI,CAAC,eAAe,CAAC,4BAA4B,CAAC;IAC9O,OAAO,YAAY,IAAI,CAAC,QAAQ,CAAC,iCAAiC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC;AACrG,CAAC"}
|
package/dist/chant/apply.d.ts
CHANGED
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
* gate is bound to its Plan phase's digest, so an approval given for one
|
|
6
6
|
* change set never applies another; yodel never resolves the gate itself.
|
|
7
7
|
* `chant approve <op> <gate> --plan <digest>` does, and the next run walks
|
|
8
|
-
* through it.
|
|
8
|
+
* through it. yodel prints `yodel approve <env> --plan <digest>` for a
|
|
9
|
+
* person, which runs that for them (#202).
|
|
9
10
|
*/
|
|
10
11
|
import type { OpConfig } from "@intentius/chant/op/types";
|
|
11
12
|
import { YodelError, type Environment, type Project, type SqlDialect } from "../project.js";
|
|
13
|
+
import { type ApprovalMode } from "../approval-mode/index.js";
|
|
12
14
|
/** The ApplyOp yodel runs for an environment. */
|
|
13
15
|
export interface ApplyOpRef {
|
|
14
16
|
name: string;
|
|
@@ -42,8 +44,8 @@ export type ApplyRunStatus = "applied" | "gated" | "failed";
|
|
|
42
44
|
export interface ApplyRun {
|
|
43
45
|
status: ApplyRunStatus;
|
|
44
46
|
code: number;
|
|
45
|
-
/** The `chant approve ...` command chant printed for a gated run. */
|
|
46
|
-
|
|
47
|
+
/** The `chant approve ...` command chant printed for a gated run; yodel prints {@link gatedCommands}' instead. */
|
|
48
|
+
chantApprove?: string;
|
|
47
49
|
/** The plan digest the gate is waiting on. */
|
|
48
50
|
planDigest?: string;
|
|
49
51
|
output: string;
|
|
@@ -52,6 +54,16 @@ export interface ApplyRun {
|
|
|
52
54
|
}
|
|
53
55
|
/** What a `chant run` of an ApplyOp says about its outcome. */
|
|
54
56
|
export declare function readApplyRun(code: number, output: string): ApplyRun;
|
|
57
|
+
/**
|
|
58
|
+
* For a run that stopped at its gate (#202): `approve`, the command a person
|
|
59
|
+
* runs (`yodel approve <env> --plan <digest>`, with `--sign` when the gate
|
|
60
|
+
* is sealed), and `chantApprove`, chant's own, for scripts. Empty when chant
|
|
61
|
+
* printed no approve command.
|
|
62
|
+
*/
|
|
63
|
+
export declare function gatedCommands(run: Pick<ApplyRun, "chantApprove" | "planDigest">, env: string, mode?: ApprovalMode): {
|
|
64
|
+
approve?: string;
|
|
65
|
+
chantApprove?: string;
|
|
66
|
+
};
|
|
55
67
|
/** Runs the ApplyOp with `chant run <op>`, its output passed to `onOutput` as it arrives. */
|
|
56
68
|
export declare function runApplyOp(project: Project, op: ApplyOpRef, options?: {
|
|
57
69
|
env?: NodeJS.ProcessEnv;
|