@catladder/pipeline 3.25.0 → 3.27.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 (77) hide show
  1. package/dist/build/custom/testJob.js +1 -2
  2. package/dist/build/node/testJob.js +1 -2
  3. package/dist/build/node/yarn.js +3 -2
  4. package/dist/build/rails/test.js +1 -2
  5. package/dist/constants.js +1 -1
  6. package/dist/deploy/types/googleCloudRun.d.ts +1 -1
  7. package/dist/pipeline/agent/createAgentReviewJob.js +1 -0
  8. package/dist/pipeline/agent/shared.d.ts +1 -1
  9. package/dist/pipeline/agent/shared.js +0 -1
  10. package/dist/pipeline/createMainPipeline.js +1 -0
  11. package/dist/pipeline/gitlab/cache.d.ts +9 -0
  12. package/dist/pipeline/gitlab/cache.js +47 -0
  13. package/dist/pipeline/gitlab/createGitlabJobs.js +7 -7
  14. package/dist/tsconfig.tsbuildinfo +1 -1
  15. package/dist/types/jobs.d.ts +2 -3
  16. package/examples/__snapshots__/automatic-releases.test.ts.snap +141 -31
  17. package/examples/__snapshots__/cloud-run-health-check-defaults.test.ts.snap +141 -31
  18. package/examples/__snapshots__/cloud-run-health-check-only-startup.test.ts.snap +141 -31
  19. package/examples/__snapshots__/cloud-run-health-check.test.ts.snap +141 -31
  20. package/examples/__snapshots__/cloud-run-http2.test.ts.snap +141 -31
  21. package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +141 -31
  22. package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +133 -27
  23. package/examples/__snapshots__/cloud-run-nextjs.test.ts.snap +144 -32
  24. package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +141 -31
  25. package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +141 -31
  26. package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +141 -31
  27. package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +141 -31
  28. package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +141 -31
  29. package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +141 -31
  30. package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +141 -31
  31. package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +141 -31
  32. package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +141 -31
  33. package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +21 -11
  34. package/examples/__snapshots__/cloud-run-with-agents.test.ts.snap +144 -32
  35. package/examples/__snapshots__/cloud-run-with-gpu.test.ts.snap +141 -31
  36. package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +141 -31
  37. package/examples/__snapshots__/cloud-run-with-sql-legacy-jobs.test.ts.snap +141 -31
  38. package/examples/__snapshots__/cloud-run-with-sql-multiple-dbs.test.ts.snap +423 -93
  39. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +282 -62
  40. package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +141 -31
  41. package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +141 -31
  42. package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +93 -22
  43. package/examples/__snapshots__/custom-deploy.test.ts.snap +141 -31
  44. package/examples/__snapshots__/custom-envs.test.ts.snap +328 -40
  45. package/examples/__snapshots__/custom-verify-job.test.ts.snap +144 -32
  46. package/examples/__snapshots__/git-submodule.test.ts.snap +141 -31
  47. package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +141 -31
  48. package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +141 -31
  49. package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +282 -62
  50. package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +141 -31
  51. package/examples/__snapshots__/local-dot-env.test.ts.snap +141 -31
  52. package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +133 -27
  53. package/examples/__snapshots__/modify-generated-files.test.ts.snap +124 -20
  54. package/examples/__snapshots__/modify-generated-yaml.test.ts.snap +124 -20
  55. package/examples/__snapshots__/multiline-var.test.ts.snap +423 -93
  56. package/examples/__snapshots__/native-app.test.ts.snap +277 -57
  57. package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +141 -31
  58. package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +141 -31
  59. package/examples/__snapshots__/override-secrets.test.ts.snap +141 -31
  60. package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +84 -22
  61. package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +84 -22
  62. package/examples/__snapshots__/referencing-other-vars.test.ts.snap +423 -93
  63. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +260 -52
  64. package/examples/__snapshots__/workspace-api-www-turbo-cache.test.ts.snap +161 -43
  65. package/examples/__snapshots__/workspace-api-www.test.ts.snap +161 -43
  66. package/package.json +1 -1
  67. package/src/build/custom/testJob.ts +0 -1
  68. package/src/build/node/testJob.ts +0 -1
  69. package/src/build/node/yarn.ts +3 -2
  70. package/src/build/rails/test.ts +0 -1
  71. package/src/deploy/types/googleCloudRun.ts +1 -1
  72. package/src/pipeline/agent/createAgentReviewJob.ts +1 -0
  73. package/src/pipeline/agent/shared.ts +2 -2
  74. package/src/pipeline/createMainPipeline.ts +1 -0
  75. package/src/pipeline/gitlab/cache.ts +49 -0
  76. package/src/pipeline/gitlab/createGitlabJobs.ts +7 -9
  77. package/src/types/jobs.ts +2 -3
