@catladder/cli 5.3.0 → 5.3.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/dist/apps/cli/src/release/changesetCheckJob.js +17 -10
- package/dist/apps/cli/src/release/changesetCheckJob.js.map +1 -1
- package/dist/bundles/catci/index.js +1 -1
- package/dist/bundles/catenv/index.js +42 -7
- package/dist/bundles/cli/index.js +42 -7
- package/dist/bundles/skills/catladder-deploys/SKILL.md +8 -1
- package/dist/bundles/skills/catladder-deploys/references/deploy-types.md +1 -1
- package/dist/bundles/skills/catladder-migrate-release-method/SKILL.md +4 -3
- package/dist/bundles/skills/catladder-releases/SKILL.md +12 -7
- package/dist/packages/pipeline/src/backends/gitlab/createGitlabJobs.js +7 -2
- package/dist/packages/pipeline/src/backends/gitlab/createGitlabJobs.js.map +1 -1
- package/dist/packages/pipeline/src/backends/gitlab/gitlabReleaseJobs.js +5 -3
- package/dist/packages/pipeline/src/backends/gitlab/gitlabReleaseJobs.js.map +1 -1
- package/dist/packages/pipeline/src/backends/types.d.ts +6 -2
- package/dist/packages/pipeline/src/customImages/hash.d.ts +4 -0
- package/dist/packages/pipeline/src/customImages/hash.js +3 -0
- package/dist/packages/pipeline/src/customImages/hash.js.map +1 -1
- package/dist/packages/pipeline/src/customImages/jobImagesPlan.d.ts +2 -1
- package/dist/packages/pipeline/src/customImages/jobImagesPlan.js +21 -1
- package/dist/packages/pipeline/src/customImages/jobImagesPlan.js.map +1 -1
- package/dist/packages/pipeline/src/pipeline/generatePipelineFiles.js +1 -1
- package/dist/packages/pipeline/src/pipeline/generatePipelineFiles.js.map +1 -1
- package/dist/packages/pipeline/src/utils/writeFiles.d.ts +2 -1
- package/dist/packages/pipeline/src/utils/writeFiles.js +5 -0
- package/dist/packages/pipeline/src/utils/writeFiles.js.map +1 -1
- package/dist/skills/catladder-deploys/SKILL.md +8 -1
- package/dist/skills/catladder-deploys/references/deploy-types.md +1 -1
- package/dist/skills/catladder-migrate-release-method/SKILL.md +4 -3
- package/dist/skills/catladder-releases/SKILL.md +12 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/release/__tests__/changesetCheckJob.test.ts +68 -0
- package/src/release/changesetCheckJob.ts +18 -10
package/package.json
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { mkdtemp, readFile, rm } from "fs/promises";
|
|
2
|
+
import { tmpdir } from "os";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { CHANGESET_REPORT_FILE, changesetCheckJob } from "../changesetCheckJob";
|
|
6
|
+
|
|
7
|
+
// the merge request's diff against its target branch: the only git
|
|
8
|
+
// output the check parses
|
|
9
|
+
const gitMock = vi.hoisted(() => ({ addedFiles: [] as string[] }));
|
|
10
|
+
|
|
11
|
+
vi.mock("../releaseGit", () => ({
|
|
12
|
+
ensureReleaseHistory: vi.fn(async () => undefined),
|
|
13
|
+
getLastReleaseTag: vi.fn(async () => "v1.2.3"),
|
|
14
|
+
git: vi.fn(async (command: string) =>
|
|
15
|
+
command === "diff" ? gitMock.addedFiles.join("\n") : "",
|
|
16
|
+
),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
vi.mock("../changesetsReleaseJob", () => ({
|
|
20
|
+
readPendingChangesets: vi.fn(async () => []),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
let cwd: string;
|
|
24
|
+
let workDir: string;
|
|
25
|
+
|
|
26
|
+
beforeEach(async () => {
|
|
27
|
+
cwd = process.cwd();
|
|
28
|
+
workDir = await mkdtemp(join(tmpdir(), "changeset-check-"));
|
|
29
|
+
process.chdir(workDir);
|
|
30
|
+
process.exitCode = undefined;
|
|
31
|
+
vi.spyOn(console, "log").mockImplementation(() => undefined);
|
|
32
|
+
vi.stubEnv("GITHUB_ACTIONS", undefined as any);
|
|
33
|
+
vi.stubEnv("GL_TOKEN", undefined as any);
|
|
34
|
+
vi.stubEnv("CI_MERGE_REQUEST_TARGET_BRANCH_NAME", "main");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterEach(async () => {
|
|
38
|
+
process.chdir(cwd);
|
|
39
|
+
process.exitCode = undefined;
|
|
40
|
+
vi.unstubAllEnvs();
|
|
41
|
+
vi.restoreAllMocks();
|
|
42
|
+
await rm(workDir, { recursive: true, force: true });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("changesetCheckJob on gitlab", () => {
|
|
46
|
+
it("exits 0 when the merge request adds no changeset — a failed job would never resolve its exposed report", async () => {
|
|
47
|
+
gitMock.addedFiles = ["src/index.ts"];
|
|
48
|
+
|
|
49
|
+
await changesetCheckJob();
|
|
50
|
+
|
|
51
|
+
expect(process.exitCode).toBeUndefined();
|
|
52
|
+
const report = await readFile(CHANGESET_REPORT_FILE, "utf-8");
|
|
53
|
+
expect(report).toContain("adds no changeset");
|
|
54
|
+
expect(console.log).toHaveBeenCalledWith(
|
|
55
|
+
expect.stringContaining("⚠️ this merge request adds no changeset"),
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("exits 0 and reports the changesets the merge request adds", async () => {
|
|
60
|
+
gitMock.addedFiles = [".changeset/brave-cats.md"];
|
|
61
|
+
|
|
62
|
+
await changesetCheckJob();
|
|
63
|
+
|
|
64
|
+
expect(process.exitCode).toBeUndefined();
|
|
65
|
+
const report = await readFile(CHANGESET_REPORT_FILE, "utf-8");
|
|
66
|
+
expect(report).toContain("adds 1 changeset: `brave-cats.md`");
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* reports which changesets the merge request adds, what is pending and
|
|
5
5
|
* what version merging would release. The report goes to the job log,
|
|
6
6
|
* to `changeset-report.md` (exposed as an artifact on gitlab) and to a
|
|
7
|
-
* sticky MR/PR comment where a token allows it.
|
|
8
|
-
*
|
|
7
|
+
* sticky MR/PR comment where a token allows it. Always exits 0: a
|
|
8
|
+
* missing changeset is a warning carried by the report, not a job
|
|
9
|
+
* failure (see the end of {@link changesetCheckJob}).
|
|
9
10
|
*/
|
|
10
11
|
import { existsSync } from "fs";
|
|
11
12
|
import { writeFile } from "fs/promises";
|
|
@@ -203,11 +204,17 @@ export const changesetCheckJob = async () => {
|
|
|
203
204
|
return;
|
|
204
205
|
}
|
|
205
206
|
if (!result.addsChangeset) {
|
|
207
|
+
// the job stays green on both platforms — the report, the log and
|
|
208
|
+
// the sticky comment carry the "no changeset" warning instead:
|
|
209
|
+
// - github has no "warning" job state: exiting non-zero would show
|
|
210
|
+
// the job as failed (a red ❌ and "exit code 1"), which reads
|
|
211
|
+
// like something broke.
|
|
212
|
+
// - gitlab only resolves the exposed artifact (the MR widget's
|
|
213
|
+
// "changeset report" link) of a SUCCESSFUL job: for a failed
|
|
214
|
+
// allow_failure job `exposed_artifacts.json` answers 204 forever
|
|
215
|
+
// and the widget spins on "Loading artifacts" — exactly on the
|
|
216
|
+
// MRs that need the report.
|
|
206
217
|
if (onGithub()) {
|
|
207
|
-
// github has no "warning" job state: exiting non-zero would show
|
|
208
|
-
// the job as failed (a red ❌ and "exit code 1"), which reads like
|
|
209
|
-
// something broke. A warning annotation plus the step summary and
|
|
210
|
-
// the sticky PR comment carry the signal instead.
|
|
211
218
|
console.log(
|
|
212
219
|
"::warning title=No changeset::this pull request adds no changeset — " +
|
|
213
220
|
"if the change is user-facing, add one so it appears in the next release's changelog",
|
|
@@ -215,10 +222,11 @@ export const changesetCheckJob = async () => {
|
|
|
215
222
|
appendStepSummary(
|
|
216
223
|
result.markdown.replace(`${CHANGESET_CHECK_MARKER}\n`, ""),
|
|
217
224
|
);
|
|
218
|
-
|
|
225
|
+
} else {
|
|
226
|
+
console.log(
|
|
227
|
+
"⚠️ this merge request adds no changeset — if the change is user-facing, " +
|
|
228
|
+
"add one so it appears in the next release's changelog (see the changeset report)",
|
|
229
|
+
);
|
|
219
230
|
}
|
|
220
|
-
// gitlab: exit 1 turns the (allow_failure) job yellow so reviewers
|
|
221
|
-
// notice
|
|
222
|
-
process.exitCode = 1;
|
|
223
231
|
}
|
|
224
232
|
};
|