@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.
- package/dist/build/custom/testJob.js +13 -11
- package/dist/build/docker.d.ts +1 -1
- package/dist/build/docker.js +16 -4
- package/dist/build/node/testJob.js +13 -11
- package/dist/build/types.d.ts +14 -1
- package/dist/config/readConfig.js +30 -1
- package/dist/constants.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/__snapshots__/custom-docker-file.test.ts.snap +1640 -0
- package/examples/custom-docker-file.test.ts +12 -0
- package/examples/custom-docker-file.ts +36 -0
- package/package.json +2 -2
- package/src/build/custom/testJob.ts +12 -1
- package/src/build/docker.ts +26 -6
- package/src/build/node/testJob.ts +12 -2
- package/src/build/types.ts +16 -1
- package/src/config/readConfig.ts +22 -1
|
@@ -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
|
-
|
|
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)((
|
|
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, (
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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;
|
package/dist/build/docker.d.ts
CHANGED
|
@@ -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,
|
|
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;
|
package/dist/build/docker.js
CHANGED
|
@@ -168,10 +168,22 @@ var BUILT_IN_ENSURE_DOCKERFILE_SCRIPTS = {
|
|
|
168
168
|
nginx: "ensureNginxDockerfile",
|
|
169
169
|
custom: null
|
|
170
170
|
};
|
|
171
|
-
var
|
|
172
|
-
var _a;
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
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((
|
|
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, (
|
|
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
|
-
|
|
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((
|
|
93
|
-
}), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (
|
|
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
|
-
|
|
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((
|
|
100
|
-
}), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (
|
|
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;
|
package/dist/build/types.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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-
|
|
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";
|