@catladder/pipeline 0.0.0-next-e3ccf7d4 → 0.0.0-next-08efdbb7

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 (67) hide show
  1. package/dist/backends/github/createGithubJobs.js +17 -8
  2. package/dist/backends/gitlab/createGitlabJobs.js +15 -2
  3. package/dist/build/cache/createJobCache.js +8 -3
  4. package/dist/build/node/cache.js +8 -1
  5. package/dist/build/types.d.ts +11 -0
  6. package/dist/constants.js +1 -1
  7. package/dist/tsconfig.tsbuildinfo +1 -1
  8. package/dist/types/jobs.d.ts +7 -1
  9. package/examples/__snapshots__/automatic-releases.test.ts.snap +20 -20
  10. package/examples/__snapshots__/cloud-run-execute-script-on-deploy.test.ts.snap +20 -20
  11. package/examples/__snapshots__/cloud-run-health-check-defaults.test.ts.snap +20 -20
  12. package/examples/__snapshots__/cloud-run-health-check-only-startup.test.ts.snap +20 -20
  13. package/examples/__snapshots__/cloud-run-health-check.test.ts.snap +20 -20
  14. package/examples/__snapshots__/cloud-run-http2.test.ts.snap +20 -20
  15. package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +20 -20
  16. package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +16 -16
  17. package/examples/__snapshots__/cloud-run-nextjs.test.ts.snap +20 -20
  18. package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +20 -20
  19. package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +20 -20
  20. package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +20 -20
  21. package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +20 -20
  22. package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +20 -20
  23. package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +20 -20
  24. package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +20 -20
  25. package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +20 -20
  26. package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +20 -20
  27. package/examples/__snapshots__/cloud-run-session-affinity.test.ts.snap +20 -20
  28. package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +12 -12
  29. package/examples/__snapshots__/cloud-run-with-agents.test.ts.snap +20 -20
  30. package/examples/__snapshots__/cloud-run-with-gpu.test.ts.snap +20 -20
  31. package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +20 -20
  32. package/examples/__snapshots__/cloud-run-with-sql-legacy-jobs.test.ts.snap +20 -20
  33. package/examples/__snapshots__/cloud-run-with-sql-multiple-dbs.test.ts.snap +60 -60
  34. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +40 -40
  35. package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +20 -20
  36. package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +20 -20
  37. package/examples/__snapshots__/cloud-run-worker-pool.test.ts.snap +20 -20
  38. package/examples/__snapshots__/custom-deploy.test.ts.snap +20 -20
  39. package/examples/__snapshots__/custom-docker-file.test.ts.snap +20 -20
  40. package/examples/__snapshots__/custom-envs.test.ts.snap +28 -28
  41. package/examples/__snapshots__/custom-verify-job.test.ts.snap +20 -20
  42. package/examples/__snapshots__/git-submodule.test.ts.snap +20 -20
  43. package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +20 -20
  44. package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +20 -20
  45. package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +40 -40
  46. package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +20 -20
  47. package/examples/__snapshots__/local-dot-env.test.ts.snap +20 -20
  48. package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +16 -16
  49. package/examples/__snapshots__/modify-generated-files.test.ts.snap +16 -16
  50. package/examples/__snapshots__/modify-generated-yaml.test.ts.snap +16 -16
  51. package/examples/__snapshots__/multiline-var.test.ts.snap +60 -60
  52. package/examples/__snapshots__/native-app.test.ts.snap +36 -36
  53. package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +20 -20
  54. package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +20 -20
  55. package/examples/__snapshots__/override-secrets.test.ts.snap +20 -20
  56. package/examples/__snapshots__/pipelines-config.test.ts.snap +20 -20
  57. package/examples/__snapshots__/referencing-other-vars.test.ts.snap +60 -60
  58. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +32 -32
  59. package/examples/__snapshots__/workspace-api-www-turbo-cache.test.ts.snap +24 -24
  60. package/examples/__snapshots__/workspace-api-www.test.ts.snap +24 -24
  61. package/package.json +1 -1
  62. package/src/backends/github/createGithubJobs.ts +17 -6
  63. package/src/backends/gitlab/createGitlabJobs.ts +13 -5
  64. package/src/build/cache/createJobCache.ts +8 -1
  65. package/src/build/node/cache.ts +11 -0
  66. package/src/build/types.ts +12 -0
  67. package/src/types/jobs.ts +7 -1
@@ -157,24 +157,33 @@ var createCacheSteps = function (context, job) {
157
157
  }
158
158
  var lowered = (_b = (0, createJobCache_1.createJobCacheFromCacheConfigs)(context, job.caches)) !== null && _b !== void 0 ? _b : [];
