@catladder/cli 0.0.0-next-3675a1db → 0.0.0-next-ca8f99e2
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/dist/apps/cli/src/apps/cli/commands/project/doctor/checkGithub.js +40 -0
- package/dist/apps/cli/src/apps/cli/commands/project/doctor/checkGithub.js.map +1 -1
- package/dist/apps/cli/src/apps/cli/commands/project/setup/index.js +12 -3
- package/dist/apps/cli/src/apps/cli/commands/project/setup/index.js.map +1 -1
- package/dist/apps/cli/src/apps/cli/commands/project/setup/setupGithub.d.ts +20 -0
- package/dist/apps/cli/src/apps/cli/commands/project/setup/setupGithub.js +92 -0
- package/dist/apps/cli/src/apps/cli/commands/project/setup/setupGithub.js.map +1 -0
- package/dist/apps/cli/src/utils/github.d.ts +2 -0
- package/dist/apps/cli/src/utils/github.js +24 -1
- package/dist/apps/cli/src/utils/github.js.map +1 -1
- package/dist/bundles/catenv/index.js +1 -0
- package/dist/bundles/cli/index.js +176 -4
- package/dist/bundles/skills/catladder-migrate-ci-backend/SKILL.md +9 -12
- package/dist/packages/pipeline/src/backends/github/index.d.ts +1 -0
- package/dist/packages/pipeline/src/backends/github/index.js +1 -0
- package/dist/packages/pipeline/src/backends/github/index.js.map +1 -1
- package/dist/skills/catladder-migrate-ci-backend/SKILL.md +9 -12
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/apps/cli/commands/project/doctor/checkGithub.ts +55 -0
- package/src/apps/cli/commands/project/setup/index.ts +17 -4
- package/src/apps/cli/commands/project/setup/setupGithub.ts +117 -0
- package/src/utils/github.ts +30 -0
|
@@ -103,6 +103,46 @@ const checkGithub = async (report, config) => {
|
|
|
103
103
|
report.ok(`repo level: all ${repoLevelReferenced.length} referenced secrets/variables present`);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
+
await checkGithubMergeGating(report, repo);
|
|
106
107
|
};
|
|
107
108
|
exports.checkGithub = checkGithub;
|
|
109
|
+
/**
|
|
110
|
+
* verifies the merge gating `project setup` configures: auto-merge
|
|
111
|
+
* enabled and the generated `catladder ✅` aggregate check required on
|
|
112
|
+
* the default branch. Without it a PR is mergeable while its checks
|
|
113
|
+
* are still running — gitlab ships this behavior built-in, github
|
|
114
|
+
* silently does not.
|
|
115
|
+
*/
|
|
116
|
+
const checkGithubMergeGating = async (report, repo) => {
|
|
117
|
+
var _a, _b;
|
|
118
|
+
let repoInfo;
|
|
119
|
+
try {
|
|
120
|
+
repoInfo = await (0, github_1.ghApiJson)("GET", `repos/${repo}`);
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
report.warn(`could not read repo settings of ${repo} (${e.message})`);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (repoInfo.allow_auto_merge) {
|
|
127
|
+
report.ok("auto-merge enabled");
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
report.fail("auto-merge disabled — the merge-when-pipeline-succeeds button cannot appear", "run: catladder project setup");
|
|
131
|
+
}
|
|
132
|
+
const branch = repoInfo.default_branch;
|
|
133
|
+
const protection = await (0, github_1.ghApiJson)("GET", `repos/${repo}/branches/${branch}/protection`).catch(() => null);
|
|
134
|
+
const checks = (_b = (_a = protection === null || protection === void 0 ? void 0 : protection.required_status_checks) === null || _a === void 0 ? void 0 : _a.checks) !== null && _b !== void 0 ? _b : [];
|
|
135
|
+
if (checks.some((c) => c.context === pipeline_1.AGGREGATE_CHECK_JOB_NAME)) {
|
|
136
|
+
report.ok(`'${pipeline_1.AGGREGATE_CHECK_JOB_NAME}' required on ${branch}`);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
report.fail(`'${pipeline_1.AGGREGATE_CHECK_JOB_NAME}' is not a required check on ${branch} — PRs can merge while the pipeline is red or still running`, "run: catladder project setup");
|
|
140
|
+
}
|
|
141
|
+
const stale = checks.filter((c) => c.context !== pipeline_1.AGGREGATE_CHECK_JOB_NAME);
|
|
142
|
+
if (stale.length > 0) {
|
|
143
|
+
report.warn(`${branch} requires ${stale.length} additional named check(s) (${stale
|
|
144
|
+
.map((c) => c.context)
|
|
145
|
+
.join(", ")}) — job names change with components; prefer only '${pipeline_1.AGGREGATE_CHECK_JOB_NAME}'`);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
108
148
|
//# sourceMappingURL=checkGithub.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkGithub.js","sourceRoot":"","sources":["../../../../../../../../../src/apps/cli/commands/project/doctor/checkGithub.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"checkGithub.js","sourceRoot":"","sources":["../../../../../../../../../src/apps/cli/commands/project/doctor/checkGithub.ts"],"names":[],"mappings":";;;AACA,kDAI6B;AAC7B,uGAGkE;AAClE,kEAAsE;AACtE,wDAMqC;AAGrC,iFAAiF;AACjF,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,KAAK,EAAE,MAAoB,EAAE,MAAc,EAAE,EAAE;IACxE,IAAI,CAAC,IAAA,kCAAuB,EAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO;IAChE,MAAM,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;IAEhD,IAAI,CAAC,CAAC,MAAM,IAAA,0BAAiB,GAAE,CAAC,EAAE,CAAC;QACjC,MAAM,CAAC,IAAI,CACT,2DAA2D,EAC3D,oBAAoB,CACrB,CAAC;QACF,OAAO;IACT,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,IAAA,kDAAuB,GAAE,CAAC;IAC7C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,CAAC,IAAI,CACT,sCAAsC,IAAA,+BAAoB,EAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CACvF,CAAC;QACF,OAAO;IACT,CAAC;IAED,IAAI,OAAiC,CAAC;IACtC,IAAI,CAAC;QACH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AAa,MAAM,aAAa,CAC9C,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACpB,MAAM,MAAM,GACV,MAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,sBAAsB,0CAAE,MAAM,mCAAI,EAAE,CAAC;IACnD,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,mCAAwB,CAAC,EAAE,CAAC;QAC/D,MAAM,CAAC,EAAE,CAAC,IAAI,mCAAwB,iBAAiB,MAAM,EAAE,CAAC,CAAC;IACnE,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CACT,IAAI,mCAAwB,gCAAgC,MAAM,6DAA6D,EAC/H,8BAA8B,CAC/B,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,mCAAwB,CAAC,CAAC;IAC3E,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,CAAC,IAAI,CACT,GAAG,MAAM,aAAa,KAAK,CAAC,MAAM,+BAA+B,KAAK;aACnE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;aACrB,IAAI,CACH,IAAI,CACL,sDAAsD,mCAAwB,GAAG,CACrF,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -7,6 +7,7 @@ const setupAccessTokens_1 = require("./setupAccessTokens");
|
|
|
7
7
|
const setupContext_1 = require("./setupContext");
|
|
8
8
|
const setupTopic_1 = require("./setupTopic");
|
|
9
9
|
const setupAgents_1 = require("./setupAgents");
|
|
10
|
+
const setupGithub_1 = require("./setupGithub");
|
|
10
11
|
const logSection_1 = require("./logSection");
|
|
11
12
|
const ensureGcloudProjectNumbers_1 = require("./ensureGcloudProjectNumbers");
|
|
12
13
|
const setupProject = async (instance, onlyComponents) => {
|
|
@@ -26,16 +27,24 @@ const setupProject = async (instance, onlyComponents) => {
|
|
|
26
27
|
allContext.forEach((context) => {
|
|
27
28
|
instance.log(` - ${context.name}:${context.env}`);
|
|
28
29
|
});
|
|
30
|
+
const enabledPipelines = config ? (0, pipeline_1.getEnabledPipelineTypes)(config) : [];
|
|
29
31
|
await (0, logSection_1.logSection)(instance, "base setup", async () => {
|
|
30
|
-
|
|
32
|
+
// gitlab-specific provisioning (access token, agent webhooks) —
|
|
33
|
+
// meaningless (and failing) on a github-only project
|
|
34
|
+
if (enabledPipelines.includes("gitlab")) {
|
|
35
|
+
await (0, setupAccessTokens_1.setupAccessTokens)(instance);
|
|
36
|
+
await (0, setupAgents_1.setupAgents)(instance);
|
|
37
|
+
}
|
|
31
38
|
await (0, setupTopic_1.setupTopic)(instance);
|
|
32
|
-
|
|
39
|
+
if (config) {
|
|
40
|
+
await (0, setupGithub_1.setupGithub)(instance, config);
|
|
41
|
+
}
|
|
33
42
|
});
|
|
34
43
|
for (const context of allContext) {
|
|
35
44
|
await (0, setupContext_1.setupContext)(instance, context);
|
|
36
45
|
}
|
|
37
46
|
instance.log("");
|
|
38
|
-
instance.log("gitlab is ready!
|
|
47
|
+
instance.log(`${enabledPipelines.join(" + ") || "gitlab"} is ready! 🥂`);
|
|
39
48
|
instance.log("\n");
|
|
40
49
|
instance.log("do not forget to make sure that:");
|
|
41
50
|
[
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../src/apps/cli/commands/project/setup/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../src/apps/cli/commands/project/setup/index.ts"],"names":[],"mappings":";;;AAAA,kDAI6B;AAE7B,6EAGgD;AAChD,2DAAwD;AACxD,iDAA8C;AAC9C,6CAA0C;AAC1C,+CAA4C;AAC5C,+CAA4C;AAC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AM,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC,CAAC;IACH,KAAK,MAAM,OAAO,IAAI,UAAU,EAAE,CAAC;QACjC,MAAM,IAAA,2BAAY,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,QAAQ,eAAe,CAAC,CAAC;IACzE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnB,QAAQ,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IACjD;QACE,kCAAkC;QAClC,2BAA2B;QAC3B,qDAAqD;QACrD,qBAAqB;QACrB,eAAe;KAChB,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;IAC9C,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACrB,CAAC,CAAC;AApDW,QAAA,YAAY,gBAoDvB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Config } from "../../../../../../../../packages/pipeline/src/index.js";
|
|
2
|
+
import type { IO } from "../../../../../core/types";
|
|
3
|
+
/**
|
|
4
|
+
* configures github merge gating — the sane default gitlab ships
|
|
5
|
+
* built-in and a fresh github repository lacks entirely: without it a
|
|
6
|
+
* PR is mergeable the moment it opens, checks still running, and the
|
|
7
|
+
* auto-merge button never appears.
|
|
8
|
+
*
|
|
9
|
+
* - repo settings: allow auto-merge, delete merged head branches
|
|
10
|
+
* - branch protection on the default branch: require the generated
|
|
11
|
+
* `catladder ✅` aggregate check (the one stable context — individual
|
|
12
|
+
* job names change with every component add/rename)
|
|
13
|
+
*
|
|
14
|
+
* Deliberately non-destructive: existing protection settings
|
|
15
|
+
* (enforce-admins, required reviews, restrictions, strictness) are
|
|
16
|
+
* preserved; the aggregate context is merged into the required checks
|
|
17
|
+
* rather than replacing them. Admins can still bypass per PR — this is
|
|
18
|
+
* a default, not a cage.
|
|
19
|
+
*/
|
|
20
|
+
export declare const setupGithub: (instance: IO, config: Config) => Promise<void>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupGithub = void 0;
|
|
4
|
+
const pipeline_1 = require("../../../../../../../../packages/pipeline/src/index.js");
|
|
5
|
+
const commandSecretsSyncGithub_1 = require("../../../../../commands/project/commandSecretsSyncGithub");
|
|
6
|
+
const github_1 = require("../../../../../utils/github");
|
|
7
|
+
/**
|
|
8
|
+
* configures github merge gating — the sane default gitlab ships
|
|
9
|
+
* built-in and a fresh github repository lacks entirely: without it a
|
|
10
|
+
* PR is mergeable the moment it opens, checks still running, and the
|
|
11
|
+
* auto-merge button never appears.
|
|
12
|
+
*
|
|
13
|
+
* - repo settings: allow auto-merge, delete merged head branches
|
|
14
|
+
* - branch protection on the default branch: require the generated
|
|
15
|
+
* `catladder ✅` aggregate check (the one stable context — individual
|
|
16
|
+
* job names change with every component add/rename)
|
|
17
|
+
*
|
|
18
|
+
* Deliberately non-destructive: existing protection settings
|
|
19
|
+
* (enforce-admins, required reviews, restrictions, strictness) are
|
|
20
|
+
* preserved; the aggregate context is merged into the required checks
|
|
21
|
+
* rather than replacing them. Admins can still bypass per PR — this is
|
|
22
|
+
* a default, not a cage.
|
|
23
|
+
*/
|
|
24
|
+
const setupGithub = async (instance, config) => {
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
26
|
+
if (!(0, pipeline_1.getEnabledPipelineTypes)(config).includes("github")) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (!(await (0, github_1.isGhAuthenticated)())) {
|
|
30
|
+
instance.log("⚠️ github cli (gh) not authenticated — skipping github merge-gating setup (run: gh auth login)");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const repo = await (0, commandSecretsSyncGithub_1.getConfiguredGithubRepo)();
|
|
34
|
+
if (!repo) {
|
|
35
|
+
instance.log(`⚠️ no github repository found on the '${(0, pipeline_1.getPipelineGitRemote)(config, "github")}' remote — skipping github merge-gating setup`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const repoInfo = await (0, github_1.ghApiJson)("GET", `repos/${repo}`);
|
|
39
|
+
if (!repoInfo.allow_auto_merge || !repoInfo.delete_branch_on_merge) {
|
|
40
|
+
await (0, github_1.ghApiJson)("PATCH", `repos/${repo}`, {
|
|
41
|
+
allow_auto_merge: true,
|
|
42
|
+
delete_branch_on_merge: true,
|
|
43
|
+
});
|
|
44
|
+
instance.log("✅ auto-merge + delete-merged-branches enabled");
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
instance.log("✅ auto-merge already enabled");
|
|
48
|
+
}
|
|
49
|
+
const branch = repoInfo.default_branch;
|
|
50
|
+
const protection = await (0, github_1.ghApiJson)("GET", `repos/${repo}/branches/${branch}/protection`).catch(() => null); // 404: branch not protected yet
|
|
51
|
+
const existingChecks = (_b = (_a = protection === null || protection === void 0 ? void 0 : protection.required_status_checks) === null || _a === void 0 ? void 0 : _a.checks) !== null && _b !== void 0 ? _b : [];
|
|
52
|
+
if (existingChecks.some((c) => c.context === pipeline_1.AGGREGATE_CHECK_JOB_NAME)) {
|
|
53
|
+
instance.log(`✅ '${pipeline_1.AGGREGATE_CHECK_JOB_NAME}' already required on ${branch}`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// merge into whatever protection exists; PUT replaces the whole rule,
|
|
57
|
+
// so every preserved setting must be carried over explicitly
|
|
58
|
+
await (0, github_1.ghApiJson)("PUT", `repos/${repo}/branches/${branch}/protection`, {
|
|
59
|
+
required_status_checks: {
|
|
60
|
+
strict: (_d = (_c = protection === null || protection === void 0 ? void 0 : protection.required_status_checks) === null || _c === void 0 ? void 0 : _c.strict) !== null && _d !== void 0 ? _d : false,
|
|
61
|
+
checks: [
|
|
62
|
+
...existingChecks.map(({ context, app_id }) => ({
|
|
63
|
+
context,
|
|
64
|
+
...(app_id !== undefined ? { app_id } : {}),
|
|
65
|
+
})),
|
|
66
|
+
{ context: pipeline_1.AGGREGATE_CHECK_JOB_NAME },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
enforce_admins: (_f = (_e = protection === null || protection === void 0 ? void 0 : protection.enforce_admins) === null || _e === void 0 ? void 0 : _e.enabled) !== null && _f !== void 0 ? _f : false,
|
|
70
|
+
required_pull_request_reviews: (protection === null || protection === void 0 ? void 0 : protection.required_pull_request_reviews)
|
|
71
|
+
? {
|
|
72
|
+
required_approving_review_count: (_g = protection.required_pull_request_reviews
|
|
73
|
+
.required_approving_review_count) !== null && _g !== void 0 ? _g : 0,
|
|
74
|
+
dismiss_stale_reviews: (_h = protection.required_pull_request_reviews.dismiss_stale_reviews) !== null && _h !== void 0 ? _h : false,
|
|
75
|
+
require_code_owner_reviews: (_j = protection.required_pull_request_reviews
|
|
76
|
+
.require_code_owner_reviews) !== null && _j !== void 0 ? _j : false,
|
|
77
|
+
}
|
|
78
|
+
: null,
|
|
79
|
+
restrictions: (protection === null || protection === void 0 ? void 0 : protection.restrictions)
|
|
80
|
+
? {
|
|
81
|
+
users: protection.restrictions.users.map((u) => u.login),
|
|
82
|
+
teams: protection.restrictions.teams.map((t) => t.slug),
|
|
83
|
+
apps: protection.restrictions.apps.map((a) => a.slug),
|
|
84
|
+
}
|
|
85
|
+
: null,
|
|
86
|
+
allow_force_pushes: (_l = (_k = protection === null || protection === void 0 ? void 0 : protection.allow_force_pushes) === null || _k === void 0 ? void 0 : _k.enabled) !== null && _l !== void 0 ? _l : false,
|
|
87
|
+
allow_deletions: (_o = (_m = protection === null || protection === void 0 ? void 0 : protection.allow_deletions) === null || _m === void 0 ? void 0 : _m.enabled) !== null && _o !== void 0 ? _o : false,
|
|
88
|
+
});
|
|
89
|
+
instance.log(`✅ branch protection on ${branch}: '${pipeline_1.AGGREGATE_CHECK_JOB_NAME}' required (merges now wait for the pipeline)`);
|
|
90
|
+
};
|
|
91
|
+
exports.setupGithub = setupGithub;
|
|
92
|
+
//# sourceMappingURL=setupGithub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupGithub.js","sourceRoot":"","sources":["../../../../../../../../../src/apps/cli/commands/project/setup/setupGithub.ts"],"names":[],"mappings":";;;AACA,kDAI6B;AAC7B,uGAAmG;AAEnG,wDAA2E;AAE3E;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,WAAW,GAAG,KAAK,EAAE,QAAY,EAAE,MAAc,EAAE,EAAE;;IAChE,IAAI,CAAC,IAAA,kCAAuB,EAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxD,OAAO;IACT,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,IAAA,0BAAiB,GAAE,CAAC,EAAE,CAAC;QACjC,QAAQ,CAAC,GAAG,CACV,gGAAgG,CACjG,CAAC;QACF,OAAO;IACT,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,IAAA,kDAAuB,GAAE,CAAC;IAC7C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,QAAQ,CAAC,GAAG,CACV,yCAAyC,IAAA,+BAAoB,EAAC,MAAM,EAAE,QAAQ,CAAC,+CAA+C,CAC/H,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,IAAA,kBAAS,EAI7B,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;IAE3B,IAAI,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,QAAQ,CAAC,sBAAsB,EAAE,CAAC;QACnE,MAAM,IAAA,kBAAS,EAAC,OAAO,EAAE,SAAS,IAAI,EAA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,GAAG,CACV,0BAA0B,MAAM,MAAM,mCAAwB,+CAA+C,CAC9G,CAAC;AACJ,CAAC,CAAC;AAzFW,QAAA,WAAW,eAyFtB"}
|
|
@@ -33,3 +33,5 @@ export declare const setGithubVariable: (repo: string, name: string, value: stri
|
|
|
33
33
|
* PUT with an empty body leaves existing settings untouched)
|
|
34
34
|
*/
|
|
35
35
|
export declare const ensureGithubEnvironment: (repo: string, environment: string) => Promise<void>;
|
|
36
|
+
/** runs `gh api` with an optional JSON body and returns the parsed response */
|
|
37
|
+
export declare const ghApiJson: <T = any>(method: "GET" | "PATCH" | "PUT", path: string, body?: unknown) => Promise<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureGithubEnvironment = exports.setGithubVariable = exports.setGithubSecret = exports.listGithubVariableNames = exports.listGithubSecretNames = exports.listGithubEnvironments = exports.getGithubRepoFromRemote = exports.isGhAuthenticated = void 0;
|
|
3
|
+
exports.ghApiJson = exports.ensureGithubEnvironment = exports.setGithubVariable = exports.setGithubSecret = exports.listGithubVariableNames = exports.listGithubSecretNames = exports.listGithubEnvironments = exports.getGithubRepoFromRemote = exports.isGhAuthenticated = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const util_1 = require("util");
|
|
6
6
|
const execFile = (0, util_1.promisify)(child_process_1.execFile);
|
|
@@ -111,4 +111,27 @@ const ensureGithubEnvironment = async (repo, environment) => new Promise((resolv
|
|
|
111
111
|
: reject(new Error(`creating github environment ${environment} failed: ${stderr.trim()}`)));
|
|
112
112
|
});
|
|
113
113
|
exports.ensureGithubEnvironment = ensureGithubEnvironment;
|
|
114
|
+
/** runs `gh api` with an optional JSON body and returns the parsed response */
|
|
115
|
+
const ghApiJson = async (method, path, body) => {
|
|
116
|
+
var _a, _b, _c, _d;
|
|
117
|
+
const args = ["api", "-X", method, path];
|
|
118
|
+
const child = (0, child_process_1.spawn)("gh", [...args, ...(body ? ["--input", "-"] : [])], {
|
|
119
|
+
stdio: [body ? "pipe" : "ignore", "pipe", "pipe"],
|
|
120
|
+
});
|
|
121
|
+
let stdout = "";
|
|
122
|
+
let stderr = "";
|
|
123
|
+
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on("data", (data) => (stdout += data));
|
|
124
|
+
(_b = child.stderr) === null || _b === void 0 ? void 0 : _b.on("data", (data) => (stderr += data));
|
|
125
|
+
if (body) {
|
|
126
|
+
(_c = child.stdin) === null || _c === void 0 ? void 0 : _c.write(JSON.stringify(body));
|
|
127
|
+
(_d = child.stdin) === null || _d === void 0 ? void 0 : _d.end();
|
|
128
|
+
}
|
|
129
|
+
return new Promise((resolve, reject) => {
|
|
130
|
+
child.on("error", reject);
|
|
131
|
+
child.on("close", (code) => code === 0
|
|
132
|
+
? resolve(stdout ? JSON.parse(stdout) : undefined)
|
|
133
|
+
: reject(new Error(`gh api ${method} ${path} failed: ${stderr.trim()}`)));
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
exports.ghApiJson = ghApiJson;
|
|
114
137
|
//# sourceMappingURL=github.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github.js","sourceRoot":"","sources":["../../../../../src/utils/github.ts"],"names":[],"mappings":";;;AAAA,iDAA8D;AAC9D,+BAAiC;AAEjC,MAAM,QAAQ,GAAG,IAAA,gBAAS,EAAC,wBAAU,CAAC,CAAC;AAEvC;;GAEG;AACI,MAAM,iBAAiB,GAAG,KAAK,IAAsB,EAAE;IAC5D,IAAI,CAAC;QACH,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAPW,QAAA,iBAAiB,qBAO5B;AAEF;;;;GAIG;AACI,MAAM,uBA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,IAAI,IAAI,YAAY,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAC/D,CACN,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA3BW,QAAA,SAAS,aA2BpB"}
|
|
@@ -3539,6 +3539,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
3539
3539
|
__exportStar(__nccwpck_require__(85385), exports);
|
|
3540
3540
|
__exportStar(__nccwpck_require__(88393), exports);
|
|
3541
3541
|
__exportStar(__nccwpck_require__(30966), exports);
|
|
3542
|
+
__exportStar(__nccwpck_require__(88288), exports);
|
|
3542
3543
|
//# sourceMappingURL=index.js.map
|
|
3543
3544
|
|
|
3544
3545
|
/***/ }),
|
|
@@ -710,8 +710,48 @@ const checkGithub = async (report, config) => {
|
|
|
710
710
|
report.ok(`repo level: all ${repoLevelReferenced.length} referenced secrets/variables present`);
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
|
+
await checkGithubMergeGating(report, repo);
|
|
713
714
|
};
|
|
714
715
|
exports.checkGithub = checkGithub;
|
|
716
|
+
/**
|
|
717
|
+
* verifies the merge gating `project setup` configures: auto-merge
|
|
718
|
+
* enabled and the generated `catladder ✅` aggregate check required on
|
|
719
|
+
* the default branch. Without it a PR is mergeable while its checks
|
|
720
|
+
* are still running — gitlab ships this behavior built-in, github
|
|
721
|
+
* silently does not.
|
|
722
|
+
*/
|
|
723
|
+
const checkGithubMergeGating = async (report, repo) => {
|
|
724
|
+
var _a, _b;
|
|
725
|
+
let repoInfo;
|
|
726
|
+
try {
|
|
727
|
+
repoInfo = await (0, github_1.ghApiJson)("GET", `repos/${repo}`);
|
|
728
|
+
}
|
|
729
|
+
catch (e) {
|
|
730
|
+
report.warn(`could not read repo settings of ${repo} (${e.message})`);
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
if (repoInfo.allow_auto_merge) {
|
|
734
|
+
report.ok("auto-merge enabled");
|
|
735
|
+
}
|
|
736
|
+
else {
|
|
737
|
+
report.fail("auto-merge disabled — the merge-when-pipeline-succeeds button cannot appear", "run: catladder project setup");
|
|
738
|
+
}
|
|
739
|
+
const branch = repoInfo.default_branch;
|
|
740
|
+
const protection = await (0, github_1.ghApiJson)("GET", `repos/${repo}/branches/${branch}/protection`).catch(() => null);
|
|
741
|
+
const checks = (_b = (_a = protection === null || protection === void 0 ? void 0 : protection.required_status_checks) === null || _a === void 0 ? void 0 : _a.checks) !== null && _b !== void 0 ? _b : [];
|
|
742
|
+
if (checks.some((c) => c.context === pipeline_1.AGGREGATE_CHECK_JOB_NAME)) {
|
|
743
|
+
report.ok(`'${pipeline_1.AGGREGATE_CHECK_JOB_NAME}' required on ${branch}`);
|
|
744
|
+
}
|
|
745
|
+
else {
|
|
746
|
+
report.fail(`'${pipeline_1.AGGREGATE_CHECK_JOB_NAME}' is not a required check on ${branch} — PRs can merge while the pipeline is red or still running`, "run: catladder project setup");
|
|
747
|
+
}
|
|
748
|
+
const stale = checks.filter((c) => c.context !== pipeline_1.AGGREGATE_CHECK_JOB_NAME);
|
|
749
|
+
if (stale.length > 0) {
|
|
750
|
+
report.warn(`${branch} requires ${stale.length} additional named check(s) (${stale
|
|
751
|
+
.map((c) => c.context)
|
|
752
|
+
.join(", ")}) — job names change with components; prefer only '${pipeline_1.AGGREGATE_CHECK_JOB_NAME}'`);
|
|
753
|
+
}
|
|
754
|
+
};
|
|
715
755
|
//# sourceMappingURL=checkGithub.js.map
|
|
716
756
|
|
|
717
757
|
/***/ }),
|
|
@@ -976,6 +1016,7 @@ const setupAccessTokens_1 = __nccwpck_require__(48907);
|
|
|
976
1016
|
const setupContext_1 = __nccwpck_require__(18120);
|
|
977
1017
|
const setupTopic_1 = __nccwpck_require__(34612);
|
|
978
1018
|
const setupAgents_1 = __nccwpck_require__(7873);
|
|
1019
|
+
const setupGithub_1 = __nccwpck_require__(40148);
|
|
979
1020
|
const logSection_1 = __nccwpck_require__(62213);
|
|
980
1021
|
const ensureGcloudProjectNumbers_1 = __nccwpck_require__(28897);
|
|
981
1022
|
const setupProject = async (instance, onlyComponents) => {
|
|
@@ -995,16 +1036,24 @@ const setupProject = async (instance, onlyComponents) => {
|
|
|
995
1036
|
allContext.forEach((context) => {
|
|
996
1037
|
instance.log(` - ${context.name}:${context.env}`);
|
|
997
1038
|
});
|
|
1039
|
+
const enabledPipelines = config ? (0, pipeline_1.getEnabledPipelineTypes)(config) : [];
|
|
998
1040
|
await (0, logSection_1.logSection)(instance, "base setup", async () => {
|
|
999
|
-
|
|
1041
|
+
// gitlab-specific provisioning (access token, agent webhooks) —
|
|
1042
|
+
// meaningless (and failing) on a github-only project
|
|
1043
|
+
if (enabledPipelines.includes("gitlab")) {
|
|
1044
|
+
await (0, setupAccessTokens_1.setupAccessTokens)(instance);
|
|
1045
|
+
await (0, setupAgents_1.setupAgents)(instance);
|
|
1046
|
+
}
|
|
1000
1047
|
await (0, setupTopic_1.setupTopic)(instance);
|
|
1001
|
-
|
|
1048
|
+
if (config) {
|
|
1049
|
+
await (0, setupGithub_1.setupGithub)(instance, config);
|
|
1050
|
+
}
|
|
1002
1051
|
});
|
|
1003
1052
|
for (const context of allContext) {
|
|
1004
1053
|
await (0, setupContext_1.setupContext)(instance, context);
|
|
1005
1054
|
}
|
|
1006
1055
|
instance.log("");
|
|
1007
|
-
instance.log("gitlab is ready!
|
|
1056
|
+
instance.log(`${enabledPipelines.join(" + ") || "gitlab"} is ready! 🥂`);
|
|
1008
1057
|
instance.log("\n");
|
|
1009
1058
|
instance.log("do not forget to make sure that:");
|
|
1010
1059
|
[
|
|
@@ -1370,6 +1419,105 @@ exports.setupContext = setupContext;
|
|
|
1370
1419
|
|
|
1371
1420
|
/***/ }),
|
|
1372
1421
|
|
|
1422
|
+
/***/ 40148:
|
|
1423
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
1424
|
+
|
|
1425
|
+
"use strict";
|
|
1426
|
+
|
|
1427
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1428
|
+
exports.setupGithub = void 0;
|
|
1429
|
+
const pipeline_1 = __nccwpck_require__(51082);
|
|
1430
|
+
const commandSecretsSyncGithub_1 = __nccwpck_require__(42462);
|
|
1431
|
+
const github_1 = __nccwpck_require__(26928);
|
|
1432
|
+
/**
|
|
1433
|
+
* configures github merge gating — the sane default gitlab ships
|
|
1434
|
+
* built-in and a fresh github repository lacks entirely: without it a
|
|
1435
|
+
* PR is mergeable the moment it opens, checks still running, and the
|
|
1436
|
+
* auto-merge button never appears.
|
|
1437
|
+
*
|
|
1438
|
+
* - repo settings: allow auto-merge, delete merged head branches
|
|
1439
|
+
* - branch protection on the default branch: require the generated
|
|
1440
|
+
* `catladder ✅` aggregate check (the one stable context — individual
|
|
1441
|
+
* job names change with every component add/rename)
|
|
1442
|
+
*
|
|
1443
|
+
* Deliberately non-destructive: existing protection settings
|
|
1444
|
+
* (enforce-admins, required reviews, restrictions, strictness) are
|
|
1445
|
+
* preserved; the aggregate context is merged into the required checks
|
|
1446
|
+
* rather than replacing them. Admins can still bypass per PR — this is
|
|
1447
|
+
* a default, not a cage.
|
|
1448
|
+
*/
|
|
1449
|
+
const setupGithub = async (instance, config) => {
|
|
1450
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1451
|
+
if (!(0, pipeline_1.getEnabledPipelineTypes)(config).includes("github")) {
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
if (!(await (0, github_1.isGhAuthenticated)())) {
|
|
1455
|
+
instance.log("⚠️ github cli (gh) not authenticated — skipping github merge-gating setup (run: gh auth login)");
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
const repo = await (0, commandSecretsSyncGithub_1.getConfiguredGithubRepo)();
|
|
1459
|
+
if (!repo) {
|
|
1460
|
+
instance.log(`⚠️ no github repository found on the '${(0, pipeline_1.getPipelineGitRemote)(config, "github")}' remote — skipping github merge-gating setup`);
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
const repoInfo = await (0, github_1.ghApiJson)("GET", `repos/${repo}`);
|
|
1464
|
+
if (!repoInfo.allow_auto_merge || !repoInfo.delete_branch_on_merge) {
|
|
1465
|
+
await (0, github_1.ghApiJson)("PATCH", `repos/${repo}`, {
|
|
1466
|
+
allow_auto_merge: true,
|
|
1467
|
+
delete_branch_on_merge: true,
|
|
1468
|
+
});
|
|
1469
|
+
instance.log("✅ auto-merge + delete-merged-branches enabled");
|
|
1470
|
+
}
|
|
1471
|
+
else {
|
|
1472
|
+
instance.log("✅ auto-merge already enabled");
|
|
1473
|
+
}
|
|
1474
|
+
const branch = repoInfo.default_branch;
|
|
1475
|
+
const protection = await (0, github_1.ghApiJson)("GET", `repos/${repo}/branches/${branch}/protection`).catch(() => null); // 404: branch not protected yet
|
|
1476
|
+
const existingChecks = (_b = (_a = protection === null || protection === void 0 ? void 0 : protection.required_status_checks) === null || _a === void 0 ? void 0 : _a.checks) !== null && _b !== void 0 ? _b : [];
|
|
1477
|
+
if (existingChecks.some((c) => c.context === pipeline_1.AGGREGATE_CHECK_JOB_NAME)) {
|
|
1478
|
+
instance.log(`✅ '${pipeline_1.AGGREGATE_CHECK_JOB_NAME}' already required on ${branch}`);
|
|
1479
|
+
return;
|
|
1480
|
+
}
|
|
1481
|
+
// merge into whatever protection exists; PUT replaces the whole rule,
|
|
1482
|
+
// so every preserved setting must be carried over explicitly
|
|
1483
|
+
await (0, github_1.ghApiJson)("PUT", `repos/${repo}/branches/${branch}/protection`, {
|
|
1484
|
+
required_status_checks: {
|
|
1485
|
+
strict: (_d = (_c = protection === null || protection === void 0 ? void 0 : protection.required_status_checks) === null || _c === void 0 ? void 0 : _c.strict) !== null && _d !== void 0 ? _d : false,
|
|
1486
|
+
checks: [
|
|
1487
|
+
...existingChecks.map(({ context, app_id }) => ({
|
|
1488
|
+
context,
|
|
1489
|
+
...(app_id !== undefined ? { app_id } : {}),
|
|
1490
|
+
})),
|
|
1491
|
+
{ context: pipeline_1.AGGREGATE_CHECK_JOB_NAME },
|
|
1492
|
+
],
|
|
1493
|
+
},
|
|
1494
|
+
enforce_admins: (_f = (_e = protection === null || protection === void 0 ? void 0 : protection.enforce_admins) === null || _e === void 0 ? void 0 : _e.enabled) !== null && _f !== void 0 ? _f : false,
|
|
1495
|
+
required_pull_request_reviews: (protection === null || protection === void 0 ? void 0 : protection.required_pull_request_reviews)
|
|
1496
|
+
? {
|
|
1497
|
+
required_approving_review_count: (_g = protection.required_pull_request_reviews
|
|
1498
|
+
.required_approving_review_count) !== null && _g !== void 0 ? _g : 0,
|
|
1499
|
+
dismiss_stale_reviews: (_h = protection.required_pull_request_reviews.dismiss_stale_reviews) !== null && _h !== void 0 ? _h : false,
|
|
1500
|
+
require_code_owner_reviews: (_j = protection.required_pull_request_reviews
|
|
1501
|
+
.require_code_owner_reviews) !== null && _j !== void 0 ? _j : false,
|
|
1502
|
+
}
|
|
1503
|
+
: null,
|
|
1504
|
+
restrictions: (protection === null || protection === void 0 ? void 0 : protection.restrictions)
|
|
1505
|
+
? {
|
|
1506
|
+
users: protection.restrictions.users.map((u) => u.login),
|
|
1507
|
+
teams: protection.restrictions.teams.map((t) => t.slug),
|
|
1508
|
+
apps: protection.restrictions.apps.map((a) => a.slug),
|
|
1509
|
+
}
|
|
1510
|
+
: null,
|
|
1511
|
+
allow_force_pushes: (_l = (_k = protection === null || protection === void 0 ? void 0 : protection.allow_force_pushes) === null || _k === void 0 ? void 0 : _k.enabled) !== null && _l !== void 0 ? _l : false,
|
|
1512
|
+
allow_deletions: (_o = (_m = protection === null || protection === void 0 ? void 0 : protection.allow_deletions) === null || _m === void 0 ? void 0 : _m.enabled) !== null && _o !== void 0 ? _o : false,
|
|
1513
|
+
});
|
|
1514
|
+
instance.log(`✅ branch protection on ${branch}: '${pipeline_1.AGGREGATE_CHECK_JOB_NAME}' required (merges now wait for the pipeline)`);
|
|
1515
|
+
};
|
|
1516
|
+
exports.setupGithub = setupGithub;
|
|
1517
|
+
//# sourceMappingURL=setupGithub.js.map
|
|
1518
|
+
|
|
1519
|
+
/***/ }),
|
|
1520
|
+
|
|
1373
1521
|
/***/ 347:
|
|
1374
1522
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
1375
1523
|
|
|
@@ -6374,7 +6522,7 @@ exports["default"] = async () => {
|
|
|
6374
6522
|
"use strict";
|
|
6375
6523
|
|
|
6376
6524
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6377
|
-
exports.ensureGithubEnvironment = exports.setGithubVariable = exports.setGithubSecret = exports.listGithubVariableNames = exports.listGithubSecretNames = exports.listGithubEnvironments = exports.getGithubRepoFromRemote = exports.isGhAuthenticated = void 0;
|
|
6525
|
+
exports.ghApiJson = exports.ensureGithubEnvironment = exports.setGithubVariable = exports.setGithubSecret = exports.listGithubVariableNames = exports.listGithubSecretNames = exports.listGithubEnvironments = exports.getGithubRepoFromRemote = exports.isGhAuthenticated = void 0;
|
|
6378
6526
|
const child_process_1 = __nccwpck_require__(35317);
|
|
6379
6527
|
const util_1 = __nccwpck_require__(39023);
|
|
6380
6528
|
const execFile = (0, util_1.promisify)(child_process_1.execFile);
|
|
@@ -6485,6 +6633,29 @@ const ensureGithubEnvironment = async (repo, environment) => new Promise((resolv
|
|
|
6485
6633
|
: reject(new Error(`creating github environment ${environment} failed: ${stderr.trim()}`)));
|
|
6486
6634
|
});
|
|
6487
6635
|
exports.ensureGithubEnvironment = ensureGithubEnvironment;
|
|
6636
|
+
/** runs `gh api` with an optional JSON body and returns the parsed response */
|
|
6637
|
+
const ghApiJson = async (method, path, body) => {
|
|
6638
|
+
var _a, _b, _c, _d;
|
|
6639
|
+
const args = ["api", "-X", method, path];
|
|
6640
|
+
const child = (0, child_process_1.spawn)("gh", [...args, ...(body ? ["--input", "-"] : [])], {
|
|
6641
|
+
stdio: [body ? "pipe" : "ignore", "pipe", "pipe"],
|
|
6642
|
+
});
|
|
6643
|
+
let stdout = "";
|
|
6644
|
+
let stderr = "";
|
|
6645
|
+
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on("data", (data) => (stdout += data));
|
|
6646
|
+
(_b = child.stderr) === null || _b === void 0 ? void 0 : _b.on("data", (data) => (stderr += data));
|
|
6647
|
+
if (body) {
|
|
6648
|
+
(_c = child.stdin) === null || _c === void 0 ? void 0 : _c.write(JSON.stringify(body));
|
|
6649
|
+
(_d = child.stdin) === null || _d === void 0 ? void 0 : _d.end();
|
|
6650
|
+
}
|
|
6651
|
+
return new Promise((resolve, reject) => {
|
|
6652
|
+
child.on("error", reject);
|
|
6653
|
+
child.on("close", (code) => code === 0
|
|
6654
|
+
? resolve(stdout ? JSON.parse(stdout) : undefined)
|
|
6655
|
+
: reject(new Error(`gh api ${method} ${path} failed: ${stderr.trim()}`)));
|
|
6656
|
+
});
|
|
6657
|
+
};
|
|
6658
|
+
exports.ghApiJson = ghApiJson;
|
|
6488
6659
|
//# sourceMappingURL=github.js.map
|
|
6489
6660
|
|
|
6490
6661
|
/***/ }),
|
|
@@ -9567,6 +9738,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
9567
9738
|
__exportStar(__nccwpck_require__(85385), exports);
|
|
9568
9739
|
__exportStar(__nccwpck_require__(88393), exports);
|
|
9569
9740
|
__exportStar(__nccwpck_require__(30966), exports);
|
|
9741
|
+
__exportStar(__nccwpck_require__(88288), exports);
|
|
9570
9742
|
//# sourceMappingURL=index.js.map
|
|
9571
9743
|
|
|
9572
9744
|
/***/ }),
|
|
@@ -258,18 +258,15 @@ now-wrong `gitRemote`, regenerate once more, and finish with
|
|
|
258
258
|
- **Set up merge gating — GitHub has none by default.** On GitLab,
|
|
259
259
|
"merge when pipeline succeeds" is built in; on a fresh GitHub repo a
|
|
260
260
|
PR is mergeable the moment it opens, checks still running, and the
|
|
261
|
-
auto-merge button does not even appear.
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
Consider leaving "enforce for administrators" off: this repo's CI is
|
|
271
|
-
generated, so if generation itself ever breaks, the admin bypass is
|
|
272
|
-
what lets the fix merge.
|
|
261
|
+
auto-merge button does not even appear. `yarn catladder project setup`
|
|
262
|
+
configures it: auto-merge + delete-merged-branches on the repo, and a
|
|
263
|
+
branch protection rule on the default branch requiring the generated
|
|
264
|
+
**`catladder ✅`** aggregate check (the one stable context — never
|
|
265
|
+
require individual job names, they change with every component
|
|
266
|
+
add/rename and a stale required name blocks its own PR forever).
|
|
267
|
+
`project doctor` verifies it. Two things stay human choices: "Do not
|
|
268
|
+
allow bypassing" (leave it off — generated CI means a generation bug
|
|
269
|
+
can only be fixed via the admin bypass) and required reviews.
|
|
273
270
|
- Tell the team where the pipeline lives now and how manual actions
|
|
274
271
|
work there (on GitHub, manual jobs are dispatch workflows in the
|
|
275
272
|
Actions sidebar — `🚀 catladder create release`, `▶️ catladder deploy`,
|
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./GithubBackend"), exports);
|
|
18
18
|
__exportStar(require("./ciVariables"), exports);
|
|
19
19
|
__exportStar(require("./scriptFiles"), exports);
|
|
20
|
+
__exportStar(require("./aggregateCheckJob"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/pipeline/src/backends/github/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,gDAA8B;AAC9B,gDAA8B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/pipeline/src/backends/github/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,gDAA8B;AAC9B,gDAA8B;AAC9B,sDAAoC"}
|