@catladder/pipeline 0.0.0-refactor-needs-aae6e67d → 0.0.0-refactor-gitlab-jobs-a7359bde
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/bundles/catladder-gitlab/index.js +398 -158
- package/dist/constants.js +1 -1
- package/dist/pipeline/createAllJobs.d.ts +8 -0
- package/dist/pipeline/createAllJobs.js +164 -0
- package/dist/pipeline/createChildPipeline.js +24 -48
- package/dist/pipeline/createJobsForComponent.d.ts +3 -0
- package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +8 -100
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +14 -0
- package/dist/pipeline/gitlab/createGitlabJobs.js +260 -0
- package/dist/pipeline/index.d.ts +1 -1
- package/dist/pipeline/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/pipeline/createAllJobs.ts +38 -0
- package/src/pipeline/createChildPipeline.ts +6 -22
- package/src/pipeline/createJobsForComponent.ts +64 -0
- package/src/pipeline/gitlab/createGitlabJobs.ts +149 -0
- package/src/pipeline/index.ts +1 -1
- package/dist/pipeline/createJobs.d.ts +0 -3
- package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -10
- package/dist/pipeline/gitlab/makeGitlabJob.js +0 -75
- package/src/pipeline/createJobs.ts +0 -196
- package/src/pipeline/gitlab/makeGitlabJob.ts +0 -25
|
@@ -28350,7 +28350,7 @@ exports.readConfigSync = readConfigSync;
|
|
|
28350
28350
|
|
|
28351
28351
|
exports.__esModule = true;
|
|
28352
28352
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
28353
|
-
exports.PIPELINE_IMAGE_TAG = "refactor-
|
|
28353
|
+
exports.PIPELINE_IMAGE_TAG = "refactor-gitlab-jobs-a7359bde" || 0;
|
|
28354
28354
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
|
|
28355
28355
|
|
|
28356
28356
|
/***/ }),
|
|
@@ -31246,22 +31246,183 @@ exports.getBaseCommitInfo = getBaseCommitInfo;
|
|
|
31246
31246
|
|
|
31247
31247
|
/***/ }),
|
|
31248
31248
|
|
|
31249
|
-
/***/
|
|
31249
|
+
/***/ 6579:
|
|
31250
31250
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
31251
31251
|
|
|
31252
31252
|
"use strict";
|
|
31253
31253
|
|
|
31254
31254
|
|
|
31255
|
-
var
|
|
31256
|
-
|
|
31257
|
-
|
|
31258
|
-
|
|
31259
|
-
|
|
31255
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
31256
|
+
function adopt(value) {
|
|
31257
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
31258
|
+
resolve(value);
|
|
31259
|
+
});
|
|
31260
|
+
}
|
|
31261
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31262
|
+
function fulfilled(value) {
|
|
31263
|
+
try {
|
|
31264
|
+
step(generator.next(value));
|
|
31265
|
+
} catch (e) {
|
|
31266
|
+
reject(e);
|
|
31267
|
+
}
|
|
31260
31268
|
}
|
|
31261
|
-
|
|
31262
|
-
|
|
31263
|
-
|
|
31269
|
+
function rejected(value) {
|
|
31270
|
+
try {
|
|
31271
|
+
step(generator["throw"](value));
|
|
31272
|
+
} catch (e) {
|
|
31273
|
+
reject(e);
|
|
31274
|
+
}
|
|
31275
|
+
}
|
|
31276
|
+
function step(result) {
|
|
31277
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
31278
|
+
}
|
|
31279
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
31280
|
+
});
|
|
31281
|
+
};
|
|
31282
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
31283
|
+
var _ = {
|
|
31284
|
+
label: 0,
|
|
31285
|
+
sent: function () {
|
|
31286
|
+
if (t[0] & 1) throw t[1];
|
|
31287
|
+
return t[1];
|
|
31288
|
+
},
|
|
31289
|
+
trys: [],
|
|
31290
|
+
ops: []
|
|
31291
|
+
},
|
|
31292
|
+
f,
|
|
31293
|
+
y,
|
|
31294
|
+
t,
|
|
31295
|
+
g;
|
|
31296
|
+
return g = {
|
|
31297
|
+
next: verb(0),
|
|
31298
|
+
"throw": verb(1),
|
|
31299
|
+
"return": verb(2)
|
|
31300
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
31301
|
+
return this;
|
|
31302
|
+
}), g;
|
|
31303
|
+
function verb(n) {
|
|
31304
|
+
return function (v) {
|
|
31305
|
+
return step([n, v]);
|
|
31306
|
+
};
|
|
31307
|
+
}
|
|
31308
|
+
function step(op) {
|
|
31309
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31310
|
+
while (_) try {
|
|
31311
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
31312
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31313
|
+
switch (op[0]) {
|
|
31314
|
+
case 0:
|
|
31315
|
+
case 1:
|
|
31316
|
+
t = op;
|
|
31317
|
+
break;
|
|
31318
|
+
case 4:
|
|
31319
|
+
_.label++;
|
|
31320
|
+
return {
|
|
31321
|
+
value: op[1],
|
|
31322
|
+
done: false
|
|
31323
|
+
};
|
|
31324
|
+
case 5:
|
|
31325
|
+
_.label++;
|
|
31326
|
+
y = op[1];
|
|
31327
|
+
op = [0];
|
|
31328
|
+
continue;
|
|
31329
|
+
case 7:
|
|
31330
|
+
op = _.ops.pop();
|
|
31331
|
+
_.trys.pop();
|
|
31332
|
+
continue;
|
|
31333
|
+
default:
|
|
31334
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
31335
|
+
_ = 0;
|
|
31336
|
+
continue;
|
|
31337
|
+
}
|
|
31338
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
31339
|
+
_.label = op[1];
|
|
31340
|
+
break;
|
|
31341
|
+
}
|
|
31342
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
31343
|
+
_.label = t[1];
|
|
31344
|
+
t = op;
|
|
31345
|
+
break;
|
|
31346
|
+
}
|
|
31347
|
+
if (t && _.label < t[2]) {
|
|
31348
|
+
_.label = t[2];
|
|
31349
|
+
_.ops.push(op);
|
|
31350
|
+
break;
|
|
31351
|
+
}
|
|
31352
|
+
if (t[2]) _.ops.pop();
|
|
31353
|
+
_.trys.pop();
|
|
31354
|
+
continue;
|
|
31355
|
+
}
|
|
31356
|
+
op = body.call(thisArg, _);
|
|
31357
|
+
} catch (e) {
|
|
31358
|
+
op = [6, e];
|
|
31359
|
+
y = 0;
|
|
31360
|
+
} finally {
|
|
31361
|
+
f = t = 0;
|
|
31362
|
+
}
|
|
31363
|
+
if (op[0] & 5) throw op[1];
|
|
31364
|
+
return {
|
|
31365
|
+
value: op[0] ? op[1] : void 0,
|
|
31366
|
+
done: true
|
|
31367
|
+
};
|
|
31368
|
+
}
|
|
31264
31369
|
};
|
|
31370
|
+
exports.__esModule = true;
|
|
31371
|
+
exports.createAllJobs = void 0;
|
|
31372
|
+
var config_1 = __nccwpck_require__(8906);
|
|
31373
|
+
var createJobsForComponent_1 = __nccwpck_require__(5327);
|
|
31374
|
+
var createAllJobs = function (config, trigger) {
|
|
31375
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
31376
|
+
var _a, _b;
|
|
31377
|
+
return __generator(this, function (_c) {
|
|
31378
|
+
switch (_c.label) {
|
|
31379
|
+
case 0:
|
|
31380
|
+
_b = (_a = Object).fromEntries;
|
|
31381
|
+
return [4 /*yield*/, Promise.all(Object.keys(config.components).map(function (componentName) {
|
|
31382
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
31383
|
+
var envs, _a, _b, _c;
|
|
31384
|
+
return __generator(this, function (_d) {
|
|
31385
|
+
switch (_d.label) {
|
|
31386
|
+
case 0:
|
|
31387
|
+
envs = (0, config_1.getAllEnvsByTrigger)(config, componentName, trigger);
|
|
31388
|
+
_a = [componentName];
|
|
31389
|
+
_c = (_b = Object).fromEntries;
|
|
31390
|
+
return [4 /*yield*/, Promise.all(envs.map(function (env) {
|
|
31391
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
31392
|
+
var _a;
|
|
31393
|
+
return __generator(this, function (_b) {
|
|
31394
|
+
switch (_b.label) {
|
|
31395
|
+
case 0:
|
|
31396
|
+
_a = [env];
|
|
31397
|
+
return [4 /*yield*/, (0, createJobsForComponent_1.createJobsForComponent)(config, componentName, env, trigger)];
|
|
31398
|
+
case 1:
|
|
31399
|
+
return [2 /*return*/, _a.concat([_b.sent()])];
|
|
31400
|
+
}
|
|
31401
|
+
});
|
|
31402
|
+
});
|
|
31403
|
+
}))];
|
|
31404
|
+
case 1:
|
|
31405
|
+
return [2 /*return*/, _a.concat([_c.apply(_b, [_d.sent()])])];
|
|
31406
|
+
}
|
|
31407
|
+
});
|
|
31408
|
+
});
|
|
31409
|
+
}))];
|
|
31410
|
+
case 1:
|
|
31411
|
+
return [2 /*return*/, _b.apply(_a, [_c.sent()])];
|
|
31412
|
+
}
|
|
31413
|
+
});
|
|
31414
|
+
});
|
|
31415
|
+
};
|
|
31416
|
+
exports.createAllJobs = createAllJobs;
|
|
31417
|
+
|
|
31418
|
+
/***/ }),
|
|
31419
|
+
|
|
31420
|
+
/***/ 4244:
|
|
31421
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
31422
|
+
|
|
31423
|
+
"use strict";
|
|
31424
|
+
|
|
31425
|
+
|
|
31265
31426
|
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
31266
31427
|
function adopt(value) {
|
|
31267
31428
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -31414,54 +31575,40 @@ var config_1 = __nccwpck_require__(8906);
|
|
|
31414
31575
|
var rules_1 = __nccwpck_require__(1410);
|
|
31415
31576
|
var runner_1 = __nccwpck_require__(7666);
|
|
31416
31577
|
var jobs_1 = __nccwpck_require__(9072);
|
|
31417
|
-
var
|
|
31578
|
+
var createAllJobs_1 = __nccwpck_require__(6579);
|
|
31579
|
+
var createGitlabJobs_1 = __nccwpck_require__(5569);
|
|
31418
31580
|
var createChildPipeline = function (type, trigger, config) {
|
|
31419
31581
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
31420
|
-
var
|
|
31421
|
-
|
|
31422
|
-
|
|
31582
|
+
var jobs, allEnvs, stages, pipeline;
|
|
31583
|
+
var _a;
|
|
31584
|
+
return __generator(this, function (_b) {
|
|
31585
|
+
switch (_b.label) {
|
|
31423
31586
|
case 0:
|
|
31424
|
-
|
|
31425
|
-
return [4 /*yield*/, components.reduce(function (acc, componentName) {
|
|
31426
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
31427
|
-
var envs, _a, _b;
|
|
31428
|
-
return __generator(this, function (_c) {
|
|
31429
|
-
switch (_c.label) {
|
|
31430
|
-
case 0:
|
|
31431
|
-
envs = (0, config_1.getAllEnvsByTrigger)(config, componentName, trigger);
|
|
31432
|
-
_a = [{}];
|
|
31433
|
-
return [4 /*yield*/, acc];
|
|
31434
|
-
case 1:
|
|
31435
|
-
_b = [__assign.apply(void 0, _a.concat([_c.sent()]))];
|
|
31436
|
-
return [4 /*yield*/, (0, createJobs_1.createJobs)(type, envs, config, componentName, trigger)];
|
|
31437
|
-
case 2:
|
|
31438
|
-
return [2 /*return*/, __assign.apply(void 0, _b.concat([_c.sent()]))];
|
|
31439
|
-
}
|
|
31440
|
-
});
|
|
31441
|
-
});
|
|
31442
|
-
}, Promise.resolve({}))];
|
|
31587
|
+
return [4 /*yield*/, (0, createAllJobs_1.createAllJobs)(config, trigger)];
|
|
31443
31588
|
case 1:
|
|
31444
|
-
jobs =
|
|
31589
|
+
jobs = _b.sent();
|
|
31445
31590
|
allEnvs = (0, config_1.getAllEnvsInAllComponents)(config);
|
|
31446
31591
|
stages = jobs_1.BASE_STAGES.reduce(function (acc, baseStage) {
|
|
31447
31592
|
return __spreadArray(__spreadArray(__spreadArray([], __read(acc), false), [baseStage], false), __read(allEnvs.map(function (e) {
|
|
31448
31593
|
return "".concat(baseStage, " ").concat(e);
|
|
31449
31594
|
})), false);
|
|
31450
31595
|
}, []);
|
|
31451
|
-
if (type === "gitlab")
|
|
31452
|
-
|
|
31453
|
-
|
|
31454
|
-
|
|
31455
|
-
|
|
31456
|
-
|
|
31457
|
-
|
|
31458
|
-
|
|
31459
|
-
|
|
31460
|
-
|
|
31461
|
-
|
|
31462
|
-
|
|
31463
|
-
|
|
31464
|
-
|
|
31596
|
+
if (!(type === "gitlab")) return [3 /*break*/, 3];
|
|
31597
|
+
_a = {
|
|
31598
|
+
image: (0, runner_1.getRunnerImage)("jobs-default"),
|
|
31599
|
+
variables: {
|
|
31600
|
+
FF_USE_FASTZIP: "true"
|
|
31601
|
+
},
|
|
31602
|
+
workflow: {
|
|
31603
|
+
rules: rules_1.RULES_ALWAYS
|
|
31604
|
+
},
|
|
31605
|
+
stages: stages
|
|
31606
|
+
};
|
|
31607
|
+
return [4 /*yield*/, (0, createGitlabJobs_1.createGitlabJobs)(jobs)];
|
|
31608
|
+
case 2:
|
|
31609
|
+
pipeline = (_a.jobs = _b.sent(), _a);
|
|
31610
|
+
return [2 /*return*/, pipeline];
|
|
31611
|
+
case 3:
|
|
31465
31612
|
throw new Error("".concat(type, " is not supported"));
|
|
31466
31613
|
}
|
|
31467
31614
|
});
|
|
@@ -31471,7 +31618,7 @@ exports.createChildPipeline = createChildPipeline;
|
|
|
31471
31618
|
|
|
31472
31619
|
/***/ }),
|
|
31473
31620
|
|
|
31474
|
-
/***/
|
|
31621
|
+
/***/ 5327:
|
|
31475
31622
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
31476
31623
|
|
|
31477
31624
|
"use strict";
|
|
@@ -31642,14 +31789,12 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
31642
31789
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31643
31790
|
};
|
|
31644
31791
|
exports.__esModule = true;
|
|
31645
|
-
exports.
|
|
31792
|
+
exports.createJobsForComponent = void 0;
|
|
31646
31793
|
var lodash_1 = __nccwpck_require__(3255);
|
|
31647
31794
|
var build_1 = __nccwpck_require__(2004);
|
|
31648
31795
|
var context_1 = __nccwpck_require__(7123);
|
|
31649
31796
|
var deploy_1 = __nccwpck_require__(1264);
|
|
31650
|
-
var utils_1 = __nccwpck_require__(1815);
|
|
31651
31797
|
var getCommitInfo_1 = __nccwpck_require__(802);
|
|
31652
|
-
var makeGitlabJob_1 = __nccwpck_require__(726);
|
|
31653
31798
|
var packageManager_1 = __nccwpck_require__(3214);
|
|
31654
31799
|
var injectDefaultVarsInCustomJobs = function (context, jobs) {
|
|
31655
31800
|
return jobs.map(function (_a) {
|
|
@@ -31677,71 +31822,9 @@ var createRawJobs = function (context) {
|
|
|
31677
31822
|
var customJobs = getCustomJobs(context);
|
|
31678
31823
|
return __spreadArray(__spreadArray(__spreadArray([], __read(buildJobs), false), __read(deployJobs), false), __read(customJobs), false);
|
|
31679
31824
|
};
|
|
31680
|
-
var
|
|
31681
|
-
if (env) {
|
|
31682
|
-
return "".concat(componentName, " ").concat(name, " | ").concat(env, " ");
|
|
31683
|
-
}
|
|
31684
|
-
return "".concat(componentName, " ").concat(name);
|
|
31685
|
-
};
|
|
31686
|
-
var getFullReferencedJobName = function (referencedJobName, componentName, env, allRawJobs) {
|
|
31687
|
-
var referencedJob = allRawJobs.find(function (j) {
|
|
31688
|
-
return j.name === referencedJobName;
|
|
31689
|
-
});
|
|
31690
|
-
if (!referencedJob) {
|
|
31691
|
-
throw new Error("unknown job referenced: " + referencedJobName);
|
|
31692
|
-
}
|
|
31693
|
-
var envToSet = referencedJob.envMode !== "none" ? env : null;
|
|
31694
|
-
return getFullJobName(referencedJobName, componentName, envToSet);
|
|
31695
|
-
};
|
|
31696
|
-
// replaces references to other jobs with the full name
|
|
31697
|
-
// the full name contains the componentname and the env name (if any)
|
|
31698
|
-
var replaceReferences = function (job, componentName, env, allRawJobs) {
|
|
31699
|
-
var _a, _b, _c;
|
|
31700
|
-
var stage = job.envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
|
|
31701
|
-
var cleanedNeeds = __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read((_b = job.needsOtherComponent) !== null && _b !== void 0 ? _b : []), false);
|
|
31702
|
-
var needs = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
|
|
31703
|
-
var _a;
|
|
31704
|
-
return (0, lodash_1.isObject)(n) ? {
|
|
31705
|
-
job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allRawJobs),
|
|
31706
|
-
artifacts: n.artifacts
|
|
31707
|
-
} : getFullReferencedJobName(n, componentName, env, allRawJobs);
|
|
31708
|
-
});
|
|
31709
|
-
return __assign(__assign({}, job), {
|
|
31710
|
-
stage: stage,
|
|
31711
|
-
needs: needs,
|
|
31712
|
-
environment: ((_c = job.environment) === null || _c === void 0 ? void 0 : _c.on_stop) ? __assign(__assign({}, job.environment), {
|
|
31713
|
-
on_stop: getFullReferencedJobName(job.environment.on_stop, componentName, env, allRawJobs)
|
|
31714
|
-
}) : job.environment
|
|
31715
|
-
});
|
|
31716
|
-
};
|
|
31717
|
-
// this can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/220758 is resolved
|
|
31718
|
-
var addStageNeeds = function (jobs) {
|
|
31719
|
-
// when a job defines needsStages, we add these as needs
|
|
31720
|
-
return jobs.map(function (job) {
|
|
31721
|
-
var _a;
|
|
31722
|
-
if (!job.needsStages || job.needsStages.length === 0) {
|
|
31723
|
-
return job;
|
|
31724
|
-
}
|
|
31725
|
-
var neededJobs = jobs.map(function (j) {
|
|
31726
|
-
var _a, _b;
|
|
31727
|
-
var neededStage = (_a = job.needsStages) === null || _a === void 0 ? void 0 : _a.find(function (s) {
|
|
31728
|
-
return j.stage === s.stage;
|
|
31729
|
-
});
|
|
31730
|
-
if (neededStage) {
|
|
31731
|
-
return {
|
|
31732
|
-
job: j.name,
|
|
31733
|
-
artifacts: (_b = neededStage.artifacts) !== null && _b !== void 0 ? _b : false
|
|
31734
|
-
};
|
|
31735
|
-
}
|
|
31736
|
-
}).filter(utils_1.notNil);
|
|
31737
|
-
return __assign(__assign({}, job), {
|
|
31738
|
-
needs: __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read(neededJobs), false)
|
|
31739
|
-
});
|
|
31740
|
-
});
|
|
31741
|
-
};
|
|
31742
|
-
var createJobs = function (type, envs, config, componentName, trigger) {
|
|
31825
|
+
var createJobsForComponent = function (config, componentName, env, trigger) {
|
|
31743
31826
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
31744
|
-
var commitInfo, _a, packageManagerInfo;
|
|
31827
|
+
var commitInfo, _a, packageManagerInfo, context;
|
|
31745
31828
|
return __generator(this, function (_b) {
|
|
31746
31829
|
switch (_b.label) {
|
|
31747
31830
|
case 0:
|
|
@@ -31754,47 +31837,19 @@ var createJobs = function (type, envs, config, componentName, trigger) {
|
|
|
31754
31837
|
return [4 /*yield*/, (0, packageManager_1.getPackageManagerInfo)(config, componentName)];
|
|
31755
31838
|
case 2:
|
|
31756
31839
|
packageManagerInfo = _b.sent();
|
|
31757
|
-
return [
|
|
31758
|
-
|
|
31759
|
-
|
|
31760
|
-
|
|
31761
|
-
switch (_f.label) {
|
|
31762
|
-
case 0:
|
|
31763
|
-
return [4 /*yield*/, (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
|
|
31764
|
-
case 1:
|
|
31765
|
-
context = _f.sent();
|
|
31766
|
-
jobs = addStageNeeds(createRawJobs(context));
|
|
31767
|
-
_a = [{}];
|
|
31768
|
-
return [4 /*yield*/, acc];
|
|
31769
|
-
case 2:
|
|
31770
|
-
_b = [__assign.apply(void 0, _a.concat([_f.sent()]))];
|
|
31771
|
-
_d = (_c = jobs).reduce;
|
|
31772
|
-
_e = [function (acc, job) {
|
|
31773
|
-
var _a;
|
|
31774
|
-
var jobWithResolvedReferences = replaceReferences(job, componentName, env, jobs);
|
|
31775
|
-
var jobName = getFullJobName(job.name, componentName, job.envMode !== "none" ? env : undefined);
|
|
31776
|
-
if (type === "gitlab") {
|
|
31777
|
-
return __assign(__assign({}, acc), (_a = {}, _a[jobName] = (0, makeGitlabJob_1.makeGitlabJob)(jobWithResolvedReferences), _a));
|
|
31778
|
-
}
|
|
31779
|
-
throw new Error("not supported");
|
|
31780
|
-
}];
|
|
31781
|
-
return [4 /*yield*/, Promise.resolve({})];
|
|
31782
|
-
case 3:
|
|
31783
|
-
result = __assign.apply(void 0, _b.concat([_d.apply(_c, _e.concat([_f.sent()]))]));
|
|
31784
|
-
return [2 /*return*/, result];
|
|
31785
|
-
}
|
|
31786
|
-
});
|
|
31787
|
-
});
|
|
31788
|
-
}, {})];
|
|
31840
|
+
return [4 /*yield*/, (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
|
|
31841
|
+
case 3:
|
|
31842
|
+
context = _b.sent();
|
|
31843
|
+
return [2 /*return*/, createRawJobs(context)];
|
|
31789
31844
|
}
|
|
31790
31845
|
});
|
|
31791
31846
|
});
|
|
31792
31847
|
};
|
|
31793
|
-
exports.
|
|
31848
|
+
exports.createJobsForComponent = createJobsForComponent;
|
|
31794
31849
|
|
|
31795
31850
|
/***/ }),
|
|
31796
31851
|
|
|
31797
|
-
/***/
|
|
31852
|
+
/***/ 5569:
|
|
31798
31853
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
31799
31854
|
|
|
31800
31855
|
"use strict";
|
|
@@ -31810,6 +31865,121 @@ var __assign = this && this.__assign || function () {
|
|
|
31810
31865
|
};
|
|
31811
31866
|
return __assign.apply(this, arguments);
|
|
31812
31867
|
};
|
|
31868
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
31869
|
+
function adopt(value) {
|
|
31870
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
31871
|
+
resolve(value);
|
|
31872
|
+
});
|
|
31873
|
+
}
|
|
31874
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31875
|
+
function fulfilled(value) {
|
|
31876
|
+
try {
|
|
31877
|
+
step(generator.next(value));
|
|
31878
|
+
} catch (e) {
|
|
31879
|
+
reject(e);
|
|
31880
|
+
}
|
|
31881
|
+
}
|
|
31882
|
+
function rejected(value) {
|
|
31883
|
+
try {
|
|
31884
|
+
step(generator["throw"](value));
|
|
31885
|
+
} catch (e) {
|
|
31886
|
+
reject(e);
|
|
31887
|
+
}
|
|
31888
|
+
}
|
|
31889
|
+
function step(result) {
|
|
31890
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
31891
|
+
}
|
|
31892
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
31893
|
+
});
|
|
31894
|
+
};
|
|
31895
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
31896
|
+
var _ = {
|
|
31897
|
+
label: 0,
|
|
31898
|
+
sent: function () {
|
|
31899
|
+
if (t[0] & 1) throw t[1];
|
|
31900
|
+
return t[1];
|
|
31901
|
+
},
|
|
31902
|
+
trys: [],
|
|
31903
|
+
ops: []
|
|
31904
|
+
},
|
|
31905
|
+
f,
|
|
31906
|
+
y,
|
|
31907
|
+
t,
|
|
31908
|
+
g;
|
|
31909
|
+
return g = {
|
|
31910
|
+
next: verb(0),
|
|
31911
|
+
"throw": verb(1),
|
|
31912
|
+
"return": verb(2)
|
|
31913
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
31914
|
+
return this;
|
|
31915
|
+
}), g;
|
|
31916
|
+
function verb(n) {
|
|
31917
|
+
return function (v) {
|
|
31918
|
+
return step([n, v]);
|
|
31919
|
+
};
|
|
31920
|
+
}
|
|
31921
|
+
function step(op) {
|
|
31922
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31923
|
+
while (_) try {
|
|
31924
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
31925
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31926
|
+
switch (op[0]) {
|
|
31927
|
+
case 0:
|
|
31928
|
+
case 1:
|
|
31929
|
+
t = op;
|
|
31930
|
+
break;
|
|
31931
|
+
case 4:
|
|
31932
|
+
_.label++;
|
|
31933
|
+
return {
|
|
31934
|
+
value: op[1],
|
|
31935
|
+
done: false
|
|
31936
|
+
};
|
|
31937
|
+
case 5:
|
|
31938
|
+
_.label++;
|
|
31939
|
+
y = op[1];
|
|
31940
|
+
op = [0];
|
|
31941
|
+
continue;
|
|
31942
|
+
case 7:
|
|
31943
|
+
op = _.ops.pop();
|
|
31944
|
+
_.trys.pop();
|
|
31945
|
+
continue;
|
|
31946
|
+
default:
|
|
31947
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
31948
|
+
_ = 0;
|
|
31949
|
+
continue;
|
|
31950
|
+
}
|
|
31951
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
31952
|
+
_.label = op[1];
|
|
31953
|
+
break;
|
|
31954
|
+
}
|
|
31955
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
31956
|
+
_.label = t[1];
|
|
31957
|
+
t = op;
|
|
31958
|
+
break;
|
|
31959
|
+
}
|
|
31960
|
+
if (t && _.label < t[2]) {
|
|
31961
|
+
_.label = t[2];
|
|
31962
|
+
_.ops.push(op);
|
|
31963
|
+
break;
|
|
31964
|
+
}
|
|
31965
|
+
if (t[2]) _.ops.pop();
|
|
31966
|
+
_.trys.pop();
|
|
31967
|
+
continue;
|
|
31968
|
+
}
|
|
31969
|
+
op = body.call(thisArg, _);
|
|
31970
|
+
} catch (e) {
|
|
31971
|
+
op = [6, e];
|
|
31972
|
+
y = 0;
|
|
31973
|
+
} finally {
|
|
31974
|
+
f = t = 0;
|
|
31975
|
+
}
|
|
31976
|
+
if (op[0] & 5) throw op[1];
|
|
31977
|
+
return {
|
|
31978
|
+
value: op[0] ? op[1] : void 0,
|
|
31979
|
+
done: true
|
|
31980
|
+
};
|
|
31981
|
+
}
|
|
31982
|
+
};
|
|
31813
31983
|
var __rest = this && this.__rest || function (s, e) {
|
|
31814
31984
|
var t = {};
|
|
31815
31985
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -31850,29 +32020,99 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
31850
32020
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31851
32021
|
};
|
|
31852
32022
|
exports.__esModule = true;
|
|
31853
|
-
exports.makeGitlabJob = void 0;
|
|
32023
|
+
exports.createGitlabJobs = exports.makeGitlabJob = void 0;
|
|
31854
32024
|
var lodash_1 = __nccwpck_require__(3255);
|
|
31855
32025
|
var defaults_1 = __nccwpck_require__(7328);
|
|
32026
|
+
var getFullJobName = function (name, componentName, env) {
|
|
32027
|
+
if (env) {
|
|
32028
|
+
return "".concat(componentName, " ").concat(name, " | ").concat(env, " ");
|
|
32029
|
+
}
|
|
32030
|
+
return "".concat(componentName, " ").concat(name);
|
|
32031
|
+
};
|
|
32032
|
+
var getFullReferencedJobName = function (referencedJobName, componentName, env, allJobs) {
|
|
32033
|
+
var _a, _b;
|
|
32034
|
+
var referencedJob = (_b = (_a = allJobs[componentName]) === null || _a === void 0 ? void 0 : _a[env]) === null || _b === void 0 ? void 0 : _b.find(function (j) {
|
|
32035
|
+
return j.name === referencedJobName;
|
|
32036
|
+
});
|
|
32037
|
+
if (!referencedJob) {
|
|
32038
|
+
throw new Error("unknown job referenced: '".concat(referencedJobName, "' from '").concat(env, ":").concat(componentName, "'"));
|
|
32039
|
+
}
|
|
32040
|
+
var envToSet = referencedJob.envMode !== "none" ? env : null;
|
|
32041
|
+
return getFullJobName(referencedJobName, componentName, envToSet);
|
|
32042
|
+
};
|
|
31856
32043
|
var getJobName = function (need) {
|
|
31857
32044
|
return (0, lodash_1.isObject)(need) ? need.job : need;
|
|
31858
32045
|
};
|
|
31859
|
-
var makeGitlabJob = function (_a) {
|
|
32046
|
+
var makeGitlabJob = function (componentName, env, _a, allJobs) {
|
|
32047
|
+
var _b;
|
|
31860
32048
|
var envMode = _a.envMode,
|
|
31861
32049
|
needsStages = _a.needsStages,
|
|
31862
32050
|
needsOtherComponent = _a.needsOtherComponent,
|
|
31863
32051
|
name = _a.name,
|
|
31864
32052
|
needs = _a.needs,
|
|
31865
|
-
|
|
31866
|
-
|
|
32053
|
+
job = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
|
|
32054
|
+
var stage = envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
|
|
32055
|
+
var needsFromStages = needsStages === null || needsStages === void 0 ? void 0 : needsStages.flatMap(function (n) {
|
|
32056
|
+
var _a, _b, _c, _d;
|
|
32057
|
+
var referencedComponentName = componentName;
|
|
32058
|
+
var allJobNamesFromThatStage = (_d = (_c = (_b = (_a = allJobs[referencedComponentName]) === null || _a === void 0 ? void 0 : _a[env]) === null || _b === void 0 ? void 0 : _b.filter(function (j) {
|
|
32059
|
+
return j.stage === n.stage;
|
|
32060
|
+
})) === null || _c === void 0 ? void 0 : _c.map(function (j) {
|
|
32061
|
+
return j.name;
|
|
32062
|
+
})) !== null && _d !== void 0 ? _d : [];
|
|
32063
|
+
return allJobNamesFromThatStage.map(function (job) {
|
|
32064
|
+
var _a;
|
|
32065
|
+
return {
|
|
32066
|
+
job: job,
|
|
32067
|
+
artifacts: (_a = n.artifacts) !== null && _a !== void 0 ? _a : false,
|
|
32068
|
+
componentName: referencedComponentName
|
|
32069
|
+
};
|
|
32070
|
+
});
|
|
32071
|
+
});
|
|
32072
|
+
var cleanedNeeds = __spreadArray(__spreadArray(__spreadArray([], __read(needs !== null && needs !== void 0 ? needs : []), false), __read(needsOtherComponent !== null && needsOtherComponent !== void 0 ? needsOtherComponent : []), false), __read(needsFromStages !== null && needsFromStages !== void 0 ? needsFromStages : []), false);
|
|
32073
|
+
var gitlabNeeds = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
|
|
32074
|
+
var _a;
|
|
32075
|
+
return (0, lodash_1.isObject)(n) ? {
|
|
32076
|
+
job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allJobs),
|
|
32077
|
+
artifacts: n.artifacts
|
|
32078
|
+
} : getFullReferencedJobName(n, componentName, env, allJobs);
|
|
32079
|
+
}).sort(function (a, b) {
|
|
32080
|
+
return getJobName(a).localeCompare(getJobName(b));
|
|
32081
|
+
});
|
|
32082
|
+
var fullJobName = getFullJobName(name, componentName, envMode !== "none" ? env : undefined);
|
|
32083
|
+
var gitlabJob = __assign(__assign({}, job), {
|
|
32084
|
+
stage: stage,
|
|
32085
|
+
environment: ((_b = job.environment) === null || _b === void 0 ? void 0 : _b.on_stop) ? __assign(__assign({}, job.environment), {
|
|
32086
|
+
on_stop: getFullReferencedJobName(job.environment.on_stop, componentName, env, allJobs)
|
|
32087
|
+
}) : job.environment,
|
|
31867
32088
|
// sort in a predictable manner for snapshot tests
|
|
31868
|
-
needs:
|
|
31869
|
-
return getJobName(a).localeCompare(getJobName(b));
|
|
31870
|
-
}) : undefined,
|
|
32089
|
+
needs: gitlabNeeds,
|
|
31871
32090
|
retry: defaults_1.BASE_RETRY,
|
|
31872
32091
|
interruptible: true
|
|
31873
32092
|
});
|
|
32093
|
+
return [fullJobName, gitlabJob];
|
|
31874
32094
|
};
|
|
31875
32095
|
exports.makeGitlabJob = makeGitlabJob;
|
|
32096
|
+
var createGitlabJobs = function (allJobs) {
|
|
32097
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
32098
|
+
return __generator(this, function (_a) {
|
|
32099
|
+
return [2 /*return*/, Object.keys(allJobs).reduce(function (accForComponents, componentName) {
|
|
32100
|
+
var componentJobs = allJobs[componentName];
|
|
32101
|
+
return __assign(__assign({}, accForComponents), Object.keys(componentJobs).reduce(function (accForEnvs, env) {
|
|
32102
|
+
var jobs = componentJobs[env];
|
|
32103
|
+
return __assign(__assign({}, accForEnvs), jobs.reduce(function (accForJobs, job) {
|
|
32104
|
+
var _a;
|
|
32105
|
+
var _b = __read((0, exports.makeGitlabJob)(componentName, env, job, allJobs), 2),
|
|
32106
|
+
fullJobName = _b[0],
|
|
32107
|
+
gitlabJob = _b[1];
|
|
32108
|
+
return __assign(__assign({}, accForJobs), (_a = {}, _a[fullJobName] = gitlabJob, _a));
|
|
32109
|
+
}, {}));
|
|
32110
|
+
}, {}));
|
|
32111
|
+
}, {})];
|
|
32112
|
+
});
|
|
32113
|
+
});
|
|
32114
|
+
};
|
|
32115
|
+
exports.createGitlabJobs = createGitlabJobs;
|
|
31876
32116
|
|
|
31877
32117
|
/***/ }),
|
|
31878
32118
|
|
|
@@ -31899,7 +32139,7 @@ var __exportStar = this && this.__exportStar || function (m, exports) {
|
|
|
31899
32139
|
};
|
|
31900
32140
|
exports.__esModule = true;
|
|
31901
32141
|
__exportStar(__nccwpck_require__(4244), exports);
|
|
31902
|
-
__exportStar(__nccwpck_require__(
|
|
32142
|
+
__exportStar(__nccwpck_require__(5327), exports);
|
|
31903
32143
|
|
|
31904
32144
|
/***/ }),
|
|
31905
32145
|
|
package/dist/constants.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
5
|
-
exports.PIPELINE_IMAGE_TAG = "refactor-
|
|
5
|
+
exports.PIPELINE_IMAGE_TAG = "refactor-gitlab-jobs-a7359bde" || "";
|
|
6
6
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Config, PipelineTrigger } from "../types";
|
|
2
|
+
import type { CatladderJob } from "../types/jobs";
|
|
3
|
+
export declare type AllCatladderJobs = {
|
|
4
|
+
[componentName: string]: {
|
|
5
|
+
[env: string]: Array<CatladderJob>;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare const createAllJobs: (config: Config, trigger: PipelineTrigger) => Promise<AllCatladderJobs>;
|