@catladder/pipeline 3.30.5 โ†’ 3.32.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.
@@ -55,7 +55,7 @@ var RUNNER_CUSTOM_TEST_VARIABLES = {
55
55
  KUBERNETES_MEMORY_LIMIT: "4Gi"
56
56
  };
57
57
  var createCustomTestJobs = function (context) {
58
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
58
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
59
59
  // don't run tests after release
60
60
  // TODO: this will be replaced by using rules
61
61
  if (context.trigger === "taggedRelease") {
@@ -69,7 +69,6 @@ var createCustomTestJobs = function (context) {
69
69
  variables: __assign({
70
70
  APP_PATH: context.build.dir
71
71
  }, context.environment.jobOnlyVars.build.envVars),
72
- runnerVariables: RUNNER_CUSTOM_TEST_VARIABLES,
73
72
  services: buildConfig.jobServices,
74
73
  cache: (0, createJobCache_1.createJobCacheFromConfig)(context, buildConfig),
75
74
  stage: "test",
@@ -78,23 +77,26 @@ var createCustomTestJobs = function (context) {
78
77
  var auditJob = buildConfig.audit ? __assign(__assign(__assign({
79
78
  name: "๐Ÿ›ก audit"
80
79
  }, base), {
81
- image: (_b = (_a = buildConfig.audit) === null || _a === void 0 ? void 0 : _a.jobImage) !== null && _b !== void 0 ? _b : buildConfig.jobImage,
80
+ runnerVariables: __assign(__assign({}, RUNNER_CUSTOM_TEST_VARIABLES), (_b = (_a = buildConfig.audit) === null || _a === void 0 ? void 0 : _a.runnerVariables) !== null && _b !== void 0 ? _b : {}),
81
+ image: (_d = (_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.jobImage) !== null && _d !== void 0 ? _d : buildConfig.jobImage,
82
82
  cache: undefined,
83
- script: __spreadArray([], __read((0, utils_1.ensureArray)((_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.command)), false),
83
+ script: __spreadArray([], __read((0, utils_1.ensureArray)((_e = buildConfig.audit) === null || _e === void 0 ? void 0 : _e.command)), false),
84
84
  allow_failure: true
85
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_d = buildConfig.audit) === null || _d === void 0 ? void 0 : _d.artifactsReports, (_e = buildConfig.audit) === null || _e === void 0 ? void 0 : _e.artifacts)) : null;
85
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_f = buildConfig.audit) === null || _f === void 0 ? void 0 : _f.artifactsReports, (_g = buildConfig.audit) === null || _g === void 0 ? void 0 : _g.artifacts)) : null;
86
86
  var lintJob = buildConfig.lint ? __assign(__assign(__assign({
87
87
  name: "๐Ÿ‘ฎ lint"
88
88
  }, base), {
89
- image: (_g = (_f = buildConfig.lint) === null || _f === void 0 ? void 0 : _f.jobImage) !== null && _g !== void 0 ? _g : buildConfig.jobImage,
90
- script: __spreadArray([], __read((0, utils_1.ensureArray)((_h = buildConfig.lint) === null || _h === void 0 ? void 0 : _h.command)), false)
91
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_j = buildConfig.lint) === null || _j === void 0 ? void 0 : _j.artifactsReports, (_k = buildConfig.lint) === null || _k === void 0 ? void 0 : _k.artifacts)) : null;
89
+ runnerVariables: __assign(__assign({}, RUNNER_CUSTOM_TEST_VARIABLES), (_j = (_h = buildConfig.lint) === null || _h === void 0 ? void 0 : _h.runnerVariables) !== null && _j !== void 0 ? _j : {}),
90
+ image: (_l = (_k = buildConfig.lint) === null || _k === void 0 ? void 0 : _k.jobImage) !== null && _l !== void 0 ? _l : buildConfig.jobImage,
91
+ script: __spreadArray([], __read((0, utils_1.ensureArray)((_m = buildConfig.lint) === null || _m === void 0 ? void 0 : _m.command)), false)
92
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_o = buildConfig.lint) === null || _o === void 0 ? void 0 : _o.artifactsReports, (_p = buildConfig.lint) === null || _p === void 0 ? void 0 : _p.artifacts)) : null;
92
93
  var testJob = buildConfig.test ? __assign(__assign(__assign({
93
94
  name: "๐Ÿงช test"
94
95
  }, base), {
95
- image: (_m = (_l = buildConfig.test) === null || _l === void 0 ? void 0 : _l.jobImage) !== null && _m !== void 0 ? _m : buildConfig.jobImage,
96
- script: __spreadArray([], __read((0, utils_1.ensureArray)((_o = buildConfig.test) === null || _o === void 0 ? void 0 : _o.command)), false)
97
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_p = buildConfig.test) === null || _p === void 0 ? void 0 : _p.artifactsReports, (_q = buildConfig.test) === null || _q === void 0 ? void 0 : _q.artifacts)) : null;
96
+ runnerVariables: __assign(__assign({}, RUNNER_CUSTOM_TEST_VARIABLES), (_r = (_q = buildConfig.test) === null || _q === void 0 ? void 0 : _q.runnerVariables) !== null && _r !== void 0 ? _r : {}),
97
+ image: (_t = (_s = buildConfig.test) === null || _s === void 0 ? void 0 : _s.jobImage) !== null && _t !== void 0 ? _t : buildConfig.jobImage,
98
+ script: __spreadArray([], __read((0, utils_1.ensureArray)((_u = buildConfig.test) === null || _u === void 0 ? void 0 : _u.command)), false)
99
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_v = buildConfig.test) === null || _v === void 0 ? void 0 : _v.artifactsReports, (_w = buildConfig.test) === null || _w === void 0 ? void 0 : _w.artifacts)) : null;
98
100
  return [auditJob, lintJob, testJob].filter(utils_1.notNil);
