@catladder/pipeline
Version:
Panter workflow for cloud CI/CD and DevOps
101 lines (100 loc) โข 4.48 kB
JavaScript
;
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __read = this && this.__read || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o),
r,
ar = [],
e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
} catch (error) {
e = {
error: error
};
} finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
} finally {
if (e) throw e.error;
}
}
return ar;
};
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createCustomTestJobs = void 0;
var utils_1 = require("../../utils");
var createArtifactsConfig_1 = require("../base/createArtifactsConfig");
var createJobCache_1 = require("../cache/createJobCache");
var types_1 = require("../types");
var RUNNER_CUSTOM_TEST_VARIABLES = {
KUBERNETES_CPU_REQUEST: "0.45",
KUBERNETES_MEMORY_REQUEST: "1Gi",
KUBERNETES_MEMORY_LIMIT: "4Gi"
};
var createCustomTestJobs = function (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 [];
}
var buildConfig = context.build.config;
if (!(0, types_1.isOfBuildType)(buildConfig, "custom")) {
throw new Error("deploy config is not custom");
}
var base = {
variables: __assign({
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"
};
var auditJob = buildConfig.audit ? __assign(__assign(__assign({
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: __spreadArray([], __read((0, utils_1.ensureArray)((_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.command)), false),
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;
var lintJob = buildConfig.lint ? __assign(__assign(__assign({
name: "๐ฎ lint"
}, base), {
image: (_g = (_f = buildConfig.lint) === null || _f === void 0 ? void 0 : _f.jobImage) !== null && _g !== void 0 ? _g : buildConfig.jobImage,
script: __spreadArray([], __read((0, utils_1.ensureArray)((_h = buildConfig.lint) === null || _h === void 0 ? void 0 : _h.command)), false)
}), (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;
var testJob = buildConfig.test ? __assign(__assign(__assign({
name: "๐งช test"
}, base), {
image: (_m = (_l = buildConfig.test) === null || _l === void 0 ? void 0 : _l.jobImage) !== null && _m !== void 0 ? _m : buildConfig.jobImage,
script: __spreadArray([], __read((0, utils_1.ensureArray)((_o = buildConfig.test) === null || _o === void 0 ? void 0 : _o.command)), false)
}), (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;