@catladder/pipeline 1.153.0 → 1.154.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/build/artifacts/createBuildJobArtifact.d.ts +3 -0
  2. package/dist/build/artifacts/createBuildJobArtifact.js +97 -0
  3. package/dist/build/base/createAppBuildJob.d.ts +3 -3
  4. package/dist/build/base/createAppBuildJob.js +9 -15
  5. package/dist/build/base/index.d.ts +6 -2
  6. package/dist/build/base/index.js +14 -5
  7. package/dist/build/base/writeDotEnv.js +2 -1
  8. package/dist/build/custom/__tests__/testJob.test.js +1 -1
  9. package/dist/build/custom/buildJob.js +3 -10
  10. package/dist/build/docker.js +3 -3
  11. package/dist/build/index.d.ts +13 -6
  12. package/dist/build/index.js +29 -7
  13. package/dist/build/node/buildJob.d.ts +7 -2
  14. package/dist/build/node/buildJob.js +40 -33
  15. package/dist/build/node/cache.d.ts +2 -2
  16. package/dist/build/node/cache.js +8 -4
  17. package/dist/build/node/index.d.ts +2 -2
  18. package/dist/build/node/meteor.js +3 -6
  19. package/dist/build/node/testJob.d.ts +3 -2
  20. package/dist/build/node/testJob.js +9 -4
  21. package/dist/build/node/yarn.js +1 -1
  22. package/dist/build/rails/build.d.ts +1 -1
  23. package/dist/build/rails/build.js +7 -2
  24. package/dist/build/rails/test.d.ts +1 -1
  25. package/dist/build/rails/test.js +5 -0
  26. package/dist/build/sbom.js +3 -2
  27. package/dist/build/types.d.ts +48 -4
  28. package/dist/build/types.js +7 -1
  29. package/dist/bundles/catladder-gitlab/index.js +2 -2
  30. package/dist/constants.js +1 -1
  31. package/dist/context/createAllComponentsContext.d.ts +12 -0
  32. package/dist/context/createAllComponentsContext.js +159 -0
  33. package/dist/context/createComponentContext.d.ts +1 -5
  34. package/dist/context/createComponentContext.js +82 -20
  35. package/dist/context/createWorkspaceContext.d.ts +16 -0
  36. package/dist/context/createWorkspaceContext.js +173 -0
  37. package/dist/context/getBuildInfoVariables.d.ts +1 -1
  38. package/dist/context/getEnvironmentContext.d.ts +1 -1
  39. package/dist/context/getEnvironmentVariables.d.ts +2 -2
  40. package/dist/context/getEnvironmentVariables.js +5 -4
  41. package/dist/context/getLabels.js +5 -5
  42. package/dist/deploy/base/deploy.d.ts +1 -1
  43. package/dist/deploy/base/deploy.js +18 -5
  44. package/dist/deploy/cloudRun/artifactsRegistry.js +2 -2
  45. package/dist/deploy/cloudRun/createJobs/common.d.ts +4 -4
  46. package/dist/deploy/cloudRun/index.d.ts +2 -2
  47. package/dist/deploy/custom/index.d.ts +2 -2
  48. package/dist/deploy/dockerTag/index.d.ts +2 -2
  49. package/dist/deploy/index.d.ts +7 -7
  50. package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +3 -1
  51. package/dist/deploy/kubernetes/cloudSql/index.js +1 -1
  52. package/dist/deploy/kubernetes/deployJob.js +2 -2
  53. package/dist/deploy/kubernetes/index.d.ts +2 -2
  54. package/dist/deploy/sbom.d.ts +1 -1
  55. package/dist/deploy/sbom.js +4 -3
  56. package/dist/deploy/types/index.d.ts +3 -3
  57. package/dist/pipeline/createAllJobs.d.ts +12 -10
  58. package/dist/pipeline/createAllJobs.js +94 -51
  59. package/dist/pipeline/createJobsForComponent.js +2 -3
  60. package/dist/pipeline/createJobsForWorkspace.d.ts +3 -0
  61. package/dist/pipeline/createJobsForWorkspace.js +12 -0
  62. package/dist/pipeline/createMainPipeline.js +26 -6
  63. package/dist/pipeline/gitlab/createGitlabJobs.d.ts +3 -16
  64. package/dist/pipeline/gitlab/createGitlabJobs.js +191 -73
  65. package/dist/pipeline/packageManager.d.ts +3 -2
  66. package/dist/pipeline/packageManager.js +43 -15
  67. package/dist/tsconfig.tsbuildinfo +1 -1
  68. package/dist/types/config.d.ts +5 -4
  69. package/dist/types/context.d.ts +80 -12
  70. package/dist/types/context.js +10 -1
  71. package/dist/types/environmentContext.d.ts +5 -6
  72. package/dist/types/jobs.d.ts +5 -0
  73. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +8 -8
  74. package/examples/__snapshots__/cloud-run-meteor-with-worker.ts.snap +8 -0
  75. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +8 -8
  76. package/examples/__snapshots__/cloud-run-no-service.ts.snap +8 -8
  77. package/examples/__snapshots__/cloud-run-non-public.ts.snap +8 -8
  78. package/examples/__snapshots__/cloud-run-post-stop-job.ts.snap +8 -8
  79. package/examples/__snapshots__/cloud-run-service-gen2.ts.snap +8 -8
  80. package/examples/__snapshots__/cloud-run-service-increase-timout.ts.snap +8 -8
  81. package/examples/__snapshots__/cloud-run-service-with-volumes.ts.snap +8 -8
  82. package/examples/__snapshots__/cloud-run-storybook.ts.snap +4 -8
  83. package/examples/__snapshots__/cloud-run-with-ngnix.ts.snap +4 -8
  84. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +16 -16
  85. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +589 -1097
  86. package/examples/__snapshots__/cloud-run-with-worker.ts.snap +8 -8
  87. package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +4 -0
  88. package/examples/__snapshots__/custom-build-job.ts.snap +4 -0
  89. package/examples/__snapshots__/custom-deploy.ts.snap +8 -8
  90. package/examples/__snapshots__/custom-envs.ts.snap +18 -12
  91. package/examples/__snapshots__/custom-sbom-java.ts.snap +4 -0
  92. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +8 -8
  93. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +8 -8
  94. package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +8 -8
  95. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +16 -16
  96. package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +8 -8
  97. package/examples/__snapshots__/local-dot-env.ts.snap +8 -8
  98. package/examples/__snapshots__/meteor-kubernetes.ts.snap +8 -0
  99. package/examples/__snapshots__/multiline-var.ts.snap +16 -16
  100. package/examples/__snapshots__/native-app.ts.snap +24 -16
  101. package/examples/__snapshots__/node-build-with-custom-image.ts.snap +8 -8
  102. package/examples/__snapshots__/node-build-with-docker-additions.ts.snap +8 -8
  103. package/examples/__snapshots__/wait-for-other-deploy.ts.snap +16 -16
  104. package/examples/cloud-run-with-sql.ts +9 -2
  105. package/package.json +1 -1
  106. package/src/build/artifacts/createBuildJobArtifact.ts +61 -0
  107. package/src/build/base/createAppBuildJob.ts +26 -22
  108. package/src/build/base/index.ts +31 -4
  109. package/src/build/base/writeDotEnv.ts +6 -2
  110. package/src/build/custom/__tests__/testJob.test.ts +4 -4
  111. package/src/build/custom/buildJob.ts +2 -13
  112. package/src/build/docker.ts +6 -8
  113. package/src/build/index.ts +39 -7
  114. package/src/build/node/buildJob.ts +68 -56
  115. package/src/build/node/cache.ts +17 -8
  116. package/src/build/node/index.ts +4 -2
  117. package/src/build/node/meteor.ts +3 -9
  118. package/src/build/node/testJob.ts +21 -7
  119. package/src/build/node/yarn.ts +2 -2
  120. package/src/build/rails/build.ts +14 -4
  121. package/src/build/rails/test.ts +9 -1
  122. package/src/build/sbom.ts +7 -2
  123. package/src/build/types.ts +68 -4
  124. package/src/context/createAllComponentsContext.ts +31 -0
  125. package/src/context/createComponentContext.ts +59 -20
  126. package/src/context/createWorkspaceContext.ts +56 -0
  127. package/src/context/getBuildInfoVariables.ts +2 -1
  128. package/src/context/getEnvironmentContext.ts +2 -2
  129. package/src/context/getEnvironmentVariables.ts +12 -7
  130. package/src/context/getLabels.ts +3 -3
  131. package/src/deploy/base/deploy.ts +33 -7
  132. package/src/deploy/cloudRun/artifactsRegistry.ts +3 -4
  133. package/src/deploy/cloudRun/createJobs/common.ts +4 -4
  134. package/src/deploy/cloudRun/index.ts +68 -67
  135. package/src/deploy/custom/index.ts +2 -2
  136. package/src/deploy/dockerTag/index.ts +8 -7
  137. package/src/deploy/index.ts +11 -9
  138. package/src/deploy/kubernetes/additionalSecretKeys.ts +3 -1
  139. package/src/deploy/kubernetes/cloudSql/index.ts +1 -1
  140. package/src/deploy/kubernetes/deployJob.ts +2 -2
  141. package/src/deploy/kubernetes/index.ts +42 -41
  142. package/src/deploy/sbom.ts +9 -4
  143. package/src/pipeline/createAllJobs.ts +56 -55
  144. package/src/pipeline/createChildPipeline.ts +1 -0
  145. package/src/pipeline/createJobsForComponent.ts +5 -4
  146. package/src/pipeline/createJobsForWorkspace.ts +12 -0
  147. package/src/pipeline/createMainPipeline.ts +38 -23
  148. package/src/pipeline/gitlab/createGitlabJobs.ts +283 -119
  149. package/src/pipeline/packageManager.ts +25 -9
  150. package/src/types/config.ts +4 -1
  151. package/src/types/context.ts +108 -12
  152. package/src/types/environmentContext.ts +6 -7
  153. package/src/types/jobs.ts +3 -1