99
101
  };
100
102
  exports.createCustomTestJobs = createCustomTestJobs;
@@ -64,6 +64,6 @@ export declare const createDockerBuildJobBase: (context: ComponentContextWithBui
64
64
  ...def
65
65
  }: DockerBuildJobDefinition) => CatladderJob;
66
66
  export declare const gitlabDockerLogin: (context: ComponentContext) => string[];
67
- export declare const getDockerBuildScriptWithBuiltInDockerFile: (context: ComponentContextWithBuild, defaultType?: BuildConfigDocker["type"]) => (string | undefined)[];
67
+ export declare const getDockerBuildScriptWithBuiltInDockerFile: (context: ComponentContextWithBuild, fallbackType?: BuildConfigDocker["type"]) => (string | undefined)[];
68
68
  export declare const getDockerBuildDefaultScript: (context: ComponentContext, ensureDockerFileScript?: string | null) => (string | undefined)[];
69
69
  export declare const hasDockerfile: (context: ComponentContext) => boolean;
@@ -168,10 +168,22 @@ var BUILT_IN_ENSURE_DOCKERFILE_SCRIPTS = {
168
168
  nginx: "ensureNginxDockerfile",
169
169
  custom: null
170
170
  };
171
- var getDockerBuildScriptWithBuiltInDockerFile = function (context, defaultType) {
172
- var _a;
173
- var type = "docker" in context.build.config && context.build.config.docker && "type" in context.build.config.docker ? (_a = context.build.config.docker) === null || _a === void 0 ? void 0 : _a.type : defaultType;
174
- return (0, exports.getDockerBuildDefaultScript)(context, type ? BUILT_IN_ENSURE_DOCKERFILE_SCRIPTS[type] : null);
171
+ var getEnsureDockerFileScript = function (context, fallbackType) {
172
+ var _a, _b, _c, _d, _e, _f;
173
+ if ("docker" in context.build.config && context.build.config.docker && "type" in context.build.config.docker) {
174
+ if (((_a = context.build.config.docker) === null || _a === void 0 ? void 0 : _a.type) === "custom") {
175
+ if ((_b = context.build.config.docker) === null || _b === void 0 ? void 0 : _b.dockerfileContent) {
176
+ // we need to create a script that creates a Dockerfile in the current directory
177
+ return "\necho \"Creating Dockerfile\"\ncat >$APP_DIR/Dockerfile <<EOF\n".concat((_d = (_c = context.build.config.docker) === null || _c === void 0 ? void 0 : _c.dockerfileContent) === null || _d === void 0 ? void 0 : _d.join("\n"), "\nEOF");
178
+ }
179
+ }
180
+ var type = (_f = (_e = context.build.config.docker) === null || _e === void 0 ? void 0 : _e.type) !== null && _f !== void 0 ? _f : fallbackType;
181
+ return type ? BUILT_IN_ENSURE_DOCKERFILE_SCRIPTS[type] : null;
182
+ }
183
+ return fallbackType ? BUILT_IN_ENSURE_DOCKERFILE_SCRIPTS[fallbackType] : null;
184
+ };
185
+ var getDockerBuildScriptWithBuiltInDockerFile = function (context, fallbackType) {
186
+ return (0, exports.getDockerBuildDefaultScript)(context, getEnsureDockerFileScript(context, fallbackType));
175
187
  };
176
188
  exports.getDockerBuildScriptWithBuiltInDockerFile = getDockerBuildScriptWithBuiltInDockerFile;
177
189
  var getDockerBuildDefaultScript = function (context, ensureDockerFileScript) {
@@ -54,7 +54,7 @@ var constants_1 = require("./constants");
54
54
  var yarn_1 = require("./yarn");
55
55
  var createJobCache_1 = require("../cache/createJobCache");
56
56
  var createNodeTestJobs = function (context) {
57
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
57
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
58
58
  // don't run tests after release
59
59
  // TODO: this will be replaced by using rules
60
60
  if (context.trigger === "taggedRelease") {
@@ -69,7 +69,6 @@ var createNodeTestJobs = function (context) {
69
69
  variables: __assign({
70
70
  APP_PATH: context.build.dir
71
71
  }, context.type === "component" ? __assign({}, context.environment.jobOnlyVars.build.envVars) : {}),
72
- runnerVariables: constants_1.NODE_RUNNER_BUILD_VARIABLES,
73
72
  stage: "test",
74
73
  needs: []
75
74
  };
@@ -78,26 +77,29 @@ var createNodeTestJobs = function (context) {
78
77
  var auditJob = buildConfig.audit !== false ? __assign(__assign(__assign({
79
78
  name: "๐Ÿ›ก audit"
80
79
  }, base), {
81
- image: (_b = (_a = buildConfig.audit) === null || _a === void 0 ? void 0 : _a.jobImage) !== null && _b !== void 0 ? _b : defaultImage,
80
+ runnerVariables: __assign(__assign({}, constants_1.NODE_RUNNER_BUILD_VARIABLES), (_b = (_a = buildConfig.audit) === null || _a === void 0 ? void 0 : _a.runnerVariables) !== null && _b !== void 0 ? _b : {}),
81
+ image: (_d = (_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.jobImage) !== null && _d !== void 0 ? _d : defaultImage,
82
82
  cache: undefined,
83
- script: __spreadArray(["cd ".concat(context.build.dir)], __read((_d = (0, utils_1.ensureArrayOrNull)((_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.command)) !== null && _d !== void 0 ? _d : [context.packageManagerInfo.isClassic ? "yarn audit" : "yarn npm audit --environment production" // yarn 2
83
+ script: __spreadArray(["cd ".concat(context.build.dir)], __read((_f = (0, utils_1.ensureArrayOrNull)((_e = buildConfig.audit) === null || _e === void 0 ? void 0 : _e.command)) !== null && _f !== void 0 ? _f : [context.packageManagerInfo.isClassic ? "yarn audit" : "yarn npm audit --environment production" // yarn 2
84
84
  ]), false),
85
85
  allow_failure: true
86
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_e = buildConfig.audit) === null || _e === void 0 ? void 0 : _e.artifactsReports, (_f = buildConfig.audit) === null || _f === void 0 ? void 0 : _f.artifacts)) : null;
86
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_g = buildConfig.audit) === null || _g === void 0 ? void 0 : _g.artifactsReports, (_h = buildConfig.audit) === null || _h === void 0 ? void 0 : _h.artifacts)) : null;
87
87
  var lintJob = buildConfig.lint !== false ? __assign(__assign(__assign({
88
88
  name: "๐Ÿ‘ฎ lint"
89
89
  }, base), {
90
- image: (_h = (_g = buildConfig.lint) === null || _g === void 0 ? void 0 : _g.jobImage) !== null && _h !== void 0 ? _h : defaultImage,
90
+ runnerVariables: __assign(__assign({}, constants_1.NODE_RUNNER_BUILD_VARIABLES), (_k = (_j = buildConfig.lint) === null || _j === void 0 ? void 0 : _j.runnerVariables) !== null && _k !== void 0 ? _k : {}),
91
+ image: (_m = (_l = buildConfig.lint) === null || _l === void 0 ? void 0 : _l.jobImage) !== null && _m !== void 0 ? _m : defaultImage,
91
92
  cache: (0, createJobCache_1.createJobCacheFromCacheConfigs)(context, (0, cache_1.getNodeCache)(context)),
92
- script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, yarn_1.ensureNodeVersion)(context)), false), ["cd ".concat(context.build.dir)], false), __read(yarnInstall), false), __read((_k = (0, utils_1.ensureArrayOrNull)((_j = buildConfig.lint) === null || _j === void 0 ? void 0 : _j.command)) !== null && _k !== void 0 ? _k : ["yarn lint"]), false)
93
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_l = buildConfig.lint) === null || _l === void 0 ? void 0 : _l.artifactsReports, (_m = buildConfig.lint) === null || _m === void 0 ? void 0 : _m.artifacts)) : null;
93
+ script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, yarn_1.ensureNodeVersion)(context)), false), ["cd ".concat(context.build.dir)], false), __read(yarnInstall), false), __read((_p = (0, utils_1.ensureArrayOrNull)((_o = buildConfig.lint) === null || _o === void 0 ? void 0 : _o.command)) !== null && _p !== void 0 ? _p : ["yarn lint"]), false)
94
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_q = buildConfig.lint) === null || _q === void 0 ? void 0 : _q.artifactsReports, (_r = buildConfig.lint) === null || _r === void 0 ? void 0 : _r.artifacts)) : null;
94
95
  var testJob = buildConfig.test !== false ? __assign(__assign(__assign({
95
96
  name: "๐Ÿงช test"
96
97
  }, base), {
97
- image: (_p = (_o = buildConfig.test) === null || _o === void 0 ? void 0 : _o.jobImage) !== null && _p !== void 0 ? _p : (0, runner_1.getRunnerImage)("jobs-testing-chrome"),
98
+ runnerVariables: __assign(__assign({}, constants_1.NODE_RUNNER_BUILD_VARIABLES), (_t = (_s = buildConfig.test) === null || _s === void 0 ? void 0 : _s.runnerVariables) !== null && _t !== void 0 ? _t : {}),
99
+ image: (_v = (_u = buildConfig.test) === null || _u === void 0 ? void 0 : _u.jobImage) !== null && _v !== void 0 ? _v : (0, runner_1.getRunnerImage)("jobs-testing-chrome"),
98
100
  cache: (0, createJobCache_1.createJobCacheFromCacheConfigs)(context, (0, cache_1.getNodeCache)(context)),
99
- script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, yarn_1.ensureNodeVersion)(context)), false), ["cd ".concat(context.build.dir)], false), __read(yarnInstall), false), __read((_r = (0, utils_1.ensureArrayOrNull)((_q = buildConfig.test) === null || _q === void 0 ? void 0 : _q.command)) !== null && _r !== void 0 ? _r : ["yarn test"]), false)
100
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_s = buildConfig.test) === null || _s === void 0 ? void 0 : _s.artifactsReports, (_t = buildConfig.test) === null || _t === void 0 ? void 0 : _t.artifacts)) : null;
101
+ script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, yarn_1.ensureNodeVersion)(context)), false), ["cd ".concat(context.build.dir)], false), __read(yarnInstall), false), __read((_x = (0, utils_1.ensureArrayOrNull)((_w = buildConfig.test) === null || _w === void 0 ? void 0 : _w.command)) !== null && _x !== void 0 ? _x : ["yarn test"]), false)
102
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_y = buildConfig.test) === null || _y === void 0 ? void 0 : _y.artifactsReports, (_z = buildConfig.test) === null || _z === void 0 ? void 0 : _z.artifacts)) : null;
101
103
  return [auditJob, lintJob, testJob].filter(utils_1.notNil);