@@ -73,8 +73,7 @@ var createCustomTestJobs = function (context) {
73
73
  services: buildConfig.jobServices,
74
74
  cache: (0, createJobCache_1.createJobCacheFromConfig)(context, buildConfig),
75
75
  stage: "test",
76
- needs: [],
77
- envMode: "none"
76
+ needs: []
78
77
  };
79
78
  var auditJob = buildConfig.audit ? __assign(__assign(__assign({
80
79
  name: "🛡 audit"
@@ -71,8 +71,7 @@ var createNodeTestJobs = function (context) {
71
71
  }, context.type === "component" ? __assign({}, context.environment.jobOnlyVars.build.envVars) : {}),
72
72
  runnerVariables: constants_1.NODE_RUNNER_BUILD_VARIABLES,
73
73
  stage: "test",
74
- needs: [],
75
- envMode: "none"
74
+ needs: []
76
75
  };
77
76
  var buildConfig = context.build.config;
78
77
  var yarnInstall = (0, yarn_1.getYarnInstall)(context);
@@ -45,7 +45,8 @@ var getYarnInstallCommand = function (context) {
45
45
  if (context.packageManagerInfo.isClassic) {
46
46
  return YARN_INSTALL_CLASSIC;
47
47
  }
48
- return "yarn install --immutable";
48
+ // inline builds make debugging easier as it prints it out in the logs, instead of writing it in temp files
49
+ return "yarn install --immutable --inline-builds";
49
50
  };
50
51
  var ensureNodeVersion = function (context) {
51
52
  return (0, gitlab_1.collapseableSection)("nodeinstall", "Ensure node version")(["if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi", "if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi"]);
@@ -69,6 +70,6 @@ var getDockerAppCopyAndBuildScript = function (context) {
69
70
  var maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins ? "RUN yarn plugin import workspace-tools" : "";
70
71
  // copy first everything and then install
71
72
  // rebuild first does not work as it will run postinstall and that might require files in the app
72
- return new BashExpression_1.BashExpression("\n".concat(DOCKER_COPY_FILES, "\n").concat(maybeAddWorkspaceToolsCommand, "\nRUN ").concat(YARN_BERRY_PROD_REBUILD, "\n\n ").trim());
73
+ return new BashExpression_1.BashExpression("\n ENV YARN_ENABLE_INLINE_BUILDS=1\n".concat(DOCKER_COPY_FILES, "\n").concat(maybeAddWorkspaceToolsCommand, "\nRUN ").concat(YARN_BERRY_PROD_REBUILD, "\n\n ").trim());
73
74
  };
74
75
  exports.getDockerAppCopyAndBuildScript = getDockerAppCopyAndBuildScript;
@@ -62,8 +62,7 @@ var createRailsTestJobs = function (context) {
62
62
  var base = {
63
63
  variables: __assign({}, context.environment.jobOnlyVars.build.envVars),
64
64
  stage: "test",
65
- needs: [],
66
- envMode: "none"
65
+ needs: []
67
66
  };
68
67
  var defaultImage = "docker.io/ruby";
69
68
  var bundlerCacheDir = "tmp/cache";
package/dist/constants.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
7
- exports.PIPELINE_IMAGE_TAG = "v3-25-0-910b2ed7" || "latest";
7
+ exports.PIPELINE_IMAGE_TAG = "v3-27-0-97e895e3" || "latest";
8
8
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";
@@ -422,7 +422,7 @@ export type DeployConfigCloudRunExecuteHttp = {
422
422
  /**
423
423
  * the http-method to use. Defaults to "POST" (as specified by google cloud scheduler)
424
424
  */
425
- method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
425
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "PURGE";
426
426
  /**
427
427
  * the body to send
428
428
  */
@@ -69,6 +69,7 @@ var createAgentReviewJob = function (context) {
69
69
  };
70
70
  });
71
71
  return __assign(__assign({}, baseJob), {
72
+ envMode: "jobPerEnv",
72
73
  name: context.name + "-agent-review",
73
74
  allow_failure: true,
74
75
  rules: __spreadArray(__spreadArray([], __read(rules), false), [__assign(__assign({}, rules_1.RULE_IS_MERGE_REQUEST), {
@@ -1,5 +1,5 @@
1
1
  import type { AgentContext, CatladderJob } from "../../types";
2
- export declare const createBaseAgentJob: (context: AgentContext) => Omit<CatladderJob, "name" | "rules" | "script">;
2
+ export declare const createBaseAgentJob: (context: AgentContext) => Omit<CatladderJob, "name" | "rules" | "script" | "envMode">;
3
3
  export declare const baseSetupScript: string[];
4
4
  export declare const callClaude: ({
5
5
  prompt
@@ -9,7 +9,6 @@ var runner_1 = require("../../runner");
9
9
  var createBaseAgentJob = function (context) {
10
10
  return {
11
11
  stage: "agents",
12
- envMode: "none",
13
12
  // image: "node:24-alpine3.21",
14
13
  image: (0, runner_1.getRunnerImage)("agent-claude"),
15
14
  variables: {
@@ -242,6 +242,7 @@ var createMainPipeline = function (pipelineType, config) {
242
242
  context = _a.context;
243
243
  // merge jobs, if a job is already there, merge the rules
244
244
  // this is currently needed because of envMode: "none", which creates the same job for all triggers, so it can appear multiple times
245
+ // NOTICE: envNode none has been removed and this may no longer be needed
245
246
  if (acc[name]) {
246
247
  acc[name].gitlabJob.rules = __spreadArray(__spreadArray([], __read((_b = acc[name].gitlabJob.rules) !== null && _b !== void 0 ? _b : []), false), __read((_c = gitlabJob.rules) !== null && _c !== void 0 ? _c : []), false);
247
248
  } else {
@@ -0,0 +1,9 @@
1
+ import type { AgentContext, Context, GitlabJobCache } from "../../types";
2
+ export declare const getCacheKeyWithFallbackForMR: (baseKey: string, context: Context) => {
3
+ key: string;
4
+ fallback_keys: string[];
5
+ } | {
6
+ key: string;
7
+ fallback_keys?: undefined;
8
+ };
9
+ export declare const addCacheFallback: (cache: GitlabJobCache | GitlabJobCache[], context: Context | AgentContext) => GitlabJobCache | GitlabJobCache[];
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", {
14
+ value: true
15
+ });
16
+ exports.addCacheFallback = exports.getCacheKeyWithFallbackForMR = void 0;
17
+ var getCacheKeyWithFallbackForMR = function (baseKey, context) {
18
+ // if its a branch, create a key with the branch name with fallback to the base key
19
+ if (context.trigger === "mr") {
20
+ return {
21
+ key: baseKey + "-mr$CI_MERGE_REQUEST_IID",
22
+ fallback_keys: [baseKey]
23
+ };
24
+ }
25
+ return {
26
+ key: baseKey
27
+ };
28
+ };
29
+ exports.getCacheKeyWithFallbackForMR = getCacheKeyWithFallbackForMR;
30
+ var addCacheFallback = function (cache, context) {
31
+ if (context.type !== "agent" && context.trigger === "mr") {
32
+ if (Array.isArray(cache)) {
33
+ return cache.map(function (c) {
34
+ return addCacheFallbackToSingleCacheForMR(c, context);
35
+ });
36
+ }
37
+ return addCacheFallbackToSingleCacheForMR(cache, context);
38
+ }
39
+ return cache;
40
+ };
41
+ exports.addCacheFallback = addCacheFallback;
42
+ var addCacheFallbackToSingleCacheForMR = function (cache, context) {
43
+ if (typeof cache.key === "string") {
44
+ return __assign(__assign({}, cache), (0, exports.getCacheKeyWithFallbackForMR)(cache.key, context));
45
+ }
46
+ return cache; // as is
47
+ };
@@ -175,6 +175,7 @@ var utils_1 = require("../../utils");
175
175
  var gitlab_1 = require("../../utils/gitlab");
176
176
  var removeUndefined_1 = require("../../utils/removeUndefined");
177
177
  var BashExpression_1 = require("../../bash/BashExpression");
178
+ var cache_1 = require("./cache");
178
179
  exports.GITLAB_ENVIRONMENT_URL_VARIABLE = "CL_GITLAB_ENVIRONMENT_URL";
179
180
  var getFullJobName = function (_a) {
180
181
  var type = _a.type,
@@ -200,12 +201,11 @@ var getFullReferencedJobNameFromComponent = function (referencedJobName, compone
200
201
  if (!referencedJob) {
201
202
  throw new Error("unknown job referenced: '".concat(referencedJobName, "' from '").concat(env, ":").concat(componentName, "'"));
202
203
  }
203
- var envToSet = referencedJob.envMode !== "none" ? env : null;
204
204
  return getFullJobName({
205
205
  type: "component",
206
206
  name: referencedJobName,
207
207
  baseName: componentName,
208
- env: envToSet,
208
+ env: env,
209
209
  allJobs: allJobs
210
210
  });
211
211
  };
@@ -219,12 +219,11 @@ var getFullReferencedJobNameFromWorkspace = function (referencedJobName, workspa
219
219
  if (!referencedJob) {
220
220
  throw new Error("unknown job referenced: '".concat(referencedJobName, "' from workspace ").concat(env, ":").concat(workspaceName, "'"));
221
221
  }
222
- var envToSet = referencedJob.envMode !== "none" ? env : null;
223
222
  return getFullJobName({
224
223
  type: "workspace",
225
224
  name: referencedJobName,
226
225
  baseName: workspaceName,
227
- env: envToSet,
226
+ env: env,
228
227
  allJobs: allJobs
229
228
  });
230
229
  };
@@ -243,14 +242,15 @@ var makeGitlabJob = function (context, job, allJobs, baseRules) {
243
242
  variables = job.variables,
244
243
  runnerVariables = job.runnerVariables,
245
244
  when = job.when,
246
- rest = __rest(job, ["environment", "envMode", "needsStages", "name", "needs", "jobTags", "script", "variables", "runnerVariables", "when"]);
245
+ cache = job.cache,
246
+ rest = __rest(job, ["environment", "envMode", "needsStages", "name", "needs", "jobTags", "script", "variables", "runnerVariables", "when", "cache"]);
247
247
  var stage = envMode === "stagePerEnv" && context.type !== "agent" ? "".concat(job.stage, " ").concat(context.env) : job.stage;
248
248
  var deduplicatedGitlabNeeds = getGitlabNeeds(context, job, allJobs);
249
249
  var fullJobName = getFullJobName({
250
250
  type: context.type,
251
251
  name: name,
252
252
  baseName: context.name,
253
- env: envMode !== "none" && context.type !== "agent" ? context.env : undefined,
253
+ env: context.type !== "agent" ? context.env : undefined,
254
254
  allJobs: allJobs
255
255
  });
256
256
  // backwards compatibility, some may still use KUBERNETES_CPU_REQUEST, KUBERNETES_MEMORY_REQUEST, etc. in variables.
@@ -283,6 +283,7 @@ var makeGitlabJob = function (context, job, allJobs, baseRules) {
283
283
  retry: defaults_1.BASE_RETRY,
284
284
  interruptible: true
285
285
  }, rest), {
286
+ cache: cache ? (0, cache_1.addCacheFallback)(cache, context) : undefined,
286
287
  rules: rules.length > 0 ? rules : undefined,
287
288
  variables: __assign(__assign({}, legacyRunnerVariables), runnerVariables),
288
289
  script: __spreadArray(__spreadArray([], __read(varsInjectScripts), false), __read((_b = script === null || script === void 0 ? void 0 : script.filter(utils_1.notNil)) !== null && _b !== void 0 ? _b : []), false),
@@ -340,7 +341,6 @@ var addGitlabEnvironment = function (context, catladderJobEnvironment, job, allJ
340
341
  var createGitlabJobs = function (allJobs, baseRules) {
341
342
  return __awaiter(void 0, void 0, void 0, function () {
342
343
  return __generator(this, function (_a) {
343
- // TODO: add workspace jobs
344
344
  return [2 /*return*/, __spreadArray(__spreadArray(__spreadArray([], __read(allJobs.workspaces), false), __read(allJobs.components), false), __read(allJobs.agents), false).flatMap(function (_a) {
345
345
  var context = _a.context,
346
346
  jobs = _a.jobs;