@@ -46,11 +46,12 @@ Object.defineProperty(exports, "__esModule", {
46
46
  });
47
47
  exports.createNodeTestJobs = void 0;
48
48
  var runner_1 = require("../../runner");
49
+ var context_1 = require("../../types/context");
49
50
  var utils_1 = require("../../utils");
51
+ var createArtifactsConfig_1 = require("../base/createArtifactsConfig");
50
52
  var cache_1 = require("./cache");
51
53
  var constants_1 = require("./constants");
52
54
  var yarn_1 = require("./yarn");
53
- var createArtifactsConfig_1 = require("../base/createArtifactsConfig");
54
55
  var createNodeTestJobs = function (context) {
55
56
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
56
57
  // don't run tests after release
@@ -58,17 +59,21 @@ var createNodeTestJobs = function (context) {
58
59
  if (context.trigger === "taggedRelease") {
59
60
  return [];
60
61
  }
61
- var buildConfig = context.build.config;
62
+ // if its not a standalone build, we don't need to run tests
63
+ if (context.type === "component" && !(0, context_1.componentContextIsStandaloneBuild)(context)) {
64
+ return [];
65
+ }
62
66
  var defaultImage = (0, runner_1.getRunnerImage)("jobs-default");
63
67
  var base = {
64
- variables: __assign(__assign({
68
+ variables: __assign({
65
69
  APP_PATH: context.build.dir
66
- }, context.environment.jobOnlyVars.build.envVars), (_a = buildConfig.extraVars) !== null && _a !== void 0 ? _a : {}),
70
+ }, context.type === "component" ? __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), (_a = context.build.config.extraVars) !== null && _a !== void 0 ? _a : {}) : {}),
67
71
  runnerVariables: constants_1.NODE_RUNNER_BUILD_VARIABLES,
68
72
  stage: "test",
69
73
  needs: [],
70
74
  envMode: "none"
71
75
  };