102
104
  };
103
105
  exports.createNodeTestJobs = createNodeTestJobs;
@@ -62,6 +62,10 @@ export type TestJobCustom = {
62
62
  * {@link TestJobCustom.artifacts}.reports.junit is merged with {@link TestJobCustom.artifactsReports} in case both given.
63
63
  */
64
64
  artifacts?: Artifacts;
65
+ /**
66
+ * additional vars for this job runner
67
+ */
68
+ runnerVariables?: Record<string, string>;
65
69
  };
66
70
  export type BuildConfigBase = {
67
71
  /**
@@ -196,6 +200,15 @@ type BuildConfigDockerCustom = {
196
200
  * Depending on your Dockerfile you may want to change it to "component"
197
201
  */
198
202
  buildContextLocation?: "root" | "component";
203
+ /**
204
+ * EXPERIMENTAL: custom docker file content
205
+ *
206
+ * you can use some predefined variables:
207
+ * - $DOCKER_COPY_WORKSPACE_FILES
208
+ * - $DOCKER_COPY_AND_INSTALL_APP
209
+ * - and all default variables
210
+ */
211
+ dockerfileContent?: string[];
199
212
  };
200
213
  export type BuildConfigDocker = BuildConfigDockerBuiltIn | BuildConfigDockerCustom;
