UNPKG

@catladder/cli

Version:

Panter cli tool for cloud CI/CD and DevOps

78 lines โ€ข 4.17 kB
"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; // 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: true, ...(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; const lintJob = buildConfig.lint ? { name: "๐Ÿ‘ฎ lint", ...base, runnerVariables: { ...RUNNER_CUSTOM_TEST_VARIABLES, ...((_j = (_h = buildConfig.lint) === null || _h === void 0 ? void 0 : _h.runnerVariables) !== null && _j !== void 0 ? _j : {}), }, image: (_l = (_k = buildConfig.lint) === null || _k === void 0 ? void 0 : _k.jobImage) !== null && _l !== void 0 ? _l : buildConfig.jobImage, script: [...(0, utils_1.ensureArray)((_m = buildConfig.lint) === null || _m === void 0 ? void 0 : _m.command)], ...(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; const testJob = buildConfig.test ? { name: "๐Ÿงช test", ...base, runnerVariables: { ...RUNNER_CUSTOM_TEST_VARIABLES, ...((_r = (_q = buildConfig.test) === null || _q === void 0 ? void 0 : _q.runnerVariables) !== null && _r !== void 0 ? _r : {}), }, image: (_t = (_s = buildConfig.test) === null || _s === void 0 ? void 0 : _s.jobImage) !== null && _t !== void 0 ? _t : buildConfig.jobImage, script: [...(0, utils_1.ensureArray)((_u = buildConfig.test) === null || _u === void 0 ? void 0 : _u.command)], ...(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; return [auditJob, lintJob, testJob].filter(utils_1.notNil); }; exports.createCustomTestJobs = createCustomTestJobs; //# sourceMappingURL=testJob.js.map