@catladder/pipeline 1.162.0 → 1.163.1

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.
Files changed (80) hide show
  1. package/README.md +15 -1
  2. package/dist/build/types.d.ts +6 -0
  3. package/dist/bundles/catladder-gitlab/index.js +2 -2
  4. package/dist/constants.js +1 -1
  5. package/dist/pipeline/generatePipelineFiles.d.ts +38 -0
  6. package/dist/pipeline/generatePipelineFiles.js +44 -23
  7. package/dist/tsconfig.tsbuildinfo +1 -1
  8. package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +1341 -0
  9. package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +1325 -0
  10. package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +1341 -0
  11. package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +1393 -0
  12. package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +1341 -0
  13. package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +1352 -0
  14. package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +1341 -0
  15. package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +1341 -0
  16. package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +1385 -0
  17. package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +1233 -4
  18. package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +1349 -4
  19. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +2825 -0
  20. package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +2572 -0
  21. package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +1349 -0
  22. package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +1196 -0
  23. package/examples/__snapshots__/custom-build-job.test.ts.snap +1085 -0
  24. package/examples/__snapshots__/custom-deploy.test.ts.snap +1103 -0
  25. package/examples/__snapshots__/custom-envs.test.ts.snap +709 -0
  26. package/examples/__snapshots__/custom-sbom-java.test.ts.snap +1093 -0
  27. package/examples/__snapshots__/git-submodule.test.ts.snap +1342 -0
  28. package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +1778 -0
  29. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.test.ts.snap +1790 -0
  30. package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +1798 -0
  31. package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +3352 -0
  32. package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +1902 -0
  33. package/examples/__snapshots__/local-dot-env.test.ts.snap +1341 -0
  34. package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +1839 -0
  35. package/examples/__snapshots__/multiline-var.test.ts.snap +3376 -0
  36. package/examples/__snapshots__/native-app.test.ts.snap +2149 -0
  37. package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +1341 -0
  38. package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +1349 -0
  39. package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +1470 -0
  40. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +1275 -0
  41. package/examples/__utils__/helpers.ts +14 -1
  42. package/examples/cloud-run-memory-limit.test.ts +9 -1
  43. package/examples/cloud-run-meteor-with-worker.test.ts +9 -1
  44. package/examples/cloud-run-no-cpu-throttling.test.ts +9 -1
  45. package/examples/cloud-run-no-service.test.ts +9 -1
  46. package/examples/cloud-run-non-public.test.ts +9 -1
  47. package/examples/cloud-run-post-stop-job.test.ts +9 -1
  48. package/examples/cloud-run-service-gen2.test.ts +9 -1
  49. package/examples/cloud-run-service-increase-timout.test.ts +9 -1
  50. package/examples/cloud-run-service-with-volumes.test.ts +9 -1
  51. package/examples/cloud-run-storybook.test.ts +9 -1
  52. package/examples/cloud-run-storybook.ts +9 -1
  53. package/examples/cloud-run-with-ngnix.test.ts +9 -1
  54. package/examples/cloud-run-with-ngnix.ts +5 -1
  55. package/examples/cloud-run-with-sql-reuse-db.test.ts +9 -1
  56. package/examples/cloud-run-with-sql.test.ts +9 -1
  57. package/examples/cloud-run-with-worker.test.ts +9 -1
  58. package/examples/custom-build-job-with-tests.test.ts +9 -1
  59. package/examples/custom-build-job.test.ts +9 -1
  60. package/examples/custom-deploy.test.ts +9 -1
  61. package/examples/custom-envs.test.ts +9 -1
  62. package/examples/custom-sbom-java.test.ts +9 -1
  63. package/examples/git-submodule.test.ts +9 -1
  64. package/examples/kubernetes-application-customization.test.ts +9 -1
  65. package/examples/kubernetes-with-cloud-sql-legacy.test.ts +9 -1
  66. package/examples/kubernetes-with-cloud-sql.test.ts +9 -1
  67. package/examples/kubernetes-with-jobs.test.ts +9 -1
  68. package/examples/kubernetes-with-mongodb.test.ts +9 -1
  69. package/examples/local-dot-env.test.ts +9 -1
  70. package/examples/meteor-kubernetes.test.ts +9 -1
  71. package/examples/multiline-var.test.ts +9 -1
  72. package/examples/native-app.test.ts +9 -1
  73. package/examples/node-build-with-custom-image.test.ts +9 -1
  74. package/examples/node-build-with-docker-additions.test.ts +9 -1
  75. package/examples/rails-k8s-with-worker.test.ts +9 -1
  76. package/examples/wait-for-other-deploy.test.ts +9 -1
  77. package/package.json +4 -3
  78. package/scripts/generate-examples-test.ts +7 -5
  79. package/src/build/types.ts +6 -0
  80. package/src/pipeline/generatePipelineFiles.ts +61 -36
