@intentius/sql-yodeler 0.12.1 → 0.13.2
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 +2 -0
- package/dist/bin.js +3 -0
- package/dist/bin.js.map +1 -1
- package/dist/chant/apply.js +3 -1
- package/dist/chant/apply.js.map +1 -1
- package/dist/chant/build.d.ts +4 -2
- package/dist/chant/build.js +8 -4
- package/dist/chant/build.js.map +1 -1
- package/dist/chant/confirm.d.ts +20 -20
- package/dist/chant/confirm.js +14 -27
- package/dist/chant/confirm.js.map +1 -1
- package/dist/chant/drift.d.ts +0 -17
- package/dist/chant/drift.js +6 -63
- package/dist/chant/drift.js.map +1 -1
- package/dist/chant/gated-request.d.ts +4 -8
- package/dist/chant/gated-request.js +5 -20
- package/dist/chant/gated-request.js.map +1 -1
- package/dist/chant/ledger-fetch.d.ts +46 -0
- package/dist/chant/ledger-fetch.js +42 -0
- package/dist/chant/ledger-fetch.js.map +1 -0
- package/dist/chant/sql-types.d.ts +4 -5
- package/dist/chant/sql-types.js +9 -9
- package/dist/chant/sql-types.js.map +1 -1
- package/dist/chant-floor-version.d.ts +4 -11
- package/dist/chant-floor-version.js +4 -11
- package/dist/chant-floor-version.js.map +1 -1
- package/dist/chant-floor.d.ts +5 -36
- package/dist/chant-floor.js +5 -65
- package/dist/chant-floor.js.map +1 -1
- package/dist/check/run.js +1 -1
- package/dist/check/run.js.map +1 -1
- package/dist/ci/check-hooks.d.ts +2 -2
- package/dist/ci/check-hooks.js +4 -17
- package/dist/ci/check-hooks.js.map +1 -1
- package/dist/ci/commit.d.ts +106 -0
- package/dist/ci/commit.js +115 -0
- package/dist/ci/commit.js.map +1 -0
- package/dist/ci/login.d.ts +17 -12
- package/dist/ci/login.js +32 -41
- package/dist/ci/login.js.map +1 -1
- package/dist/ci/render.d.ts +81 -47
- package/dist/ci/render.js +215 -285
- package/dist/ci/render.js.map +1 -1
- package/dist/ci-words.d.ts +18 -19
- package/dist/ci-words.js +16 -30
- package/dist/ci-words.js.map +1 -1
- package/dist/cli.js +1 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/approve.d.ts +1 -1
- package/dist/commands/approve.js +6 -7
- package/dist/commands/approve.js.map +1 -1
- package/dist/commands/chant.d.ts +7 -1
- package/dist/commands/chant.js +16 -3
- package/dist/commands/chant.js.map +1 -1
- package/dist/commands/ci.js +55 -9
- package/dist/commands/ci.js.map +1 -1
- package/dist/commands/create.d.ts +2 -2
- package/dist/commands/create.js +2 -2
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/drift.js +8 -18
- package/dist/commands/drift.js.map +1 -1
- package/dist/commands/emulator.d.ts +2 -2
- package/dist/commands/emulator.js +2 -2
- package/dist/commands/emulator.js.map +1 -1
- package/dist/commands/init.js +3 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/lint.js +29 -3
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/new.d.ts +7 -0
- package/dist/commands/new.js +156 -22
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/override.js +2 -2
- package/dist/commands/override.js.map +1 -1
- package/dist/commands/plan.js +7 -4
- package/dist/commands/plan.js.map +1 -1
- package/dist/commands/upgrade.d.ts +2 -2
- package/dist/commands/upgrade.js +12 -36
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/config/define.d.ts +37 -0
- package/dist/config/define.js +4 -0
- package/dist/config/define.js.map +1 -1
- package/dist/config/load.js +22 -4
- package/dist/config/load.js.map +1 -1
- package/dist/declarative/plan.d.ts +1 -0
- package/dist/declarative/plan.js +5 -3
- package/dist/declarative/plan.js.map +1 -1
- package/dist/exit.d.ts +15 -37
- package/dist/exit.js +23 -79
- package/dist/exit.js.map +1 -1
- package/dist/init/adopt.d.ts +1 -1
- package/dist/init/adopt.js +3 -2
- package/dist/init/adopt.js.map +1 -1
- package/dist/lint/rules.d.ts +3 -1
- package/dist/lint/rules.js +3 -1
- package/dist/lint/rules.js.map +1 -1
- package/dist/lint/unmigrated.d.ts +18 -0
- package/dist/lint/unmigrated.js +62 -0
- package/dist/lint/unmigrated.js.map +1 -0
- package/dist/mcp/chant-hook.d.ts +1 -2
- package/dist/mcp/chant-hook.js +4 -12
- package/dist/mcp/chant-hook.js.map +1 -1
- package/dist/notify/index.d.ts +11 -4
- package/dist/notify/index.js +18 -16
- package/dist/notify/index.js.map +1 -1
- package/dist/pr/forge.d.ts +7 -6
- package/dist/pr/forge.js +19 -56
- package/dist/pr/forge.js.map +1 -1
- package/dist/pr/issue.d.ts +30 -19
- package/dist/pr/issue.js +66 -11
- package/dist/pr/issue.js.map +1 -1
- package/dist/pr/note.d.ts +4 -2
- package/dist/pr/note.js +21 -16
- package/dist/pr/note.js.map +1 -1
- package/dist/pr/overdue.d.ts +5 -12
- package/dist/pr/overdue.js +7 -49
- package/dist/pr/overdue.js.map +1 -1
- package/dist/pr/render.d.ts +0 -2
- package/dist/pr/render.js +0 -2
- package/dist/pr/render.js.map +1 -1
- package/dist/pr/tenants.d.ts +1 -0
- package/dist/pr/tenants.js +6 -4
- package/dist/pr/tenants.js.map +1 -1
- package/dist/project.d.ts +1 -1
- package/dist/project.js +3 -2
- package/dist/project.js.map +1 -1
- package/dist/schemas.d.ts +1 -1
- package/dist/sources/index.js +2 -1
- package/dist/sources/index.js.map +1 -1
- package/dist/versioned/op.js +8 -3
- package/dist/versioned/op.js.map +1 -1
- package/package.json +9 -8
- package/schemas/event.schema.json +17 -2
- package/dist/chant/process.d.ts +0 -46
- package/dist/chant/process.js +0 -92
- package/dist/chant/process.js.map +0 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/yodel new` (#312) and `/yodel rebase` (#313): chant's commit job,
|
|
3
|
+
* rendered from the sql lexicon's `yodelCommitSpec` (chant pull request
|
|
4
|
+
* 4798). A job with no forge token runs the command on the pull request's
|
|
5
|
+
* head, in a worktree, and a second job holding the push token pushes what
|
|
6
|
+
* it changed to the branch. chant refuses a pull request from a fork, a
|
|
7
|
+
* commenter who cannot write, a change outside `migrations/`, a head the
|
|
8
|
+
* job pushed itself and a fourth push to one pull request.
|
|
9
|
+
*
|
|
10
|
+
* - `new` runs `yodel new [<name>] --if-changed --replace-own --env <env>...`
|
|
11
|
+
* with each environment's reader variables, so `--replace-own` reads the
|
|
12
|
+
* histories and refuses a migration one of them records (chant pull
|
|
13
|
+
* request 4834). `/yodel new <name>` names the migration: chant hands the
|
|
14
|
+
* comment's argument to the command (chant pull request 4835).
|
|
15
|
+
* - `rebase` merges the base branch into the head first (`mergeBase`), as a
|
|
16
|
+
* fork shows only on that merge, then runs `yodel rebase --env <env>...`
|
|
17
|
+
* with each environment's reader variables and nothing of a writer
|
|
18
|
+
* (`commandEnv`). The environments are every one the apply pipeline
|
|
19
|
+
* applies, since any of them may hold the other branch's migrations.
|
|
20
|
+
*
|
|
21
|
+
* yodel.config.ts `ci.respond.<word>` picks the triggers:
|
|
22
|
+
*
|
|
23
|
+
* - `comment` (the default): the job answers `/yodel <word>`.
|
|
24
|
+
* - `on-change` (new) or `on-fork` (rebase): that, and a check on each push
|
|
25
|
+
* to a pull request, `yodel lint --commit-trigger <word>`, which exits
|
|
26
|
+
* with chant's `drift` code (2) when lint finds `unmigrated` or `fork`;
|
|
27
|
+
* the commit job follows it then.
|
|
28
|
+
* - `off`: nothing.
|
|
29
|
+
*
|
|
30
|
+
* On GitLab chant's check trigger is off unless asked for, so it is asked
|
|
31
|
+
* for. GitLab runs a comment's job in a pipeline of the default branch,
|
|
32
|
+
* which cannot read the merge request's target branch, so chant refuses
|
|
33
|
+
* `mergeBase` there: `/yodel rebase` runs on GitLab through the check
|
|
34
|
+
* trigger only, for `comment` and `on-fork` alike.
|
|
35
|
+
*
|
|
36
|
+
* GitHub and Forgejo get a workflow per job. GitLab gets a file per word,
|
|
37
|
+
* which `.gitlab-ci.yml` includes; a comment there reaches the job as a
|
|
38
|
+
* pipeline of the default branch started with `CHANT_COMMIT_PR` and
|
|
39
|
+
* `CHANT_COMMIT=<word>` (chant's header in the file says how).
|
|
40
|
+
*
|
|
41
|
+
* The generator is each forge lexicon's `generateOpPipeline`, called
|
|
42
|
+
* directly: chant's `generateOpsPipeline` looks every spec up as a declared
|
|
43
|
+
* Op, and a commit job runs no Op.
|
|
44
|
+
*/
|
|
45
|
+
import { yodelCommitSetup, yodelCommitSpec } from "@intentius/chant-lexicon-sql/yodel-run";
|
|
46
|
+
import { YODEL_WORDS } from "../ci-words.js";
|
|
47
|
+
/** The secret (GitHub, Forgejo) or protected variable (GitLab) the push job reads the token from. */
|
|
48
|
+
export const COMMIT_TOKEN_ENV = "YODEL_PUSH_TOKEN";
|
|
49
|
+
/** The GitLab file each word's commit jobs are in. */
|
|
50
|
+
export const GITLAB_COMMIT_FILES = { new: ".gitlab/yodel-commit.gitlab-ci.yml", rebase: ".gitlab/yodel-rebase.gitlab-ci.yml" };
|
|
51
|
+
export const GITLAB_COMMIT_FILE = GITLAB_COMMIT_FILES.new;
|
|
52
|
+
/** The job that answers `/yodel <word>`, and the one after the check. */
|
|
53
|
+
export const commitJob = (word) => `yodel-${word}`;
|
|
54
|
+
export const checkJob = (word) => `yodel-${word}-check`;
|
|
55
|
+
export const NEW_JOB = commitJob("new");
|
|
56
|
+
export const NEW_CHECK_JOB = checkJob("new");
|
|
57
|
+
/** The check a commit job follows: lint, exiting 2 when it finds the word's finding (`unmigrated`, `fork`). */
|
|
58
|
+
export const checkCommand = (word) => ["yodel", "lint", "--commit-trigger", word];
|
|
59
|
+
export const NEW_CHECK_COMMAND = checkCommand("new");
|
|
60
|
+
async function pluginOf(forge) {
|
|
61
|
+
const mod = (await import(`@intentius/chant-lexicon-${forge}`));
|
|
62
|
+
const plugin = Object.values(mod).find((v) => typeof v?.generateOpPipeline === "function");
|
|
63
|
+
if (!plugin)
|
|
64
|
+
throw new Error(`@intentius/chant-lexicon-${forge} has no generateOpPipeline`);
|
|
65
|
+
return plugin;
|
|
66
|
+
}
|
|
67
|
+
/** The commit jobs' specs of `word` for `forge`, the comment's first. */
|
|
68
|
+
export function commitSpecs(r, forge, word = "new") {
|
|
69
|
+
const respond = word === "new" ? r.respond : (r.respondRebase ?? "comment");
|
|
70
|
+
if (respond === "off")
|
|
71
|
+
return {};
|
|
72
|
+
const setup = r.yodelImage ? [] : yodelCommitSetup({ dir: r.dir });
|
|
73
|
+
const base = {
|
|
74
|
+
tokenEnv: COMMIT_TOKEN_ENV,
|
|
75
|
+
...(r.readers && r.readers.envs.length > 0 ? { envs: r.readers.envs, readerVariables: r.readers.variables } : {}),
|
|
76
|
+
};
|
|
77
|
+
const spec = (name, commit) => ({ name, trigger: { kind: "pull_request" }, commit, ...(setup.length > 0 ? { setup } : {}) });
|
|
78
|
+
// chant runs the check trigger on GitLab only when asked (gitlabCheck).
|
|
79
|
+
const check = () => spec(checkJob(word), { ...yodelCommitSpec(word, { ...base, on: "check" }), ...(forge === "gitlab" ? { gitlabCheck: true } : {}) });
|
|
80
|
+
// GitLab refuses mergeBase on a comment job: /yodel rebase runs there on the check trigger only.
|
|
81
|
+
if (word === "rebase" && forge === "gitlab")
|
|
82
|
+
return { check: check() };
|
|
83
|
+
const comment = spec(commitJob(word), { ...yodelCommitSpec(word, { ...base, on: "comment" }) });
|
|
84
|
+
return respond === "comment" ? { comment } : { comment, check: check() };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The commit jobs' files of `word` for `forge`, each YAML as the lexicon
|
|
88
|
+
* emits it. The words are made active while they render, so the jobs'
|
|
89
|
+
* chant lines run through `yodel chant` and the comment reads `/yodel
|
|
90
|
+
* <word>`.
|
|
91
|
+
*/
|
|
92
|
+
export async function commitFiles(r, forge, word = "new") {
|
|
93
|
+
const { comment, check } = commitSpecs(r, forge, word);
|
|
94
|
+
if (!comment && !check)
|
|
95
|
+
return [];
|
|
96
|
+
const { withProductWords } = (await import("@intentius/chant/ci-product-words"));
|
|
97
|
+
const plugin = await pluginOf(forge);
|
|
98
|
+
const options = { image: r.image, ...(forge === "gitlab" ? { opsStage: "ops", opsFileName: GITLAB_COMMIT_FILES[word] } : {}) };
|
|
99
|
+
const runCommand = checkCommand(word);
|
|
100
|
+
return withProductWords(YODEL_WORDS, () => {
|
|
101
|
+
const files = [];
|
|
102
|
+
if (forge === "gitlab") {
|
|
103
|
+
// One file per word: its comment's jobs and its check's, under stage ops.
|
|
104
|
+
files.push(...(plugin.generateOpPipeline([...(comment ? [comment] : []), ...(check ? [check] : [])], { ...options, runCommand }).files ?? []));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
if (comment)
|
|
108
|
+
files.push(...(plugin.generateOpPipeline([comment], options).files ?? []));
|
|
109
|
+
if (check)
|
|
110
|
+
files.push(...(plugin.generateOpPipeline([check], { ...options, runCommand }).files ?? []));
|
|
111
|
+
}
|
|
112
|
+
return Promise.resolve(files);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=commit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit.js","sourceRoot":"","sources":["../../src/ci/commit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAiD,MAAM,wCAAwC,CAAC;AAE1I,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qGAAqG;AACrG,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAEnD,sDAAsD;AACtD,MAAM,CAAC,MAAM,mBAAmB,GAA8C,EAAE,GAAG,EAAE,oCAAoC,EAAE,MAAM,EAAE,oCAAoC,EAAE,CAAC;AAC1K,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,GAAG,CAAC;AAE1D,yEAAyE;AACzE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAqB,EAAU,EAAE,CAAC,SAAS,IAAI,EAAE,CAAC;AAC5E,MAAM,CAAC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C,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;QACjJ,CAAC;aAAM,CAAC;YACN,IAAI,OAAO;gBAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;YACxF,IAAI,KAAK;gBAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;QACzG,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/ci/login.d.ts
CHANGED
|
@@ -16,19 +16,17 @@
|
|
|
16
16
|
* `id_tokens` are chant's (`CHANT_ID_TOKEN_<CLOUD>`).
|
|
17
17
|
*
|
|
18
18
|
* Forgejo gives a job no OIDC token, so there is nothing to trade: a login
|
|
19
|
-
* is rendered only
|
|
20
|
-
* provides, and it is
|
|
21
|
-
* -
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* The variables go to $GITHUB_ENV, so every later step has them (the
|
|
29
|
-
* report too). Yodel's own login on GitHub and GitLab, from before the
|
|
30
|
-
* trade, left in 0.12 (#303).
|
|
19
|
+
* is rendered only for a cloud whose config's `tokenFile` names a token the
|
|
20
|
+
* runner provides, and it is chant's cloud login from that file (chant's
|
|
21
|
+
* `forgejoCloudLogin`, `@intentius/chant/ci-login`): AWS web identity
|
|
22
|
+
* variables, a Google `external_account` credential that gcloud and the
|
|
23
|
+
* SDKs read, and Azure's federated token variables with `az login`. yodel
|
|
24
|
+
* keeps only the mapping from `ci.login` to chant's login spec
|
|
25
|
+
* ({@link forgejoLoginSpec}). The variables go to $GITHUB_ENV, so every
|
|
26
|
+
* later step has them (the report too). Yodel's own login on GitHub and
|
|
27
|
+
* GitLab, from before the trade, left in 0.12 (#303).
|
|
31
28
|
*/
|
|
29
|
+
import { type CloudLoginSpec } from "@intentius/chant/ci-login";
|
|
32
30
|
import type { AwsLogin, AzureLogin, CiLogin, CloudLogins, GcpLogin } from "../config/define.js";
|
|
33
31
|
import type { CloudToken, Role } from "../credentials.js";
|
|
34
32
|
/** One job's trade, in chant's `CloudTradeSpec` shape, the parts yodel fills. */
|
|
@@ -92,6 +90,13 @@ export declare function loginFor(login: CiLogin | undefined, env: string, token:
|
|
|
92
90
|
* for one cloud are refused.
|
|
93
91
|
*/
|
|
94
92
|
export declare function jobLogins(login: CiLogin | undefined, held: ReadonlyArray<readonly [string, Role]>, cloudOf: (env: string, role: Role) => CloudToken | undefined): Login[];
|
|
93
|
+
/**
|
|
94
|
+
* yodel.config.ts `ci.login` for a Forgejo job, as chant's login spec: each
|
|
95
|
+
* cloud whose config names a `tokenFile`. A cloud without one is left out,
|
|
96
|
+
* since there the runner's own identity mints. AWS keeps yodel's session
|
|
97
|
+
* name, and Azure logs the `az` command line in too, as before.
|
|
98
|
+
*/
|
|
99
|
+
export declare function forgejoLoginSpec(logins: readonly Login[]): CloudLoginSpec;
|
|
95
100
|
/** The login steps of a job on `forge`, for `logins`: chant's trade on GitHub and GitLab, the runner's token file on Forgejo. */
|
|
96
101
|
export declare function loginSteps(forge: LoginForge, logins: readonly Login[]): LoginSteps;
|
|
97
102
|
/** What is wrong with yodel.config.ts `ci.login`, if anything. */
|
package/dist/ci/login.js
CHANGED
|
@@ -16,20 +16,18 @@
|
|
|
16
16
|
* `id_tokens` are chant's (`CHANT_ID_TOKEN_<CLOUD>`).
|
|
17
17
|
*
|
|
18
18
|
* Forgejo gives a job no OIDC token, so there is nothing to trade: a login
|
|
19
|
-
* is rendered only
|
|
20
|
-
* provides, and it is
|
|
21
|
-
* -
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* The variables go to $GITHUB_ENV, so every later step has them (the
|
|
29
|
-
* report too). Yodel's own login on GitHub and GitLab, from before the
|
|
30
|
-
* trade, left in 0.12 (#303).
|
|
19
|
+
* is rendered only for a cloud whose config's `tokenFile` names a token the
|
|
20
|
+
* runner provides, and it is chant's cloud login from that file (chant's
|
|
21
|
+
* `forgejoCloudLogin`, `@intentius/chant/ci-login`): AWS web identity
|
|
22
|
+
* variables, a Google `external_account` credential that gcloud and the
|
|
23
|
+
* SDKs read, and Azure's federated token variables with `az login`. yodel
|
|
24
|
+
* keeps only the mapping from `ci.login` to chant's login spec
|
|
25
|
+
* ({@link forgejoLoginSpec}). The variables go to $GITHUB_ENV, so every
|
|
26
|
+
* later step has them (the report too). Yodel's own login on GitHub and
|
|
27
|
+
* GitLab, from before the trade, left in 0.12 (#303).
|
|
31
28
|
*/
|
|
32
29
|
import { gitlabTradeIdTokens, gitlabTradeLines, TRADE_SPEC_ENV, tradeLine } from "@intentius/chant/ci-identity";
|
|
30
|
+
import { forgejoCloudLogin } from "@intentius/chant/ci-login";
|
|
33
31
|
/** yodel.config.ts `ci.login` for a job's logins, as chant's trade spec. */
|
|
34
32
|
export function tradeSpec(logins) {
|
|
35
33
|
const spec = {};
|
|
@@ -99,39 +97,32 @@ export function jobLogins(login, held, cloudOf) {
|
|
|
99
97
|
return l ? [l] : [];
|
|
100
98
|
});
|
|
101
99
|
}
|
|
102
|
-
/** Writes the gcloud credential configuration: `node -e '<this>' <provider> <service account> <token file> <config file>`. */
|
|
103
|
-
const GCP_CREDENTIALS = 'const [provider, sa, token, file] = process.argv.slice(1); require("fs").writeFileSync(file, JSON.stringify({ type: "external_account", audience: "//iam.googleapis.com/" + provider, subject_token_type: "urn:ietf:params:oauth:token-type:jwt", token_url: "https://sts.googleapis.com/v1/token", service_account_impersonation_url: "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/" + sa + ":generateAccessToken", credential_source: { file: token } }, null, 2))';
|
|
104
100
|
const quote = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
|
|
105
|
-
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return { AZURE_CLIENT_ID: l.config.clientId, AZURE_TENANT_ID: l.config.tenantId, AZURE_FEDERATED_TOKEN_FILE: tokenFile };
|
|
114
|
-
}
|
|
115
|
-
const STEP_NAME = { aws: "Log in to AWS (web identity)", gcp: "Log in to Google Cloud (workload identity)", azure: "Log in to Azure (federated token)" };
|
|
116
|
-
/** A Forgejo job's login from the runner's token file; a cloud without a `tokenFile` is left out, since the runner's own identity mints there. */
|
|
117
|
-
function forgejoSteps(logins) {
|
|
118
|
-
const out = { steps: [], variables: {} };
|
|
101
|
+
/**
|
|
102
|
+
* yodel.config.ts `ci.login` for a Forgejo job, as chant's login spec: each
|
|
103
|
+
* cloud whose config names a `tokenFile`. A cloud without one is left out,
|
|
104
|
+
* since there the runner's own identity mints. AWS keeps yodel's session
|
|
105
|
+
* name, and Azure logs the `az` command line in too, as before.
|
|
106
|
+
*/
|
|
107
|
+
export function forgejoLoginSpec(logins) {
|
|
108
|
+
const spec = {};
|
|
119
109
|
for (const l of logins) {
|
|
120
|
-
const
|
|
121
|
-
if (
|
|
110
|
+
const tokenFile = l.config.tokenFile;
|
|
111
|
+
if (tokenFile === undefined)
|
|
122
112
|
continue;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
lines.push(`az login --service-principal --username ${quote(l.config.clientId)} --tenant ${quote(l.config.tenantId)} --federated-token "$(cat ${path(file)})" --allow-no-subscriptions --output none`);
|
|
130
|
-
}
|
|
131
|
-
lines.push(...Object.entries(loginVariables(l, file)).map(([k, v]) => `echo "${k}=${v}" >> "$GITHUB_ENV"`));
|
|
132
|
-
out.steps.push({ name: STEP_NAME[l.cloud], lines });
|
|
113
|
+
if (l.cloud === "aws")
|
|
114
|
+
spec.aws = { role: l.config.roleArn, tokenFile, sessionName: l.config.sessionName ?? "yodel", ...(l.config.region ? { region: l.config.region } : {}) };
|
|
115
|
+
else if (l.cloud === "gcp")
|
|
116
|
+
spec.gcp = { serviceAccount: l.config.serviceAccount, provider: l.config.workloadIdentityProvider, tokenFile };
|
|
117
|
+
else
|
|
118
|
+
spec.azure = { clientId: l.config.clientId, tenantId: l.config.tenantId, tokenFile, cli: true };
|
|
133
119
|
}
|
|
134
|
-
return
|
|
120
|
+
return spec;
|
|
121
|
+
}
|
|
122
|
+
/** A Forgejo job's login: chant's (`forgejoCloudLogin`), from the runner's token files. */
|
|
123
|
+
function forgejoSteps(logins) {
|
|
124
|
+
const out = forgejoCloudLogin(forgejoLoginSpec(logins));
|
|
125
|
+
return { steps: out.steps.map((st) => ({ name: st.name, lines: st.run })), variables: {} };
|
|
135
126
|
}
|
|
136
127
|
/** The login steps of a job on `forge`, for `logins`: chant's trade on GitHub and GitLab, the runner's token file on Forgejo. */
|
|
137
128
|
export function loginSteps(forge, logins) {
|
package/dist/ci/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/ci/login.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/ci/login.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAChH,OAAO,EAAE,iBAAiB,EAAuB,MAA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C,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QAC9I,KAAK,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/C,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACf,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,QAAQ;gBAAE,SAAS;YAChD,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;gBAAE,OAAO,GAAG,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QAC3F,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,KAAa;IACxD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,KAAK,kDAAkD,CAAC;IACxF,OAAO,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/ci/render.d.ts
CHANGED
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
* yodel ci renders through chant's product pipeline (chant#4550) with
|
|
76
76
|
* yodel's words (#289, ../ci-words.ts): {@link productWaves}.
|
|
77
77
|
*/
|
|
78
|
-
import { type ApplySteps, type ApprovalMode, type CiLogin, type WaveGate } from "../config/define.js";
|
|
78
|
+
import { type ApplySteps, type ApprovalMode, type CiLogin, type RespondNew, type RespondRebase, type WaveGate } from "../config/define.js";
|
|
79
79
|
import type { OpWaveHooks } from "@intentius/chant/op";
|
|
80
80
|
import { type CloudToken, type Role } from "../credentials.js";
|
|
81
81
|
import { type CheckHook } from "./check-hooks.js";
|
|
@@ -159,6 +159,10 @@ export interface Environments {
|
|
|
159
159
|
* the moment and the project has a declaration.
|
|
160
160
|
*/
|
|
161
161
|
checkHooks?: true;
|
|
162
|
+
/** yodel.config.ts `ci.respond.new` (#312): what answers `/yodel new`, through chant's commit job. Default `comment`. */
|
|
163
|
+
respondNew?: RespondNew;
|
|
164
|
+
/** yodel.config.ts `ci.respond.rebase` (#313): what answers `/yodel rebase`. Default `comment`, or `off` when a reader's password is cloud-minted. */
|
|
165
|
+
respondRebase?: RespondRebase;
|
|
162
166
|
}
|
|
163
167
|
/** The line the lint job runs chant's check moment with (#294): the hooks are read at the pull request's base. */
|
|
164
168
|
export declare const checkHooksLine: (forge: Forge) => string;
|
|
@@ -185,10 +189,14 @@ export declare const ID_TOKENS: Record<CloudToken, {
|
|
|
185
189
|
export declare const writeProbe: (envs: readonly string[]) => string;
|
|
186
190
|
/**
|
|
187
191
|
* The approvals: `chant approve` records them on the chant/lifecycle branch,
|
|
188
|
-
* and approvers push it. A CI checkout fetches one ref, so
|
|
189
|
-
*
|
|
192
|
+
* and approvers push it. A CI checkout fetches one ref, so each job fetches
|
|
193
|
+
* this one too, through chant's reader (`yodel ci --fetch-ledger`, #326):
|
|
194
|
+
* yodel writes neither the branch nor the remote-tracking ref chant's push
|
|
195
|
+
* leases against. `yodel` is the project's, named by path, as the line may
|
|
196
|
+
* run before the install's PATH reaches the step; in the yodel image, the
|
|
197
|
+
* image's.
|
|
190
198
|
*/
|
|
191
|
-
export declare const
|
|
199
|
+
export declare const fetchApprovals: (tc?: Pick<Toolchain, "yodelImage">) => string;
|
|
192
200
|
/** The watch reads; it never pushes. See the comment at the top. */
|
|
193
201
|
export declare const NO_PUSH = "git remote set-url --push origin no-push://the-drift-watch-only-reads";
|
|
194
202
|
/** After the watch's `chant run`: drift against the history, the environment's tracking issue, and exit 2 on drift. */
|
|
@@ -264,12 +272,13 @@ export declare const REPORT_DIR = "yodel-report";
|
|
|
264
272
|
export declare const reportCommand: (env: string, tc?: Toolchain) => string;
|
|
265
273
|
/** The artifact a job keeps its report in. */
|
|
266
274
|
export declare const reportArtifact: (job: string) => string;
|
|
267
|
-
/**
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
275
|
+
/** upload-artifact v4 on GitHub, and v3 from code.forgejo.org on Forgejo, where v4 refuses any server but github.com's (chant#4008), as chant's own Forgejo jobs have it. */
|
|
276
|
+
export declare const UPLOAD_ARTIFACT: string;
|
|
277
|
+
export declare const FORGEJO_UPLOAD_ARTIFACT: string;
|
|
278
|
+
/** The pipeline directories yodel ci writes into, besides the root `.gitlab-ci.yml`. */
|
|
279
|
+
export declare const PIPELINE_DIRS: string[];
|
|
280
|
+
/** Whether a file's text is one yodel ci wrote: it opens with the header (#348). */
|
|
281
|
+
export declare const renderedByYodel: (text: string) => boolean;
|
|
273
282
|
type Actions = "github" | "forgejo";
|
|
274
283
|
export declare function actionsReview(forge: Actions, envs_: Environments): RenderedFile;
|
|
275
284
|
export declare const GITLAB_WATCH_FILE = ".gitlab/yodel-watch.gitlab-ci.yml";
|
|
@@ -327,6 +336,7 @@ interface WavesSpec {
|
|
|
327
336
|
name: string;
|
|
328
337
|
};
|
|
329
338
|
variables?: Record<string, string>;
|
|
339
|
+
idTokens?: Record<string, string>;
|
|
330
340
|
hooks?: OpWaveHooks;
|
|
331
341
|
}>;
|
|
332
342
|
/** The scheduled resume job (yodel.config.ts `ci.resume`); only the pipelines are rendered from it, the spec file leaves it out. */
|
|
@@ -334,9 +344,14 @@ interface WavesSpec {
|
|
|
334
344
|
schedule: string;
|
|
335
345
|
};
|
|
336
346
|
}
|
|
347
|
+
/** A wave job's own variables and the OIDC tokens it requests, on one forge, as the spec's wave carries them (chant's `variables` and `idTokens`). */
|
|
348
|
+
export interface WaveJobSettings {
|
|
349
|
+
variables: Record<string, string>;
|
|
350
|
+
idTokens?: Record<string, string>;
|
|
351
|
+
}
|
|
337
352
|
/**
|
|
338
353
|
* The waves spec. What the file holds is the same for every forge; each
|
|
339
|
-
* forge's jobs get their own variables on top (`
|
|
354
|
+
* forge's jobs get their own variables and OIDC tokens on top (`job`).
|
|
340
355
|
*
|
|
341
356
|
* The spec names the sql lexicon's `sql-migrate` capability (#291,
|
|
342
357
|
* chant#4569), and chant plans and applies each run through it, which calls
|
|
@@ -355,7 +370,7 @@ interface WavesSpec {
|
|
|
355
370
|
* the base commit, as it does run by hand. A step runs once, under the
|
|
356
371
|
* lock, as #107 asks.
|
|
357
372
|
*/
|
|
358
|
-
export declare function wavesSpec(waves: readonly Wave[],
|
|
373
|
+
export declare function wavesSpec(waves: readonly Wave[], job?: (env: string) => WaveJobSettings, resume?: {
|
|
359
374
|
schedule: string;
|
|
360
375
|
}): WavesSpec;
|
|
361
376
|
/** The sql lexicon's capability for a versioned environment (chant#4569). */
|
|
@@ -363,25 +378,14 @@ export declare const SQL_MIGRATE = "sql-migrate";
|
|
|
363
378
|
/**
|
|
364
379
|
* The waves spec file and the apply pipeline on each forge. The spec comes
|
|
365
380
|
* from chant's productPipelineJobs under yodel's words (#289), and each job
|
|
366
|
-
* runs `yodel chant` where chant's own runs `chant` (
|
|
381
|
+
* runs `yodel chant` where chant's own runs `chant` (chant's `bin`,
|
|
382
|
+
* {@link productWaves}). What yodel adds to chant's jobs goes in as
|
|
383
|
+
* generateOpWavesPipeline's inputs (#4791): each wave job's cloud login,
|
|
384
|
+
* its `yodel report` and the report's artifact (`waveJobs`), the plans
|
|
385
|
+
* job's login, write probe and readers (`recordPlans`), and each wave's
|
|
386
|
+
* variables and OIDC tokens in the spec.
|
|
367
387
|
*/
|
|
368
388
|
export declare function applyPipelines(dir: string, envs: Environments, product: ChantProduct): Promise<RenderedFile[]>;
|
|
369
|
-
/**
|
|
370
|
-
* The wave jobs' report: chant's generateOpWavesPipeline takes run lines
|
|
371
|
-
* after the wave's command but no step that runs when it fails (a wave that
|
|
372
|
-
* waits exits 3), and no artifact, so they are added to its output here.
|
|
373
|
-
* The output is parsed and emitted again; the emitter is checked to give
|
|
374
|
-
* back chant's text unchanged before anything is added, so a change in
|
|
375
|
-
* chant's emitter fails here instead of rendering something else.
|
|
376
|
-
*/
|
|
377
|
-
/**
|
|
378
|
-
* chant writes a SHA-pinned action as `uses: owner/action@<sha> # vX.Y.Z`
|
|
379
|
-
* (chant#4403, #4410); the `# vX.Y.Z` is a YAML comment, which parsing drops.
|
|
380
|
-
* Each re-emit below puts every one back on the line that names the same
|
|
381
|
-
* pinned ref, so the re-emitted text still matches chant's and the files keep
|
|
382
|
-
* the release each SHA stands for.
|
|
383
|
-
*/
|
|
384
|
-
export declare function withPinComments(original: string, emitted: string): string;
|
|
385
389
|
/** yodel.config.ts `waves`, checked against the environments; one wave per environment, gate `always`, without it. */
|
|
386
390
|
export declare function readWaves(dir: string, envs: readonly string[]): Promise<Wave[]>;
|
|
387
391
|
/**
|
|
@@ -399,23 +403,36 @@ export declare function productWaves(product: ChantProduct, forge: Forge, spec:
|
|
|
399
403
|
spec: WavesSpec;
|
|
400
404
|
jobs: ProductWaveJob[];
|
|
401
405
|
};
|
|
402
|
-
/**
|
|
403
|
-
export
|
|
404
|
-
/**
|
|
405
|
-
* The watch's spec for one environment: the Op, and on GitHub and Forgejo the
|
|
406
|
-
* reader's secrets. A GitLab job already has the project's variables (a
|
|
407
|
-
* writer's only under its environment, which the watch does not declare), and
|
|
408
|
-
* `NAME: $NAME` there would refer to itself.
|
|
409
|
-
*/
|
|
410
|
-
export declare function watchSpec(env: string, dialect: Dialect, forge: Forge, creds?: EnvCredentials): {
|
|
406
|
+
/** A watch's spec: chant's ScheduledOpSpec, the parts yodel fills. */
|
|
407
|
+
export interface WatchSpec {
|
|
411
408
|
name: string;
|
|
412
409
|
variables?: Record<string, string>;
|
|
413
|
-
permissions?: Record<string,
|
|
414
|
-
|
|
410
|
+
permissions?: Record<string, "read" | "write">;
|
|
411
|
+
/** A step's name is written on GitHub and Forgejo (chant issue 4932); GitLab's script lines have none. */
|
|
412
|
+
setup?: Array<{
|
|
413
|
+
name?: string;
|
|
414
|
+
run: string;
|
|
415
|
+
}>;
|
|
416
|
+
gitlab?: {
|
|
417
|
+
idTokens: Record<string, {
|
|
418
|
+
aud: string;
|
|
419
|
+
}>;
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* The watch's spec for one environment: the Op, the cloud login (#132) when
|
|
424
|
+
* its reader is cloud-minted, as setup steps before the job's other lines,
|
|
425
|
+
* and on GitHub and Forgejo the reader's secrets. A GitLab job already has
|
|
426
|
+
* the project's variables (a writer's only under its environment, which the
|
|
427
|
+
* watch does not declare), and `NAME: $NAME` there would refer to itself;
|
|
428
|
+
* there the login's variables and the job's ID tokens go on the job.
|
|
429
|
+
*/
|
|
430
|
+
export declare function watchSpec(env: string, forge: Forge, envs: Pick<Environments, "dialect" | "credentials" | "login">): WatchSpec;
|
|
415
431
|
/**
|
|
416
|
-
* The drift watches, through chant's
|
|
417
|
-
* `yodel chant run watch-<env>` where chant's runs `chant run watch-<env
|
|
418
|
-
* so the Op's statuses and notices say
|
|
432
|
+
* The drift watches, through chant's generateOpsPipeline: each job runs
|
|
433
|
+
* `yodel chant run watch-<env>` where chant's runs `chant run watch-<env>`
|
|
434
|
+
* (the generator's `runCommand`), so the Op's statuses and notices say
|
|
435
|
+
* yodel (#289).
|
|
419
436
|
*
|
|
420
437
|
* The job stays chant's generateOpsPipeline and its last line stays `yodel
|
|
421
438
|
* drift <env> --issue`, which plans the build for ClickHouse grant drift
|
|
@@ -424,7 +441,22 @@ export declare function watchSpec(env: string, dialect: Dialect, forge: Forge, c
|
|
|
424
441
|
* sql lexicon's live diff, the watch moves onto chant's drift job with
|
|
425
442
|
* `stages.drift` and the workaround goes.
|
|
426
443
|
*/
|
|
427
|
-
export declare function watchPipelines(dir: string, envs_: Environments
|
|
444
|
+
export declare function watchPipelines(dir: string, envs_: Environments): Promise<RenderedFile[]>;
|
|
445
|
+
/** Whether `/yodel new` gets chant's commit job (#312): `ci.respond.new` is not `off`. */
|
|
446
|
+
export declare const respondsNew: (envs: Pick<Environments, "respondNew" | "checkOnly">) => boolean;
|
|
447
|
+
/**
|
|
448
|
+
* What answers `/yodel rebase` (#313): `ci.respond.rebase`, by default
|
|
449
|
+
* `comment`. The rebase reads every environment's history with its reader,
|
|
450
|
+
* and chant's commit job takes no cloud identity yet, so with a
|
|
451
|
+
* cloud-minted reader the default is `off`, and asking for it is refused.
|
|
452
|
+
*/
|
|
453
|
+
export declare function rebaseRespond(envs: Pick<Environments, "respondRebase" | "checkOnly" | "names" | "credentials">): RespondRebase;
|
|
454
|
+
/**
|
|
455
|
+
* `/yodel new` and `/yodel rebase`, chant's commit job (#312, #313,
|
|
456
|
+
* ./commit.ts): a workflow per job on GitHub and Forgejo, and a file per
|
|
457
|
+
* word GitLab's pipeline includes.
|
|
458
|
+
*/
|
|
459
|
+
export declare function commitPipelines(dir: string, envs_: Environments): Promise<RenderedFile[]>;
|
|
428
460
|
/** The dialect and the environments chant.config.ts declares, in order. */
|
|
429
461
|
export declare function environments(dir: string): Promise<Environments>;
|
|
430
462
|
/** The roles of each environment whose profile is made with credentials(). */
|
|
@@ -455,8 +487,7 @@ export declare function loadProjectJobs(dir: string, file: string): Promise<Proj
|
|
|
455
487
|
export declare function review(envs: Environments): RenderedFile[];
|
|
456
488
|
/**
|
|
457
489
|
* The workspace declaration with yodel's check presets in `ci.hooks.check`
|
|
458
|
-
* (#294), or undefined when the
|
|
459
|
-
* project has no declaration. The hooks are one list for every forge: the
|
|
490
|
+
* (#294), or undefined when the project has no declaration. The hooks are one list for every forge: the
|
|
460
491
|
* lint and check presets print with `--format forge`, so a GitHub or
|
|
461
492
|
* Forgejo job annotates the files and a GitLab job writes the code quality
|
|
462
493
|
* report its artifact keeps.
|
|
@@ -464,7 +495,7 @@ export declare function review(envs: Environments): RenderedFile[];
|
|
|
464
495
|
export declare function checkHooksDeclaration(dir: string, envs_: Environments, declaration?: RenderedFile): Promise<RenderedFile | undefined>;
|
|
465
496
|
/** The forge a rendered file is for; undefined for the waves spec, which every forge's apply reads. */
|
|
466
497
|
export declare function forgeOf(path: string): Forge | undefined;
|
|
467
|
-
/** chant's product pipeline (#289), which every pipeline renders through
|
|
498
|
+
/** chant's product pipeline (#289), which every pipeline renders through. */
|
|
468
499
|
export declare function requireProduct(): Promise<ChantProduct>;
|
|
469
500
|
/**
|
|
470
501
|
* Every file `yodel ci` writes, through chant's product pipeline (#289).
|
|
@@ -473,8 +504,11 @@ export declare function requireProduct(): Promise<ChantProduct>;
|
|
|
473
504
|
* check hooks into when the project has none on disk: the one `yodel
|
|
474
505
|
* upgrade` adds (#298). A project with no declaration, in its directory or
|
|
475
506
|
* given here, keeps the lint job's own steps ({@link checkHooksDeclaration}).
|
|
507
|
+
* `options.respondNew` and `options.respondRebase` stand in for yodel.config.ts `ci.respond`.
|
|
476
508
|
*/
|
|
477
509
|
export declare function render(dir: string, options?: {
|
|
478
510
|
declaration?: RenderedFile;
|
|
511
|
+
respondNew?: RespondNew;
|
|
512
|
+
respondRebase?: RespondRebase;
|
|
479
513
|
}): Promise<RenderedFile[]>;
|
|
480
514
|
export {};
|