76
+ var buildConfig = context.build.config;
72
77
  var yarnInstall = (0, yarn_1.getYarnInstall)(context);
73
78
  var auditJob = buildConfig.audit !== false ? __assign(__assign(__assign({
74
79
  name: "🛡 audit"
@@ -53,7 +53,7 @@ var ensureNodeVersion = function (context) {
53
53
  exports.ensureNodeVersion = ensureNodeVersion;
54
54
  var getYarnInstall = function (context, options) {
55
55
  var _a;
56
- var postInstall = "postInstall" in context.build.config ? context.build.config.postInstall : null;
56
+ var postInstall = context.type !== "workspace" && "postInstall" in context.build.config ? context.build.config.postInstall : null;
57
57
  return __spreadArray(__spreadArray(__spreadArray([], __read((0, exports.ensureNodeVersion)(context)), false), __read((0, gitlab_1.collapseableSection)("yarninstall", "Yarn install")([getYarnInstallCommand(context)])), false), __read(postInstall && !(options === null || options === void 0 ? void 0 : options.noCustomPostInstall) ? (0, gitlab_1.collapseableSection)("postinstall", "Custom post install")((_a = (0, utils_1.ensureArray)(postInstall)) !== null && _a !== void 0 ? _a : []) : []), false);
58
58
  };
59
59
  exports.getYarnInstall = getYarnInstall;
@@ -1,3 +1,3 @@
1
- import type { ComponentContext } from "../..";
1
+ import { type ComponentContext } from "../..";
2
2
  import type { CatladderJob } from "../../types/jobs";
3
3
  export declare const createRailsBuildJobs: (context: ComponentContext) => CatladderJob[];
@@ -45,6 +45,7 @@ Object.defineProperty(exports, "__esModule", {
45
45
  value: true
46
46
  });
47
47
  exports.createRailsBuildJobs = void 0;
48
+ var __1 = require("../..");
48
49
  var base_1 = require("../base");
49
50
  var docker_1 = require("../docker");
50
51
  var types_1 = require("../types");
@@ -55,8 +56,12 @@ var createRailsBuildJobs = function (context) {
55
56
  // should not happen
56
57
  throw new Error("build type is not rails");
57
58
  }
59
+ // if its not a standalone build, we don't need to run tests
60
+ if (!(0, __1.componentContextIsStandaloneBuild)(context)) {
61
+ throw new Error("workspace builds are not supported for rails apps");
62
+ }
58
63
  if ((0, docker_1.hasDockerfile)(context)) {
59
- return (0, base_1.createBuildJobs)(context, {
64
+ return (0, base_1.createComponentBuildJobs)(context, {
60
65
  appBuild: undefined,
61
66
  dockerBuild: {
62
67
  script: (0, docker_1.getDockerBuildDefaultScript)(context),
@@ -71,7 +76,7 @@ var createRailsBuildJobs = function (context) {
71
76
  v = _b[1];
72
77
  return "--env '".concat(k).concat(v ? "=".concat(v) : "", "'");
73
78
  }).join(" ");
74
- return (0, base_1.createBuildJobs)(context, {
79
+ return (0, base_1.createComponentBuildJobs)(context, {
75
80
  appBuild: undefined,
76
81
  dockerBuild: {
77
82
  variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), context.build.config.extraVars),
@@ -1,3 +1,3 @@
1
- import type { ComponentContext } from "../..";
1
+ import { type ComponentContext } from "../..";
2
2
  import type { CatladderJob } from "../../types/jobs";
3
3
  export declare const createRailsTestJobs: (context: ComponentContext) => CatladderJob[];
@@ -45,6 +45,7 @@ Object.defineProperty(exports, "__esModule", {
45
45
  value: true
46
46
  });
47
47
  exports.createRailsTestJobs = void 0;
48
+ var __1 = require("../..");
48
49
  var utils_1 = require("../../utils");
49
50
  var createRailsTestJobs = function (context) {
50
51
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
@@ -53,6 +54,10 @@ var createRailsTestJobs = function (context) {
53
54
  if (context.trigger === "taggedRelease") {
54
55
  return [];
55
56
  }
57
+ // if its not a standalone build, we don't need to run tests
58
+ if (!(0, __1.componentContextIsStandaloneBuild)(context)) {
59
+ return [];
60
+ }
56
61
  var buildConfig = context.build.config;
57
62
  var base = {
58
63
  variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), (_a = buildConfig.extraVars) !== null && _a !== void 0 ? _a : {}),
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createSbomBuildJob = exports.SBOM_FILE = exports.SBOM_BUILD_JOB_NAME = void 0;
7
+ var _1 = require(".");
7
8
  var utils_1 = require("../utils");
8
9
  exports.SBOM_BUILD_JOB_NAME = "🧾 sbom";
9
10
  exports.SBOM_FILE = "__sbom.json";
@@ -12,8 +13,8 @@ var createSbomBuildJob = function (context) {
12
13
  var buildConfig = context.build.config;
13
14
  var defaultImage = "aquasec/trivy:0.38.3";
14
15
  var defaultScript = ["trivy fs --quiet --format cyclonedx --output \"".concat(exports.SBOM_FILE, "\" ").concat(context.packageManagerInfo.componentIsInWorkspace ? "." : context.build.dir)];
15
- var image = buildConfig.type === "custom" && buildConfig.sbom !== false ? (_b = (_a = buildConfig.sbom) === null || _a === void 0 ? void 0 : _a.jobImage) !== null && _b !== void 0 ? _b : defaultImage : defaultImage;
16
- var script = buildConfig.type === "custom" && buildConfig.sbom !== false ? (_d = (0, utils_1.ensureArray)((_c = buildConfig.sbom) === null || _c === void 0 ? void 0 : _c.command)) !== null && _d !== void 0 ? _d : defaultScript : defaultScript;
16
+ var image = (0, _1.isStandaloneBuildConfig)(buildConfig) && buildConfig.type === "custom" && buildConfig.sbom !== false ? (_b = (_a = buildConfig.sbom) === null || _a === void 0 ? void 0 : _a.jobImage) !== null && _b !== void 0 ? _b : defaultImage : defaultImage;
17
+ var script = (0, _1.isStandaloneBuildConfig)(buildConfig) && buildConfig.type === "custom" && buildConfig.sbom !== false ? (_d = (0, utils_1.ensureArray)((_c = buildConfig.sbom) === null || _c === void 0 ? void 0 : _c.command)) !== null && _d !== void 0 ? _d : defaultScript : defaultScript;
17
18
  return {
18
19
  name: exports.SBOM_BUILD_JOB_NAME,
19
20
  stage: "build",
@@ -111,6 +111,7 @@ export type BuildConfigMeteor = BuildConfigNodeBase & {
111
111
  installScripts?: boolean;
112
112
  docker?: Omit<BuildConfigDockerBuiltInMeteor, "type"> | BuildConfigDocker;
113
113
  };
114
+ export type BuildConfigNodeLike = BuildConfigNode | BuildConfigNodeStatic | BuildConfigStorybook | BuildConfigMeteor;
114
115
  type BuildConfigDockerWithAdditions = {
115
116
  /**
116
117
  * Custom Dockerfile lines integrated in the generated Dockerfile before the standard build steps.
@@ -217,12 +218,24 @@ export type BuildConfigStorybook = BuildConfigNodeBase & {
217
218
  type: "storybook";
218
219
  startCommand?: never;
219
220
  };
220
- export type BuildConfig = BuildConfigNode | BuildConfigNodeStatic | BuildConfigStorybook | BuildConfigMeteor | BuildConfigCustom | BuildConfigRails;
221
- export type BuildConfigType = BuildConfig["type"];
222
- export type BuildConfigGeneric<T extends BuildConfigType> = Extract<BuildConfig, {
221
+ export type BuildConfigFromWorkspace = {
222
+ from: string;
223
+ docker?: BuildConfigDocker;
224
+ startCommand?: string;
225
+ /**
226
+ * additional paths for artifacts,
227
+ * by default "dist" and ".next" are allways included
228
+ */
229
+ artifactsPaths?: string[];
230
+ };
231
+ export type BuildConfigStandalone = BuildConfigNode | BuildConfigNodeStatic | BuildConfigStorybook | BuildConfigMeteor | BuildConfigCustom | BuildConfigRails;
232
+ export type BuildConfig = BuildConfigFromWorkspace | BuildConfigStandalone;
233
+ export type BuildConfigStandaloneType = BuildConfigStandalone["type"];
234
+ export type BuildConfigGeneric<T extends BuildConfigStandaloneType> = Extract<BuildConfig, {
223
235
  type: T;
224
236
  }>;
225
- export declare const isOfBuildType: <T extends ("node" | "node-static" | "storybook" | "meteor" | "custom" | "rails")[]>(t: BuildConfig, ...types: T) => t is Extract<BuildConfigNode, {
237
+ export declare const isStandaloneBuildConfig: (t: BuildConfig | false) => t is BuildConfigStandalone;
238
+ export declare const isOfBuildType: <T extends ("custom" | "rails" | "node" | "meteor" | "node-static" | "storybook")[]>(t: BuildConfig, ...types: T) => t is Extract<BuildConfigNode, {
226
239
  type: T[number];
227
240
  }> | Extract<BuildConfigNodeStatic, {
228
241
  type: T[number];
@@ -235,4 +248,35 @@ export declare const isOfBuildType: <T extends ("node" | "node-static" | "storyb
235
248
  }> | Extract<BuildConfigRails, {
236
249
  type: T[number];
237
250
  }>;
251
+ export type WorkspaceBuildConfigBase = {
252
+ dir?: string;
253
+ /**
254
+ * customize lint, set false to disable
255
+ */
256
+ lint?: false | TestJobCustom;
257
+ /**
258
+ * customize test, set false to disable
259
+ */
260
+ test?: false | TestJobCustom;
261
+ /**
262
+ * customize audit, set false to disable
263
+ */
264
+ audit?: false | TestJobCustom;
265
+ /**
266
+ * additional vars only for the runner.
267
+ * Also if you use services: that require env vars, you need to set them here.
268
+ *
269
+ */
270
+ runnerVariables?: Record<string, string>;
271
+ /**
272
+ * additional CI/CD artifacts reports,
273
+ * use to display information in merge requests, pipeline views and security dashboards.
274
+ */
275
+ artifactsReports?: BuildConfigArtifactsReports;
276
+ };
277
+ export type WorkspaceBuildConfigNode = {
278
+ type: "node";
279
+ buildCommand?: string | string[];
280
+ } & WorkspaceBuildConfigBase;
281
+ export type WorkspaceBuildConfig = WorkspaceBuildConfigNode;
238
282
  export {};
@@ -3,12 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isOfBuildType = void 0;
6
+ exports.isOfBuildType = exports.isStandaloneBuildConfig = void 0;
7
+ var isStandaloneBuildConfig = function (t) {
8
+ if (!t) return false;
9
+ return !("from" in t);
10
+ };
11
+ exports.isStandaloneBuildConfig = isStandaloneBuildConfig;
7
12
  var isOfBuildType = function (t) {
8
13
  var types = [];
9
14
  for (var _i = 1; _i < arguments.length; _i++) {
10
15
  types[_i - 1] = arguments[_i];
11
16
  }
17
+ if (!(0, exports.isStandaloneBuildConfig)(t)) return false;
12
18
  return types.includes(t.type);
13
19
  };
14
20
  exports.isOfBuildType = isOfBuildType;