@@ -1,10 +1,18 @@
1
- import { createAllPipelines } from "./__utils__/helpers";
1
+ import {
2
+ createAllPipelines,
3
+ createYamlLocalPipeline,
4
+ } from "./__utils__/helpers";
2
5
  import config from "./node-build-with-custom-image";
3
6
 
4
7
  /**
5
8
  * This test is auto-generated.
6
9
  * Modifications will be overwritten on every `yarn test` run!
7
10
  */
11
+
8
12
  it("matches snapshot for node-build-with-custom-image", async () => {
9
13
  expect(await createAllPipelines(config)).toMatchSnapshot();
10
14
  });
15
+
16
+ it("matches snapshot for cloud-run-memory-limit local pipeline YAML", async () => {
17
+ expect(await createYamlLocalPipeline(config)).toMatchSnapshot();
18
+ });
@@ -1,10 +1,18 @@
1
- import { createAllPipelines } from "./__utils__/helpers";
1
+ import {
2
+ createAllPipelines,
3
+ createYamlLocalPipeline,
4
+ } from "./__utils__/helpers";
2
5
  import config from "./node-build-with-docker-additions";
3
6
 
4
7
  /**
5
8
  * This test is auto-generated.
6
9
  * Modifications will be overwritten on every `yarn test` run!
7
10
  */
11
+
8
12
  it("matches snapshot for node-build-with-docker-additions", async () => {
9
13
  expect(await createAllPipelines(config)).toMatchSnapshot();
10
14
  });
15
+
16
+ it("matches snapshot for cloud-run-memory-limit local pipeline YAML", async () => {
17
+ expect(await createYamlLocalPipeline(config)).toMatchSnapshot();
18
+ });
@@ -1,10 +1,18 @@
1
- import { createAllPipelines } from "./__utils__/helpers";
1
+ import {
2
+ createAllPipelines,
3
+ createYamlLocalPipeline,
4
+ } from "./__utils__/helpers";
2
5
  import config from "./rails-k8s-with-worker";
3
6
 
4
7
  /**
5
8
  * This test is auto-generated.
6
9
  * Modifications will be overwritten on every `yarn test` run!
7
10
  */
11
+
8
12
  it("matches snapshot for rails-k8s-with-worker", async () => {
9
13
  expect(await createAllPipelines(config)).toMatchSnapshot();
10
14
  });
15
+
16
+ it("matches snapshot for cloud-run-memory-limit local pipeline YAML", async () => {
17
+ expect(await createYamlLocalPipeline(config)).toMatchSnapshot();
18
+ });
@@ -1,10 +1,18 @@
1
- import { createAllPipelines } from "./__utils__/helpers";
1
+ import {
2
+ createAllPipelines,
3
+ createYamlLocalPipeline,
4
+ } from "./__utils__/helpers";
2
5
  import config from "./wait-for-other-deploy";
3
6
 
4
7
  /**
5
8
  * This test is auto-generated.
6
9
  * Modifications will be overwritten on every `yarn test` run!
7
10
  */
11
+
8
12
  it("matches snapshot for wait-for-other-deploy", async () => {
9
13
  expect(await createAllPipelines(config)).toMatchSnapshot();
10
14
  });