159
159
  return (0, utils_1.ensureArray)(lowered).map(function (cache) {
160
- var _a, _b, _c, _d, _e, _f;
160
+ var _a, _b, _c, _d, _e, _f, _g;
161
161
  var paths = (0, utils_1.ensureArray)((_a = cache.paths) !== null && _a !== void 0 ? _a : []);
162
162
  var key = cache.key;
163
- var _g = typeof key === "string" || key === undefined ? {
163
+ var _h = typeof key === "string" || key === undefined ? ((_b = cache.keyFiles) === null || _b === void 0 ? void 0 : _b.length) ? {
164
+ // content-keyed: an unchanged hash is an exact hit and the
165
+ // cache is never re-saved (no per-run copies, no races
166
+ // between parallel jobs saving the same key)
167
+ cacheKey: "".concat(key !== null && key !== void 0 ? key : "cache", "-${{ hashFiles(").concat(cache.keyFiles.map(function (f) {
168
+ return "'".concat(f, "'");
169
+ }).join(", "), ") }}"),
170
+ restoreKeyPrefix: "".concat(key !== null && key !== void 0 ? key : "cache", "-"),
171
+ label: key !== null && key !== void 0 ? key : "cache"
172
+ } : {
164
173
  // unique key per run so the cache is re-saved, restored via prefix
165
174
  cacheKey: "".concat(key !== null && key !== void 0 ? key : "cache", "-${{ github.run_id }}"),
166
175
  restoreKeyPrefix: "".concat(key !== null && key !== void 0 ? key : "cache", "-"),
167
176
  label: key !== null && key !== void 0 ? key : "cache"
168
177
  } : {
169
- cacheKey: "".concat((_b = key.prefix) !== null && _b !== void 0 ? _b : "files", "-${{ hashFiles(").concat(((_c = key.files) !== null && _c !== void 0 ? _c : []).map(function (f) {
178
+ cacheKey: "".concat((_c = key.prefix) !== null && _c !== void 0 ? _c : "files", "-${{ hashFiles(").concat(((_d = key.files) !== null && _d !== void 0 ? _d : []).map(function (f) {
170
179
  return "'".concat(f, "'");
171
180
  }).join(", "), ") }}"),
172
- restoreKeyPrefix: "".concat((_d = key.prefix) !== null && _d !== void 0 ? _d : "files", "-"),
173
- label: (_e = key.prefix) !== null && _e !== void 0 ? _e : ((_f = key.files) !== null && _f !== void 0 ? _f : []).join(",")
181
+ restoreKeyPrefix: "".concat((_e = key.prefix) !== null && _e !== void 0 ? _e : "files", "-"),
182
+ label: (_f = key.prefix) !== null && _f !== void 0 ? _f : ((_g = key.files) !== null && _g !== void 0 ? _g : []).join(",")
174
183
  },
175
- cacheKey = _g.cacheKey,
176
- restoreKeyPrefix = _g.restoreKeyPrefix,
177
- label = _g.label;
184
+ cacheKey = _h.cacheKey,
185
+ restoreKeyPrefix = _h.restoreKeyPrefix,
186
+ label = _h.label;
178
187
  return {
179
188
  name: "Cache ".concat(label),
180
189
  // pull-only caches are restored but never saved
@@ -260,8 +260,21 @@ var makeGitlabJob = function (context, job, allJobs, images, baseRules) {
260
260
  var when = jobWhen !== null && jobWhen !== void 0 ? jobWhen : gate ? gate === "manual" ? "manual" : "on_success" : undefined;
261
261
  var allow_failure = jobAllowFailure !== null && jobAllowFailure !== void 0 ? jobAllowFailure : gate ? gate === "manual" : undefined;
262
262
  // the neutral `caches` declarations resolve to gitlab cache configs;
263
- // an explicitly set gitlab `cache` takes precedence
264
- var cache = jobCache !== null && jobCache !== void 0 ? jobCache : caches && context.type !== "agent" ? (0, createJobCache_1.createJobCacheFromCacheConfigs)(context, caches) : undefined;
263
+ // an explicitly set gitlab `cache` takes precedence. `keyFiles` is a
264
+ // github-only content-key hint and must not leak into the gitlab yaml
265
+ var stripKeyFiles = function (resolved) {
266
+ return Array.isArray(resolved) ? resolved.map(function (_a) {
267
+ var _keyFiles = _a.keyFiles,
268
+ cacheRest = __rest(_a, ["keyFiles"]);
269
+ return cacheRest;
270
+ }) : function (_a) {
271
+ var _keyFiles = _a.keyFiles,
272
+ cacheRest = __rest(_a, ["keyFiles"]);
273
+ return cacheRest;
274
+ }(resolved);
275
+ };
276
+ var resolvedCaches = caches && context.type !== "agent" ? (0, createJobCache_1.createJobCacheFromCacheConfigs)(context, caches) : undefined;
277
+ var cache = jobCache !== null && jobCache !== void 0 ? jobCache : resolvedCaches && stripKeyFiles(resolvedCaches);
265
278
  var stage = envMode === "stagePerEnv" && context.type !== "agent" ? "".concat(job.stage, " ").concat(context.env) : job.stage;
266
279
  var deduplicatedGitlabNeeds = getGitlabNeeds(context, job, allJobs, imageNeeds);
267
280
  var fullJobName = getFullJobName({
@@ -88,7 +88,8 @@ var createJobCacheFromCacheConfigs = function (context, caches) {
88
88
  scope = _a.scope,
89
89
  pathMode = _a.pathMode,
90
90
  buildDir = _a.buildDir,
91
- rest = __rest(_a, ["key", "paths", "policy", "scope", "pathMode", "buildDir"]);
91
+ keyFiles = _a.keyFiles,
92
+ rest = __rest(_a, ["key", "paths", "policy", "scope", "pathMode", "buildDir", "keyFiles"]);
92
93
  var baseDir = pathMode === "absolute" ? "" : buildDir !== null && buildDir !== void 0 ? buildDir : context.build.dir;
93
94
  var transformedKey = scope === "global" ? key : typeof key === "string" ? (scope === "buildDir" // really edge case...
94
95
  ? (0, slugify_1.default)(baseDir) : context.name) + "-" + key : __assign(__assign({}, key), {
@@ -96,13 +97,17 @@ var createJobCacheFromCacheConfigs = function (context, caches) {
96
97
  return pathMode === "absolute" ? f : (0, path_1.join)(baseDir, f);
97
98
  })
98
99
  });
99
- return __assign({
100
+ return __assign(__assign({
100
101
  key: transformedKey,
101
102
  policy: policy !== null && policy !== void 0 ? policy : "pull-push",
102
103
  paths: pathMode === "absolute" ? paths : paths === null || paths === void 0 ? void 0 : paths.map(function (p) {
103
104
  return (0, path_1.join)(baseDir, p);
104
105
  })
105
- }, rest);
106
+ }, (keyFiles === null || keyFiles === void 0 ? void 0 : keyFiles.length) ? {
107
+ keyFiles: keyFiles.map(function (f) {
108
+ return pathMode === "absolute" ? f : (0, path_1.join)(baseDir, f);
109
+ })
110
+ } : {}), rest);
106
111
  });
107
112
  return __spreadArray(__spreadArray([], __read(advancedCaches), false), __read(simpleCaches), false);
108
113
  };
@@ -180,7 +180,10 @@ var getYarnCache = function (context_1) {
180
180
  pathMode: componentIsInWorkspace ? "absolute" : "relative",
181
181
  key: "yarn",
182
182
  policy: policy,
183
- paths: [".yarn"]
183
+ paths: [".yarn"],
184
+ // content-key for immutable-cache backends (github); the lockfile
185
+ // decides whether the cached content could have changed
186
+ keyFiles: ["yarn.lock"]
184
187
  }]];
185
188
  }
186
189
  });
@@ -214,6 +217,10 @@ var getNodeModulesCache = function (context_1) {
214
217
  // if component is in a shared workspace, use workspace cache. use individual cache else
215
218
  key: componentIsInWorkspace ? "node-modules-workspace" : (0, slugify_1.default)(context.build.dir) + "-node-modules",
216
219
  // we use the dirname, not the component name, because in certain cases we have two apps in the same directory and want to share the cache, e.g. when having storybook in the same package.json
220
+ // content-key for immutable-cache backends (github); the lockfile
221
+ // decides whether the cached content could have changed (absolute
222
+ // pathMode: resolve the standalone component's lockfile explicitly)
223
+ keyFiles: [componentIsInWorkspace ? "yarn.lock" : (0, path_1.join)(context.build.dir, "yarn.lock")],
217
224
  policy: policy,
218
225
  paths: __spreadArray([], __read(componentIsInWorkspace ? (0, lodash_es_1.uniq)(__spreadArray(__spreadArray(["node_modules"], __read((_a = workspaces.map(function (w) {
219
226
  return (0, path_1.join)(w.location, "node_modules");
@@ -14,6 +14,17 @@ export type CacheConfigAdvanced = Omit<CatladderJobCache, "paths" | "key"> & {
14
14
  * defaults to context
15
15
  */
16
16
  scope?: "context" | "buildDir" | "global";
17
+ /**
18
+ * files whose content determines whether the cached content changed
19
+ * (e.g. the lockfile for a node_modules cache).
20
+ *
21
+ * Backends with immutable caches (github) key the cache by the hash
22
+ * of these files: an unchanged hash is an exact hit and the cache is
23
+ * never re-saved (without this, every run saves a fresh multi-GB
24
+ * cache under a run-unique key, and parallel jobs race on saving
25
+ * it). Gitlab ignores this and keeps its stable, mutable key.
26
+ */
27
+ keyFiles?: string[];
17
28
  } & CacheConfigSimple;
18
29
  export type CacheConfigSimple = {
19
30
  /**
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 = "next-e3ccf7d4" || "latest";
7
+ exports.PIPELINE_IMAGE_TAG = "next-08efdbb7" || "latest";
8
8
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";