201
214
  export type BuildConfigCustom = Omit<BuildConfigBase, "lint" | "test" | "audit"> & {
@@ -329,7 +342,7 @@ export type WorkspaceBuildConfigBase = {
329
342
  */
330
343
  audit?: false | TestJobCustom;
331
344
  /**
332
- * additional vars only for the runner.
345
+ * additional vars only for the build job.
333
346
  * Also if you use services: that require env vars, you need to set them here.
334
347
  *
335
348
  */
@@ -151,13 +151,14 @@ Object.defineProperty(exports, "__esModule", {
151
151
  });
152
152
  exports.readConfig = void 0;
153
153
  var fs_1 = require("fs");
154
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
154
155
  var tsx = require("tsx/cjs/api");
155
156
  var yaml_1 = require("yaml");
156
157
  // allows us to load ts files
157
158
  var fullPath = function (directory, ext) {
158
159
  return directory + "/catladder." + ext;
159
160
  };
160
- var readConfig = function () {
161
+ var readConfigInternal = function () {
161
162
  var args_1 = [];
162
163
  for (var _i = 0; _i < arguments.length; _i++) {
163
164
  args_1[_i] = arguments[_i];
@@ -199,4 +200,32 @@ var readConfig = function () {
199
200
  });
200
201
  });
201
202
  };
203
+ var readConfig = function () {
204
+ var args_1 = [];
205
+ for (var _i = 0; _i < arguments.length; _i++) {
206
+ args_1[_i] = arguments[_i];
207
+ }
208
+ return __awaiter(void 0, __spreadArray([], __read(args_1), false), void 0, function (directory) {
209
+ var error_1;
210
+ if (directory === void 0) {
211
+ directory = process.cwd();
212
+ }
213
+ return __generator(this, function (_a) {
214
+ switch (_a.label) {
215
+ case 0:
216
+ _a.trys.push([0, 2,, 3]);
217
+ return [4 /*yield*/, readConfigInternal(directory)];
218
+ case 1:
219
+ return [2 /*return*/, _a.sent()];
220
+ case 2:
221
+ error_1 = _a.sent();
222
+ console.error("Error reading config in ".concat(directory, ":"), error_1);
223
+ console.error("\nThis may happen due to various reasons:\n - Syntax errors in your catladder.ts file\n - tsx (the TypeScript loader used by catladder) needs to understand the syntax in your project.\n If your project uses newer TypeScript/JavaScript syntax, you may need to update catladder\n to get a newer version of tsx that supports it.\n - Missing or incorrect dependencies in your project\n - TypeScript configuration issues in your tsconfig.json\n");
224
+ return [2 /*return*/, null];
225
+ case 3:
226
+ return [2 /*return*/];
227
+ }
228
+ });
229
+ });
230
+ };
202
231
  exports.readConfig = readConfig;
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-30-5-116bf090" || "latest";
7
+ exports.PIPELINE_IMAGE_TAG = "v3-32-0-6cdca903" || "latest";
8
8
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";