@catladder/cli
Version:
Panter cli tool for cloud CI/CD and DevOps
76 lines (75 loc) โข 4.06 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createCustomTestJobs = void 0;
const utils_1 = require("../../utils");
const createArtifactsConfig_1 = require("../base/createArtifactsConfig");
const createJobCache_1 = require("../cache/createJobCache");
const types_1 = require("../types");
const RUNNER_CUSTOM_TEST_VARIABLES = {
KUBERNETES_CPU_REQUEST: "0.45",
KUBERNETES_MEMORY_REQUEST: "1Gi",
KUBERNETES_MEMORY_LIMIT: "4Gi"
};
const createCustomTestJobs = context => {
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, _0;
// don't run tests after release
// TODO: this will be replaced by using rules
if (context.trigger === "taggedRelease") {
return [];
}
const buildConfig = context.build.config;
if (!(0, types_1.isOfBuildType)(buildConfig, "custom")) {
throw new Error("deploy config is not custom");
}
const base = {
variables: {
APP_PATH: context.build.dir,
...context.environment.jobOnlyVars.build.envVars
},
services: buildConfig.jobServices,
cache: (0, createJobCache_1.createJobCacheFromConfig)(context, buildConfig),
stage: "test",
needs: []
};
const auditJob = buildConfig.audit ? {
name: "๐ก audit",
...base,
runnerVariables: {
...RUNNER_CUSTOM_TEST_VARIABLES,
...((_b = (_a = buildConfig.audit) === null || _a === void 0 ? void 0 : _a.runnerVariables) !== null && _b !== void 0 ? _b : {})
},
image: (_d = (_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.jobImage) !== null && _d !== void 0 ? _d : buildConfig.jobImage,
cache: undefined,
script: [...(0, utils_1.ensureArray)((_e = buildConfig.audit) === null || _e === void 0 ? void 0 : _e.command)],
allow_failure: (_g = (_f = buildConfig.audit) === null || _f === void 0 ? void 0 : _f.allowFailure) !== null && _g !== void 0 ? _g : true,
...(0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_h = buildConfig.audit) === null || _h === void 0 ? void 0 : _h.artifactsReports, (_j = buildConfig.audit) === null || _j === void 0 ? void 0 : _j.artifacts)
} : null;
const lintJob = buildConfig.lint ? {
name: "๐ฎ lint",
...base,
runnerVariables: {
...RUNNER_CUSTOM_TEST_VARIABLES,
...((_l = (_k = buildConfig.lint) === null || _k === void 0 ? void 0 : _k.runnerVariables) !== null && _l !== void 0 ? _l : {})
},
image: (_o = (_m = buildConfig.lint) === null || _m === void 0 ? void 0 : _m.jobImage) !== null && _o !== void 0 ? _o : buildConfig.jobImage,
script: [...(0, utils_1.ensureArray)((_p = buildConfig.lint) === null || _p === void 0 ? void 0 : _p.command)],
allow_failure: (_q = buildConfig.lint) === null || _q === void 0 ? void 0 : _q.allowFailure,
...(0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_r = buildConfig.lint) === null || _r === void 0 ? void 0 : _r.artifactsReports, (_s = buildConfig.lint) === null || _s === void 0 ? void 0 : _s.artifacts)
} : null;
const testJob = buildConfig.test ? {
name: "๐งช test",
...base,
runnerVariables: {
...RUNNER_CUSTOM_TEST_VARIABLES,
...((_u = (_t = buildConfig.test) === null || _t === void 0 ? void 0 : _t.runnerVariables) !== null && _u !== void 0 ? _u : {})
},
image: (_w = (_v = buildConfig.test) === null || _v === void 0 ? void 0 : _v.jobImage) !== null && _w !== void 0 ? _w : buildConfig.jobImage,
script: [...(0, utils_1.ensureArray)((_x = buildConfig.test) === null || _x === void 0 ? void 0 : _x.command)],
allow_failure: (_y = buildConfig.test) === null || _y === void 0 ? void 0 : _y.allowFailure,
...(0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_z = buildConfig.test) === null || _z === void 0 ? void 0 : _z.artifactsReports, (_0 = buildConfig.test) === null || _0 === void 0 ? void 0 : _0.artifacts)
} : null;
return [auditJob, lintJob, testJob].filter(utils_1.notNil);
};
exports.createCustomTestJobs = createCustomTestJobs;