15
+
16
+ it("matches snapshot for cloud-run-memory-limit local pipeline YAML", async () => {
17
+ expect(await createYamlLocalPipeline(config)).toMatchSnapshot();
18
+ });
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@catladder/pipeline",
3
- "description": "CI/CD and Devops-Workflow",
4
- "homepage": "https://git.panter.ch/catladder/catladder/#readme",
3
+ "description": "Panter workflow for cloud CI/CD and DevOps",
4
+ "homepage": "https://catladder.git.panter.biz/catladder/docs",
5
5
  "bugs": "https://git.panter.ch/catladder/catladder/issues",
6
+ "readme": "https://git.panter.ch/catladder/catladder/-/blob/main/pipeline/README.md",
6
7
  "repository": {
7
8
  "type": "git",
8
9
  "url": "git+https://git.panter.ch/catladder/catladder.git",
@@ -52,7 +53,7 @@
52
53
  }
53
54
  ],
54
55
  "license": "MIT",
55
- "version": "1.162.0",
56
+ "version": "1.163.1",
56
57
  "scripts": {
57
58
  "build:tsc": "yarn tsc",
58
59
  "build": "yarn build:compile && yarn build:inline-variables && yarn build:bundle",
@@ -63,16 +63,18 @@ async function main() {
63
63
  exampleFiles.map(async (exampleFile) => {
64
64
  const kebabName = basename(exampleFile, ".ts");
65
65
  const testFileContent = [
66
- `import { createAllPipelines } from "./__utils__/helpers";`,
66
+ `import { createAllPipelines, createYamlLocalPipeline } from "./__utils__/helpers";`,
67
67
  `import config from "./${kebabName}";`,
68
- ``,
69
- `/**`,
68
+ `\n/**`,
70
69
  ` * This test is auto-generated.`,
71
70
  ` * Modifications will be overwritten on every \`yarn test\` run!`,
72
- ` */`,
71
+ ` */\n`,
73
72
  `it("matches snapshot for ${kebabName}", async () => {`,
74
73
  ` expect(await createAllPipelines(config)).toMatchSnapshot();`,
75
- `});`,
74
+ `});\n`,
75
+ `it("matches snapshot for cloud-run-memory-limit local pipeline YAML", async () => {`,
76
+ ` expect(await createYamlLocalPipeline(config)).toMatchSnapshot();`,
77
+ `});\n`,
76
78
  ].join("\n");
77
79
  const formattedTest = await format(testFileContent, {
78
80
  parser: "typescript",
@@ -114,6 +114,9 @@ export type BuildConfigNode = {
114
114
  } & BuildConfigNodeBase;
115
115
 
116
116
  export type BuildConfigNodeStatic = BuildConfigNodeBase & {
117
+ /**
118
+ * @deprecated use type: "node" and docker: { type: "nginx" } instead
119
+ */
117
120
  type: "node-static";
118
121
  startCommand?: never;
119
122
  docker?: Omit<BuildConfigDockerBuiltInNgninx, "type"> | BuildConfigDocker;
@@ -271,6 +274,9 @@ export type BuildConfigRails = BuildConfigBase & {
271
274
  };
272
275
 
273
276
  export type BuildConfigStorybook = BuildConfigNodeBase & {
277
+ /**
278
+ * @deprecated use type: "node" and docker: { type: "nginx" } instead
279
+ */
274
280
  type: "storybook";
275
281
  startCommand?: never;
276
282
  };
@@ -4,48 +4,73 @@ import { createChildPipeline } from "./createChildPipeline";
4
4
  import { createMainPipeline } from "./createMainPipeline";
5
5
  import { getPipelineTriggerForGitlabChildPipeline } from "./gitlab/getPipelineTriggerForGitlabChildPipeline";
6
6
  import { sortGitLabJobDefProps } from "./gitlab/sortGitLabJobDefProps";
7
+
8
+ export async function generateChildPipelineContent<T extends PipelineType>(
9
+ config: Config,
10
+ pipelineType: T,
11
+ ) {
12
+ const trigger = getPipelineTriggerForGitlabChildPipeline();
13
+ const { jobs, image, stages, variables, workflow, ...pipelineRest } =
14
+ await createChildPipeline(pipelineType, trigger, config);
15
+
16
+ const jobsWithSortedProps = Object.fromEntries(
17
+ Object.entries(jobs).map(([jobName, job]) => [
18
+ jobName,
19
+ sortGitLabJobDefProps(job),
20
+ ]),
21
+ );
22
+
23
+ return {
24
+ image,
25
+ stages,
26
+ variables,
27
+ workflow,
28
+ ...pipelineRest,
29
+ // jobs need to be spread into main YAML, because GitLab pipeline YAML has no jobs key - jobs are top level with their key as their name
30
+ ...jobsWithSortedProps,
31
+ };
32
+ }
33
+
34
+ export async function generateLocalPipelineContent<T extends PipelineType>(
35
+ config: Config,
36
+ pipelineType: T,
37
+ ) {
38
+ const { jobs, image, stages, variables, workflow, ...pipelineRest } =
39
+ await createMainPipeline(pipelineType, config);
40
+
41
+ const jobsWithSortedProps = Object.fromEntries(
42
+ Object.entries(jobs).map(([jobName, job]) => [
43
+ jobName,
44
+ sortGitLabJobDefProps(job),
45
+ ]),
46
+ );
47
+
48
+ return {
49
+ image,
50
+ stages,
51
+ variables,
52
+ workflow,
53
+ ...pipelineRest,
54
+ // jobs need to be spread into main YAML, because GitLab pipeline YAML has no jobs key - jobs are top level with their key as their name
55
+ ...jobsWithSortedProps,
56
+ };
57
+ }
58
+
7
59
  export async function generatePipelineFiles<T extends PipelineType>(
8
60
  config: Config,
9
61
  pipelineType: T,
10
62
  mode: PipelineMode<T>,
11
63
  ) {
12
64
  if (mode === "childpipeline") {
13
- const trigger = getPipelineTriggerForGitlabChildPipeline();
14
-
15
- const { jobs, image, stages, variables, workflow, ...pipelineRest } =
16
- await createChildPipeline(pipelineType, trigger, config);
17
- const jobsWithSortedProps = Object.fromEntries(
18
- Object.entries(jobs).map(([jobName, job]) => [
19
- jobName,
20
- sortGitLabJobDefProps(job),
21
- ]),
22
- );
23
- await writeYamlfile(`__pipeline.yml`, {
24
- image,
25
- stages,
26
- variables,
27
- workflow,
28
- ...pipelineRest,
29
- // jobs need to be spread into main YAML, because GitLab pipeline YAML has no jobs key - jobs are top level with their key as their name
30
- ...jobsWithSortedProps,
31
- });
32
- } else {
33
- const { jobs, image, stages, variables, workflow, ...pipelineRest } =
34
- await createMainPipeline(pipelineType, config);
35
- const jobsWithSortedProps = Object.fromEntries(
36
- Object.entries(jobs).map(([jobName, job]) => [
37
- jobName,
38
- sortGitLabJobDefProps(job),
39
- ]),
65
+ const pipelineContent = await generateChildPipelineContent(
66
+ config,
67
+ pipelineType,
40
68
  );
41
- await writeYamlfile(`.gitlab-ci.yml`, {
42
- image,
43
- stages,
44
- variables,
45
- workflow,
46
- ...pipelineRest,
47
- // jobs need to be spread into main YAML, because GitLab pipeline YAML has no jobs key - jobs are top level with their key as their name
48
- ...jobsWithSortedProps,
49
- });
69
+ return writeYamlfile(`__pipeline.yml`, pipelineContent);
50
70
  }
71
+ const pipelineContent = await generateLocalPipelineContent(
72
+ config,
73
+ pipelineType,
74
+ );
75
+ return writeYamlfile(`.gitlab-ci.yml`, pipelineContent);
51
76
  }