@catladder/cli
Version:
Panter cli tool for cloud CI/CD and DevOps
68 lines โข 3.5 kB
JavaScript
;
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;
// 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,
},
runnerVariables: RUNNER_CUSTOM_TEST_VARIABLES,
services: buildConfig.jobServices,
cache: (0, createJobCache_1.createJobCacheFromConfig)(context, buildConfig),
stage: "test",
needs: [],
envMode: "none",
};
const auditJob = buildConfig.audit
? {
name: "๐ก audit",
...base,
image: (_b = (_a = buildConfig.audit) === null || _a === void 0 ? void 0 : _a.jobImage) !== null && _b !== void 0 ? _b : buildConfig.jobImage,
cache: undefined,
script: [...(0, utils_1.ensureArray)((_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.command)],
allow_failure: true,
...(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;
const lintJob = buildConfig.lint
? {
name: "๐ฎ lint",
...base,
image: (_g = (_f = buildConfig.lint) === null || _f === void 0 ? void 0 : _f.jobImage) !== null && _g !== void 0 ? _g : buildConfig.jobImage,
script: [...(0, utils_1.ensureArray)((_h = buildConfig.lint) === null || _h === void 0 ? void 0 : _h.command)],
...(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;
const testJob = buildConfig.test
? {
name: "๐งช test",
...base,
image: (_m = (_l = buildConfig.test) === null || _l === void 0 ? void 0 : _l.jobImage) !== null && _m !== void 0 ? _m : buildConfig.jobImage,
script: [...(0, utils_1.ensureArray)((_o = buildConfig.test) === null || _o === void 0 ? void 0 : _o.command)],
...(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;
return [auditJob, lintJob, testJob].filter(utils_1.notNil);
};
exports.createCustomTestJobs = createCustomTestJobs;
//# sourceMappingURL=testJob.js.map