@intentius/sql-yodeler 0.7.0 → 0.9.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 +10 -2
- 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/ci/render.d.ts +11 -2
- package/dist/ci/render.js +21 -6
- package/dist/ci/render.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/apply.js +173 -64
- package/dist/commands/apply.js.map +1 -1
- package/dist/commands/drift.js +8 -8
- package/dist/commands/drift.js.map +1 -1
- package/dist/commands/lint.js +10 -7
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/override.js +46 -22
- package/dist/commands/override.js.map +1 -1
- package/dist/commands/plan.js +19 -19
- package/dist/commands/plan.js.map +1 -1
- package/dist/commands/revert.js +3 -2
- package/dist/commands/revert.js.map +1 -1
- package/dist/config/define.d.ts +12 -7
- package/dist/config/define.js.map +1 -1
- package/dist/lint/check.d.ts +3 -0
- package/dist/lint/check.js +3 -2
- package/dist/lint/check.js.map +1 -1
- package/dist/lint/policies.d.ts +22 -0
- package/dist/lint/policies.js +47 -0
- package/dist/lint/policies.js.map +1 -0
- package/dist/lint/schema-checks.d.ts +14 -3
- package/dist/lint/schema-checks.js +11 -5
- package/dist/lint/schema-checks.js.map +1 -1
- package/dist/mcp/tools.d.ts +1 -1
- package/dist/mcp/tools.js +6 -4
- package/dist/mcp/tools.js.map +1 -1
- package/dist/notify/index.d.ts +30 -97
- package/dist/notify/index.js +50 -154
- 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.js +7 -2
- package/dist/pr/model.js.map +1 -1
- package/dist/pr/render.js +2 -2
- package/dist/pr/render.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 +6 -2
- package/dist/tenants/wave.js +1 -3
- package/dist/tenants/wave.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 +4 -10
- package/dist/waves/index.js +8 -33
- package/dist/waves/index.js.map +1 -1
- package/package.json +19 -8
- package/schemas/event.schema.json +218 -26
- 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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# SQL Yodeler
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Schema changes for ClickHouse and Postgres, and the ops they imply. Declare your schema in TypeScript, and SQL Yodeler works out the change: it plans and applies it against the live database, or writes it as a versioned migration, behind an approval bound to the plan. Built on chant's `sql` lexicon.
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
// src/schema.ts
|
|
@@ -20,7 +20,15 @@ export const events = table`
|
|
|
20
20
|
ORDER BY (kind, at)`;
|
|
21
21
|
```
|
|
22
22
|
|
|
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.
|
|
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, and [why it is plain SQL](docs/schema.md#why-plain-sql).
|
|
24
|
+
|
|
25
|
+
Some schema changes imply work beyond one statement, and yodel does that work as part of the migration:
|
|
26
|
+
|
|
27
|
+
- **ClickHouse rebuild.** Some changes, such as a new sort key, engine or partitioning, can't be made with `ALTER`. yodel creates a new table, copies the rows into it, checks that they match, and swaps it in.
|
|
28
|
+
- **Postgres safe rename.** Renaming a column or table in one step breaks the app that is still using the old name. yodel adds the new name, keeps both in sync, moves readers over, and drops the old name later. This is called expand and contract.
|
|
29
|
+
- **Backfill.** A new column often needs values for the rows already there. You write the fill once, and yodel runs it in batches, resuming where it stopped if it is interrupted.
|
|
30
|
+
|
|
31
|
+
Rebuilds, renames and backfills run once, inside the migration. No recurring jobs. Not an ORM; it works next to one ([Schema from an ORM](docs/orm.md)). [Data migrations](docs/steps.md) has the details.
|
|
24
32
|
|
|
25
33
|
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
34
|
|
|
@@ -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,"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AK,CAAC;QAC9D,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,KAAuB,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/ci/render.d.ts
CHANGED
|
@@ -72,7 +72,8 @@
|
|
|
72
72
|
* in that image instead, which carries node, yodel, chant and the lexicons
|
|
73
73
|
* on PATH, and no job runs `npm ci` ({@link Toolchain}).
|
|
74
74
|
*/
|
|
75
|
-
import { type ApprovalMode, type CiLogin, type WaveGate } from "../config/define.js";
|
|
75
|
+
import { type ApplySteps, type ApprovalMode, type CiLogin, type WaveGate } from "../config/define.js";
|
|
76
|
+
import type { OpWaveHooks } from "@intentius/chant/op";
|
|
76
77
|
import { type CloudToken, type Role } from "../credentials.js";
|
|
77
78
|
import type { Declarable } from "@intentius/chant/declarable";
|
|
78
79
|
export type Forge = "github" | "gitlab" | "forgejo";
|
|
@@ -123,6 +124,8 @@ export interface Environments {
|
|
|
123
124
|
replay: boolean;
|
|
124
125
|
/** The project has tests/*.test.ts: with the replay profile, the lint job runs yodel test on its server too (#54). */
|
|
125
126
|
tests?: boolean;
|
|
127
|
+
/** The project commits sql-types.d.ts (typed columns, #228): the lint job fails when it no longer matches the schema. */
|
|
128
|
+
typedColumns?: boolean;
|
|
126
129
|
/**
|
|
127
130
|
* The environments whose profile is made with credentials() (#50): the
|
|
128
131
|
* variables each role reads, and the cloud token source that mints its
|
|
@@ -209,6 +212,8 @@ export declare const REPLAY = "yodel lint --replay replay --reset";
|
|
|
209
212
|
export declare const TEST = "yodel test --env replay --reset --junit yodel-test.xml";
|
|
210
213
|
/** Fails a pull request whose pipelines differ from what yodel ci renders. */
|
|
211
214
|
export declare const CI_CHECK = "yodel ci --check";
|
|
215
|
+
/** Fails a pull request whose sql-types.d.ts no longer matches the schema (#228). */
|
|
216
|
+
export declare const TYPES_CHECK = "chant sql types --check";
|
|
212
217
|
/**
|
|
213
218
|
* Webhook events (yodel.config.ts `notify`): the variables the apply, plan
|
|
214
219
|
* and watch jobs pass from the forge's secrets. yodel sends nothing while
|
|
@@ -258,6 +263,8 @@ export interface Wave {
|
|
|
258
263
|
shares?: number;
|
|
259
264
|
/** Which approvals of the wave's digest count (yodel.config.ts `waves[].approval`, #48); absent, `ledger`. */
|
|
260
265
|
approval?: ApprovalMode;
|
|
266
|
+
/** The environment's steps around apply (yodel.config.ts `environments.<env>.steps`, #64): the wave's stage hooks (#206). */
|
|
267
|
+
steps?: ApplySteps;
|
|
261
268
|
}
|
|
262
269
|
/** The waves spec: committed, and read by every wave job (its gate policy at the commit before the push). */
|
|
263
270
|
export declare const WAVES_SPEC = "yodel-waves.json";
|
|
@@ -281,6 +288,7 @@ interface WavesSpec {
|
|
|
281
288
|
name: string;
|
|
282
289
|
};
|
|
283
290
|
variables?: Record<string, string>;
|
|
291
|
+
hooks?: OpWaveHooks;
|
|
284
292
|
}>;
|
|
285
293
|
/** The scheduled resume job (yodel.config.ts `ci.resume`); only the pipelines are rendered from it, the spec file leaves it out. */
|
|
286
294
|
resume?: {
|
|
@@ -304,7 +312,8 @@ export declare function readWaves(dir: string, envs: readonly string[]): Promise
|
|
|
304
312
|
* `shares` slots (one without) that read the tenants when the wave runs.
|
|
305
313
|
* The query is not run here, so the pipeline stays the same as tenants come
|
|
306
314
|
* and go; a list or a file is in the repository, and changing it is
|
|
307
|
-
* rendering again.
|
|
315
|
+
* rendering again. Each wave also gets its environment's steps around
|
|
316
|
+
* apply (#64), for its stage hooks.
|
|
308
317
|
*/
|
|
309
318
|
export declare function withTenants(dir: string, waves: readonly Wave[]): Promise<Wave[]>;
|
|
310
319
|
/**
|
package/dist/ci/render.js
CHANGED
|
@@ -76,6 +76,7 @@ import { existsSync } from "node:fs";
|
|
|
76
76
|
import { join, resolve } from "node:path";
|
|
77
77
|
import { pathToFileURL } from "node:url";
|
|
78
78
|
import { APPROVAL_MODES, WAVE_GATES, waveGateHint } from "../config/define.js";
|
|
79
|
+
import { stepHooks } from "../apply-steps/index.js";
|
|
79
80
|
import { audience, CLOUD_OF, jobLogins, loginSteps } from "./login.js";
|
|
80
81
|
import { RECORD_PLANS_ENV } from "../approval-mode/index.js";
|
|
81
82
|
import { cloudToken, credentialsOf, roleVariables } from "../credentials.js";
|
|
@@ -249,6 +250,8 @@ export const REPLAY = `yodel lint --replay ${REPLAY_PROFILE} --reset`;
|
|
|
249
250
|
export const TEST = `yodel test --env ${REPLAY_PROFILE} --reset --junit yodel-test.xml`;
|
|
250
251
|
/** Fails a pull request whose pipelines differ from what yodel ci renders. */
|
|
251
252
|
export const CI_CHECK = "yodel ci --check";
|
|
253
|
+
/** Fails a pull request whose sql-types.d.ts no longer matches the schema (#228). */
|
|
254
|
+
export const TYPES_CHECK = "chant sql types --check";
|
|
252
255
|
/**
|
|
253
256
|
* Webhook events (yodel.config.ts `notify`): the variables the apply, plan
|
|
254
257
|
* and watch jobs pass from the forge's secrets. yodel sends nothing while
|
|
@@ -328,7 +331,7 @@ const runner = (container, tc) => ({ "runs-on": "ubuntu-latest", ...(container ?
|
|
|
328
331
|
function commentToken(forge) {
|
|
329
332
|
return forge === "github" ? { GITHUB_TOKEN: "${{ github.token }}" } : { FORGEJO_TOKEN: "${{ github.token }}" };
|
|
330
333
|
}
|
|
331
|
-
function lintJob(forge, dialect, replay, tc, tests = false) {
|
|
334
|
+
function lintJob(forge, dialect, replay, tc, tests = false, typedColumns = false) {
|
|
332
335
|
// With the replay check, the job runs in IMAGE on every forge and reaches
|
|
333
336
|
// its replay server by the service's name on the job's own network. On
|
|
334
337
|
// GitHub's VM the service would be on localhost through a published port,
|
|
@@ -338,6 +341,7 @@ function lintJob(forge, dialect, replay, tc, tests = false) {
|
|
|
338
341
|
const steps = [
|
|
339
342
|
...setupSteps(container, tc),
|
|
340
343
|
new Step({ name: "The pipelines are up to date", run: CI_CHECK }),
|
|
344
|
+
...(typedColumns ? [new Step({ name: "sql-types.d.ts is up to date", run: TYPES_CHECK })] : []),
|
|
341
345
|
new Step({ name: "yodel lint", run: lintCommand(forge) }),
|
|
342
346
|
];
|
|
343
347
|
if (!replay)
|
|
@@ -364,7 +368,7 @@ function lintJob(forge, dialect, replay, tc, tests = false) {
|
|
|
364
368
|
export function actionsReview(forge, envs_) {
|
|
365
369
|
const { dialect, names: envs, replay, waves, jobs: own } = envs_;
|
|
366
370
|
const tc = toolchainOf(envs_);
|
|
367
|
-
const jobs = { lint: lintJob(forge, dialect, replay, tc, envs_.tests === true) };
|
|
371
|
+
const jobs = { lint: lintJob(forge, dialect, replay, tc, envs_.tests === true, envs_.typedColumns === true) };
|
|
368
372
|
for (const env of envs) {
|
|
369
373
|
const read = [env, ...requiredOf(waves, env)];
|
|
370
374
|
jobs[`plan-${env}`] = new ActionsJob({
|
|
@@ -436,17 +440,18 @@ export function gitlabPipeline(envs_) {
|
|
|
436
440
|
before_script: [...installLines(tc, "gitlab"), FETCH_APPROVALS],
|
|
437
441
|
}));
|
|
438
442
|
const svc = REPLAY_SERVICE[dialect];
|
|
443
|
+
const types = envs_.typedColumns === true ? [TYPES_CHECK] : [];
|
|
439
444
|
jobs.set("lint", new GitLabJob({
|
|
440
445
|
extends: ".yodel",
|
|
441
446
|
stage: "review",
|
|
442
447
|
rules: mr(),
|
|
443
448
|
...(replay
|
|
444
449
|
? {
|
|
445
|
-
script: [CI_CHECK, lintCommand("gitlab"), waitFor(svc.name, svc.port), REPLAY, ...(envs_.tests === true ? [TEST] : [])],
|
|
450
|
+
script: [CI_CHECK, ...types, lintCommand("gitlab"), waitFor(svc.name, svc.port), REPLAY, ...(envs_.tests === true ? [TEST] : [])],
|
|
446
451
|
services: [new GitLabService({ name: svc.image, alias: svc.name, variables: svc.env })],
|
|
447
452
|
variables: { [`${variablePrefix(REPLAY_PROFILE, dialect)}_URL`]: svc.url(svc.name), ...svc.jobEnv },
|
|
448
453
|
}
|
|
449
|
-
: { script: [CI_CHECK, lintCommand("gitlab")] }),
|
|
454
|
+
: { script: [CI_CHECK, ...types, lintCommand("gitlab")] }),
|
|
450
455
|
// The code quality report, kept when lint fails too: that is when it has something to show.
|
|
451
456
|
artifacts: new GitLabArtifacts({ when: "always", reports: { codequality: CODE_QUALITY_FILE } }),
|
|
452
457
|
}));
|
|
@@ -563,10 +568,17 @@ export function wavesSpec(waves, variables, resume) {
|
|
|
563
568
|
...(w.shares !== undefined && w.shares > 1 ? { shares: w.shares } : {}),
|
|
564
569
|
...(w.approval !== undefined && w.approval !== "ledger" ? { approval: w.approval } : {}),
|
|
565
570
|
...(variables ? { environment: { name: w.env }, variables: variables(w.env) } : {}),
|
|
571
|
+
// The steps around apply (#64) as chant's stage hooks, which the apply runs under its lock (#206).
|
|
572
|
+
...hooksOf(w.steps),
|
|
566
573
|
})),
|
|
567
574
|
...(resume ? { resume } : {}),
|
|
568
575
|
};
|
|
569
576
|
}
|
|
577
|
+
/** A wave's stage hooks from its steps, when it has any. */
|
|
578
|
+
function hooksOf(steps) {
|
|
579
|
+
const hooks = stepHooks(steps);
|
|
580
|
+
return hooks ? { hooks } : {};
|
|
581
|
+
}
|
|
570
582
|
/** The waves spec file and the apply pipeline on each forge. */
|
|
571
583
|
export async function applyPipelines(dir, envs) {
|
|
572
584
|
const { dialect, waves } = envs;
|
|
@@ -780,7 +792,8 @@ export async function readWaves(dir, envs) {
|
|
|
780
792
|
* `shares` slots (one without) that read the tenants when the wave runs.
|
|
781
793
|
* The query is not run here, so the pipeline stays the same as tenants come
|
|
782
794
|
* and go; a list or a file is in the repository, and changing it is
|
|
783
|
-
* rendering again.
|
|
795
|
+
* rendering again. Each wave also gets its environment's steps around
|
|
796
|
+
* apply (#64), for its stage hooks.
|
|
784
797
|
*/
|
|
785
798
|
export async function withTenants(dir, waves) {
|
|
786
799
|
const { loadProject } = await import("../project.js");
|
|
@@ -789,7 +802,8 @@ export async function withTenants(dir, waves) {
|
|
|
789
802
|
const out = [];
|
|
790
803
|
for (const w of waves) {
|
|
791
804
|
const targets = await waveTargets(project, w.env, w.shares);
|
|
792
|
-
|
|
805
|
+
const steps = w.steps ?? project.yodel?.config.environments?.[w.env]?.steps;
|
|
806
|
+
out.push({ ...w, ...(targets !== undefined ? { targets } : {}), ...(steps ? { steps } : {}) });
|
|
793
807
|
}
|
|
794
808
|
return out;
|
|
795
809
|
}
|
|
@@ -926,6 +940,7 @@ export async function environments(dir) {
|
|
|
926
940
|
...(Object.keys(credentials).length > 0 ? { credentials } : {}),
|
|
927
941
|
replay,
|
|
928
942
|
...(hasTests(dir) ? { tests: true } : {}),
|
|
943
|
+
...(existsSync(join(dir, config.sourceDir ?? ".", "sql-types.d.ts")) ? { typedColumns: true } : {}),
|
|
929
944
|
waves: await withTenants(dir, await readWaves(dir, envs)),
|
|
930
945
|
forges: ci?.forges ?? FORGES,
|
|
931
946
|
...(ci?.jobs ? { jobs: await loadProjectJobs(dir, ci.jobs) } : {}),
|