@catladder/pipeline 1.153.0 → 1.154.0
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/build/artifacts/createBuildJobArtifact.d.ts +3 -0
- package/dist/build/artifacts/createBuildJobArtifact.js +97 -0
- package/dist/build/base/createAppBuildJob.d.ts +3 -3
- package/dist/build/base/createAppBuildJob.js +9 -15
- package/dist/build/base/index.d.ts +6 -2
- package/dist/build/base/index.js +14 -5
- package/dist/build/base/writeDotEnv.js +2 -1
- package/dist/build/custom/__tests__/testJob.test.js +1 -1
- package/dist/build/custom/buildJob.js +3 -10
- package/dist/build/docker.js +3 -3
- package/dist/build/index.d.ts +13 -6
- package/dist/build/index.js +29 -7
- package/dist/build/node/buildJob.d.ts +7 -2
- package/dist/build/node/buildJob.js +40 -33
- package/dist/build/node/cache.d.ts +2 -2
- package/dist/build/node/cache.js +8 -4
- package/dist/build/node/index.d.ts +2 -2
- package/dist/build/node/meteor.js +3 -6
- package/dist/build/node/testJob.d.ts +3 -2
- package/dist/build/node/testJob.js +9 -4
- package/dist/build/node/yarn.js +1 -1
- package/dist/build/rails/build.d.ts +1 -1
- package/dist/build/rails/build.js +7 -2
- package/dist/build/rails/test.d.ts +1 -1
- package/dist/build/rails/test.js +5 -0
- package/dist/build/sbom.js +3 -2
- package/dist/build/types.d.ts +48 -4
- package/dist/build/types.js +7 -1
- package/dist/bundles/catladder-gitlab/index.js +2 -2
- package/dist/constants.js +1 -1
- package/dist/context/createAllComponentsContext.d.ts +12 -0
- package/dist/context/createAllComponentsContext.js +159 -0
- package/dist/context/createComponentContext.d.ts +1 -5
- package/dist/context/createComponentContext.js +82 -20
- package/dist/context/createWorkspaceContext.d.ts +16 -0
- package/dist/context/createWorkspaceContext.js +173 -0
- package/dist/context/getBuildInfoVariables.d.ts +1 -1
- package/dist/context/getEnvironmentContext.d.ts +1 -1
- package/dist/context/getEnvironmentVariables.d.ts +2 -2
- package/dist/context/getEnvironmentVariables.js +5 -4
- package/dist/context/getLabels.js +5 -5
- package/dist/deploy/base/deploy.d.ts +1 -1
- package/dist/deploy/base/deploy.js +18 -5
- package/dist/deploy/cloudRun/artifactsRegistry.js +2 -2
- package/dist/deploy/cloudRun/createJobs/common.d.ts +4 -4
- package/dist/deploy/cloudRun/index.d.ts +2 -2
- package/dist/deploy/custom/index.d.ts +2 -2
- package/dist/deploy/dockerTag/index.d.ts +2 -2
- package/dist/deploy/index.d.ts +7 -7
- package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +3 -1
- package/dist/deploy/kubernetes/cloudSql/index.js +1 -1
- package/dist/deploy/kubernetes/deployJob.js +2 -2
- package/dist/deploy/kubernetes/index.d.ts +2 -2
- package/dist/deploy/sbom.d.ts +1 -1
- package/dist/deploy/sbom.js +4 -3
- package/dist/deploy/types/index.d.ts +3 -3
- package/dist/pipeline/createAllJobs.d.ts +12 -10
- package/dist/pipeline/createAllJobs.js +94 -51
- package/dist/pipeline/createJobsForComponent.js +2 -3
- package/dist/pipeline/createJobsForWorkspace.d.ts +3 -0
- package/dist/pipeline/createJobsForWorkspace.js +12 -0
- package/dist/pipeline/createMainPipeline.js +26 -6
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +3 -16
- package/dist/pipeline/gitlab/createGitlabJobs.js +191 -73
- package/dist/pipeline/packageManager.d.ts +3 -2
- package/dist/pipeline/packageManager.js +43 -15
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +5 -4
- package/dist/types/context.d.ts +80 -12
- package/dist/types/context.js +10 -1
- package/dist/types/environmentContext.d.ts +5 -6
- package/dist/types/jobs.d.ts +5 -0
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-meteor-with-worker.ts.snap +8 -0
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-no-service.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-post-stop-job.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-service-gen2.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-service-increase-timout.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-service-with-volumes.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-storybook.ts.snap +4 -8
- package/examples/__snapshots__/cloud-run-with-ngnix.ts.snap +4 -8
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +16 -16
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +589 -1097
- package/examples/__snapshots__/cloud-run-with-worker.ts.snap +8 -8
- package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +4 -0
- package/examples/__snapshots__/custom-build-job.ts.snap +4 -0
- package/examples/__snapshots__/custom-deploy.ts.snap +8 -8
- package/examples/__snapshots__/custom-envs.ts.snap +18 -12
- package/examples/__snapshots__/custom-sbom-java.ts.snap +4 -0
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +8 -8
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +8 -8
- package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +8 -8
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +16 -16
- package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +8 -8
- package/examples/__snapshots__/local-dot-env.ts.snap +8 -8
- package/examples/__snapshots__/meteor-kubernetes.ts.snap +8 -0
- package/examples/__snapshots__/multiline-var.ts.snap +16 -16
- package/examples/__snapshots__/native-app.ts.snap +24 -16
- package/examples/__snapshots__/node-build-with-custom-image.ts.snap +8 -8
- package/examples/__snapshots__/node-build-with-docker-additions.ts.snap +8 -8
- package/examples/__snapshots__/wait-for-other-deploy.ts.snap +16 -16
- package/examples/cloud-run-with-sql.ts +9 -2
- package/package.json +1 -1
- package/src/build/artifacts/createBuildJobArtifact.ts +61 -0
- package/src/build/base/createAppBuildJob.ts +26 -22
- package/src/build/base/index.ts +31 -4
- package/src/build/base/writeDotEnv.ts +6 -2
- package/src/build/custom/__tests__/testJob.test.ts +4 -4
- package/src/build/custom/buildJob.ts +2 -13
- package/src/build/docker.ts +6 -8
- package/src/build/index.ts +39 -7
- package/src/build/node/buildJob.ts +68 -56
- package/src/build/node/cache.ts +17 -8
- package/src/build/node/index.ts +4 -2
- package/src/build/node/meteor.ts +3 -9
- package/src/build/node/testJob.ts +21 -7
- package/src/build/node/yarn.ts +2 -2
- package/src/build/rails/build.ts +14 -4
- package/src/build/rails/test.ts +9 -1
- package/src/build/sbom.ts +7 -2
- package/src/build/types.ts +68 -4
- package/src/context/createAllComponentsContext.ts +31 -0
- package/src/context/createComponentContext.ts +59 -20
- package/src/context/createWorkspaceContext.ts +56 -0
- package/src/context/getBuildInfoVariables.ts +2 -1
- package/src/context/getEnvironmentContext.ts +2 -2
- package/src/context/getEnvironmentVariables.ts +12 -7
- package/src/context/getLabels.ts +3 -3
- package/src/deploy/base/deploy.ts +33 -7
- package/src/deploy/cloudRun/artifactsRegistry.ts +3 -4
- package/src/deploy/cloudRun/createJobs/common.ts +4 -4
- package/src/deploy/cloudRun/index.ts +68 -67
- package/src/deploy/custom/index.ts +2 -2
- package/src/deploy/dockerTag/index.ts +8 -7
- package/src/deploy/index.ts +11 -9
- package/src/deploy/kubernetes/additionalSecretKeys.ts +3 -1
- package/src/deploy/kubernetes/cloudSql/index.ts +1 -1
- package/src/deploy/kubernetes/deployJob.ts +2 -2
- package/src/deploy/kubernetes/index.ts +42 -41
- package/src/deploy/sbom.ts +9 -4
- package/src/pipeline/createAllJobs.ts +56 -55
- package/src/pipeline/createChildPipeline.ts +1 -0
- package/src/pipeline/createJobsForComponent.ts +5 -4
- package/src/pipeline/createJobsForWorkspace.ts +12 -0
- package/src/pipeline/createMainPipeline.ts +38 -23
- package/src/pipeline/gitlab/createGitlabJobs.ts +283 -119
- package/src/pipeline/packageManager.ts +25 -9
- package/src/types/config.ts +4 -1
- package/src/types/context.ts +108 -12
- package/src/types/environmentContext.ts +6 -7
- package/src/types/jobs.ts +3 -1
package/dist/constants.js
CHANGED
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
7
|
-
exports.PIPELINE_IMAGE_TAG = "v1-
|
|
7
|
+
exports.PIPELINE_IMAGE_TAG = "v1-154-0-97e273fa" || "latest";
|
|
8
8
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ComponentContext, PipelineType } from "../types";
|
|
2
|
+
import type { Config, PipelineTrigger } from "../types/config";
|
|
3
|
+
export type CreateAllComponentsContextProps = {
|
|
4
|
+
config: Config;
|
|
5
|
+
trigger: PipelineTrigger;
|
|
6
|
+
pipelineType: PipelineType;
|
|
7
|
+
};
|
|
8
|
+
export declare const createAllComponentsContext: ({
|
|
9
|
+
config,
|
|
10
|
+
trigger,
|
|
11
|
+
pipelineType
|
|
12
|
+
}: CreateAllComponentsContextProps) => Promise<Array<ComponentContext>>;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) {
|
|
5
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
6
|
+
resolve(value);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.next(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function rejected(value) {
|
|
18
|
+
try {
|
|
19
|
+
step(generator["throw"](value));
|
|
20
|
+
} catch (e) {
|
|
21
|
+
reject(e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function step(result) {
|
|
25
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
26
|
+
}
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
31
|
+
var _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function () {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
},
|
|
40
|
+
f,
|
|
41
|
+
y,
|
|
42
|
+
t,
|
|
43
|
+
g;
|
|
44
|
+
return g = {
|
|
45
|
+
next: verb(0),
|
|
46
|
+
"throw": verb(1),
|
|
47
|
+
"return": verb(2)
|
|
48
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
49
|
+
return this;
|
|
50
|
+
}), g;
|
|
51
|
+
function verb(n) {
|
|
52
|
+
return function (v) {
|
|
53
|
+
return step([n, v]);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function step(op) {
|
|
57
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
58
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
59
|
+
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;
|
|
60
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
61
|
+
switch (op[0]) {
|
|
62
|
+
case 0:
|
|
63
|
+
case 1:
|
|
64
|
+
t = op;
|
|
65
|
+
break;
|
|
66
|
+
case 4:
|
|
67
|
+
_.label++;
|
|
68
|
+
return {
|
|
69
|
+
value: op[1],
|
|
70
|
+
done: false
|
|
71
|
+
};
|
|
72
|
+
case 5:
|
|
73
|
+
_.label++;
|
|
74
|
+
y = op[1];
|
|
75
|
+
op = [0];
|
|
76
|
+
continue;
|
|
77
|
+
case 7:
|
|
78
|
+
op = _.ops.pop();
|
|
79
|
+
_.trys.pop();
|
|
80
|
+
continue;
|
|
81
|
+
default:
|
|
82
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
+
_ = 0;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
+
_.label = op[1];
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
+
_.label = t[1];
|
|
92
|
+
t = op;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (t && _.label < t[2]) {
|
|
96
|
+
_.label = t[2];
|
|
97
|
+
_.ops.push(op);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (t[2]) _.ops.pop();
|
|
101
|
+
_.trys.pop();
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
op = body.call(thisArg, _);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
op = [6, e];
|
|
107
|
+
y = 0;
|
|
108
|
+
} finally {
|
|
109
|
+
f = t = 0;
|
|
110
|
+
}
|
|
111
|
+
if (op[0] & 5) throw op[1];
|
|
112
|
+
return {
|
|
113
|
+
value: op[0] ? op[1] : void 0,
|
|
114
|
+
done: true
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
Object.defineProperty(exports, "__esModule", {
|
|
119
|
+
value: true
|
|
120
|
+
});
|
|
121
|
+
exports.createAllComponentsContext = void 0;
|
|
122
|
+
var configruedEnvs_1 = require("../config/configruedEnvs");
|
|
123
|
+
var createComponentContext_1 = require("./createComponentContext");
|
|
124
|
+
var createAllComponentsContext = function (_a) {
|
|
125
|
+
return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
126
|
+
var config = _b.config,
|
|
127
|
+
trigger = _b.trigger,
|
|
128
|
+
pipelineType = _b.pipelineType;
|
|
129
|
+
return __generator(this, function (_c) {
|
|
130
|
+
switch (_c.label) {
|
|
131
|
+
case 0:
|
|
132
|
+
return [4 /*yield*/, Promise.all(Object.keys(config.components).flatMap(function (componentName) {
|
|
133
|
+
var envs = (0, configruedEnvs_1.getAllEnvsByTrigger)(config, componentName, trigger);
|
|
134
|
+
return envs.map(function (env) {
|
|
135
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
136
|
+
return __generator(this, function (_a) {
|
|
137
|
+
switch (_a.label) {
|
|
138
|
+
case 0:
|
|
139
|
+
return [4 /*yield*/, (0, createComponentContext_1.createComponentContext)({
|
|
140
|
+
config: config,
|
|
141
|
+
componentName: componentName,
|
|
142
|
+
env: env,
|
|
143
|
+
trigger: trigger,
|
|
144
|
+
pipelineType: pipelineType
|
|
145
|
+
})];
|
|
146
|
+
case 1:
|
|
147
|
+
return [2 /*return*/, _a.sent()];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}))];
|
|
153
|
+
case 1:
|
|
154
|
+
return [2 /*return*/, _c.sent()];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
exports.createAllComponentsContext = createAllComponentsContext;
|
|
@@ -8,8 +8,4 @@ export type CreateComponentContextContext = {
|
|
|
8
8
|
pipelineType?: PipelineType;
|
|
9
9
|
trigger?: PipelineTrigger;
|
|
10
10
|
};
|
|
11
|
-
export declare const createComponentContext: (ctx: CreateComponentContextContext) => Promise<ComponentContext>;
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated use createComponentContext instead
|
|
14
|
-
*/
|
|
15
|
-
export declare const createContext: (ctx: CreateComponentContextContext) => Promise<ComponentContext>;
|
|
11
|
+
export declare const createComponentContext: (ctx: CreateComponentContextContext) => Promise<ComponentContext>;
|
|
@@ -125,55 +125,121 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
|
+
var __read = this && this.__read || function (o, n) {
|
|
129
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
130
|
+
if (!m) return o;
|
|
131
|
+
var i = m.call(o),
|
|
132
|
+
r,
|
|
133
|
+
ar = [],
|
|
134
|
+
e;
|
|
135
|
+
try {
|
|
136
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
e = {
|
|
139
|
+
error: error
|
|
140
|
+
};
|
|
141
|
+
} finally {
|
|
142
|
+
try {
|
|
143
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
144
|
+
} finally {
|
|
145
|
+
if (e) throw e.error;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return ar;
|
|
149
|
+
};
|
|
150
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
151
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
152
|
+
if (ar || !(i in from)) {
|
|
153
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
154
|
+
ar[i] = from[i];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
158
|
+
};
|
|
128
159
|
Object.defineProperty(exports, "__esModule", {
|
|
129
160
|
value: true
|
|
130
161
|
});
|
|
131
|
-
exports.
|
|
162
|
+
exports.createComponentContext = void 0;
|
|
132
163
|
var lodash_1 = require("lodash");
|
|
133
164
|
var build_1 = require("../build");
|
|
134
165
|
var deploy_1 = require("../deploy");
|
|
166
|
+
var packageManager_1 = require("../pipeline/packageManager");
|
|
135
167
|
var utils_1 = require("../utils");
|
|
136
168
|
var getEnvironment_1 = require("./getEnvironment");
|
|
137
169
|
var getEnvironmentContext_1 = require("./getEnvironmentContext");
|
|
138
|
-
var packageManager_1 = require("../pipeline/packageManager");
|
|
139
170
|
var createComponentContext = function (ctx) {
|
|
140
171
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
141
|
-
var packageManagerInfo, envContext, componentConfigWithoutDefaults, defaults, componentConfig, environment, deploy, build, customJobs, dir, context, resolvedCustomJobs;
|
|
142
|
-
|
|
143
|
-
|
|
172
|
+
var packageManagerInfo, envContext, componentConfigWithoutDefaults, resolvedBuildType, defaults, componentConfig, environment, deploy, build, customJobs, dir, getComponentDirs, _getBuildContext, buildContext, context, resolvedCustomJobs;
|
|
173
|
+
var _a;
|
|
174
|
+
return __generator(this, function (_b) {
|
|
175
|
+
switch (_b.label) {
|
|
144
176
|
case 0:
|
|
145
177
|
if (!/^[a-z0-9-]+$/.test(ctx.componentName)) {
|
|
146
178
|
throw new Error("componentName may only contain lower case letters, numbers and -");
|
|
147
179
|
}
|
|
148
180
|
return [4 /*yield*/, (0, packageManager_1.getPackageManagerInfoForComponent)(ctx.config, ctx.componentName)];
|
|
149
181
|
case 1:
|
|
150
|
-
packageManagerInfo =
|
|
182
|
+
packageManagerInfo = _b.sent();
|
|
151
183
|
envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(ctx);
|
|
152
184
|
componentConfigWithoutDefaults = envContext.envConfigRaw;
|
|
185
|
+
resolvedBuildType = (0, build_1.isStandaloneBuildConfig)(componentConfigWithoutDefaults.build) ? componentConfigWithoutDefaults.build.type : (_a = ctx.config.builds) === null || _a === void 0 ? void 0 : _a[componentConfigWithoutDefaults.build.from].type;
|
|
186
|
+
if (!resolvedBuildType) {
|
|
187
|
+
throw new Error("build type not found, is the build config correct?");
|
|
188
|
+
}
|
|
153
189
|
defaults = componentConfigWithoutDefaults.deploy ? {
|
|
154
|
-
build: build_1.BUILD_TYPES[
|
|
190
|
+
build: build_1.BUILD_TYPES[resolvedBuildType].defaults(envContext),
|
|
155
191
|
deploy: deploy_1.DEPLOY_TYPES[componentConfigWithoutDefaults.deploy.type].defaults(envContext)
|
|
156
192
|
} : {
|
|
157
|
-
build:
|
|
193
|
+
build: build_1.BUILD_TYPES[resolvedBuildType].defaults(envContext),
|
|
158
194
|
deploy: {}
|
|
159
195
|
};
|
|
160
196
|
componentConfig = (0, utils_1.mergeWithMergingArrays)(defaults, componentConfigWithoutDefaults);
|
|
161
197
|
return [4 /*yield*/, (0, getEnvironment_1.getEnvironment)(ctx)];
|
|
162
198
|
case 2:
|
|
163
|
-
environment =
|
|
199
|
+
environment = _b.sent();
|
|
164
200
|
deploy = componentConfig.deploy, build = componentConfig.build, customJobs = componentConfig.customJobs, dir = componentConfig.dir;
|
|
201
|
+
getComponentDirs = function (mode) {
|
|
202
|
+
var _a;
|
|
203
|
+
return __spreadArray([dir], __read(mode === "all" ? (_a = packageManagerInfo.currentWorkspaceDependencies) !== null && _a !== void 0 ? _a : [] : []), false);
|
|
204
|
+
};
|
|
205
|
+
_getBuildContext = function () {
|
|
206
|
+
var _a;
|
|
207
|
+
if ((0, build_1.isStandaloneBuildConfig)(build)) {
|
|
208
|
+
return {
|
|
209
|
+
dir: dir,
|
|
210
|
+
getComponentDirs: getComponentDirs,
|
|
211
|
+
config: build,
|
|
212
|
+
buildType: build.type,
|
|
213
|
+
type: "standalone"
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
// must be shared build
|
|
217
|
+
var referencedBuild = (_a = ctx.config.builds) === null || _a === void 0 ? void 0 : _a[build.from];
|
|
218
|
+
if (!referencedBuild) {
|
|
219
|
+
throw new Error("build.from not found in config");
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
dir: dir,
|
|
223
|
+
getComponentDirs: getComponentDirs,
|
|
224
|
+
config: build,
|
|
225
|
+
workspaceBuildConfig: referencedBuild,
|
|
226
|
+
workspaceName: build.from,
|
|
227
|
+
buildType: referencedBuild.type,
|
|
228
|
+
type: "fromWorkspace"
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
buildContext = _getBuildContext();
|
|
165
232
|
context = {
|
|
233
|
+
type: "component",
|
|
234
|
+
name: ctx.componentName,
|
|
235
|
+
componentName: ctx.componentName,
|
|
236
|
+
env: ctx.env,
|
|
166
237
|
fullConfig: ctx.config,
|
|
167
238
|
componentConfig: componentConfig,
|
|
168
|
-
|
|
169
|
-
build: {
|
|
170
|
-
dir: dir,
|
|
171
|
-
config: build
|
|
172
|
-
},
|
|
239
|
+
build: buildContext,
|
|
173
240
|
deploy: deploy ? {
|
|
174
241
|
config: deploy
|
|
175
242
|
} : null,
|
|
176
|
-
componentName: ctx.componentName,
|
|
177
243
|
environment: environment,
|
|
178
244
|
packageManagerInfo: packageManagerInfo,
|
|
179
245
|
pipelineType: ctx.pipelineType,
|
|
@@ -187,8 +253,4 @@ var createComponentContext = function (ctx) {
|
|
|
187
253
|
});
|
|
188
254
|
});
|
|
189
255
|
};
|
|
190
|
-
exports.createComponentContext = createComponentContext;
|
|
191
|
-
/**
|
|
192
|
-
* @deprecated use createComponentContext instead
|
|
193
|
-
*/
|
|
194
|
-
exports.createContext = exports.createComponentContext;
|
|
256
|
+
exports.createComponentContext = createComponentContext;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Config, type PipelineTrigger, type PipelineType, type WorkspaceContext } from "..";
|
|
2
|
+
export declare function createWorkspaceContext({
|
|
3
|
+
env,
|
|
4
|
+
components,
|
|
5
|
+
workspaceName,
|
|
6
|
+
config,
|
|
7
|
+
pipelineType,
|
|
8
|
+
trigger
|
|
9
|
+
}: {
|
|
10
|
+
env: string;
|
|
11
|
+
components: WorkspaceContext["components"];
|
|
12
|
+
workspaceName: string;
|
|
13
|
+
config: Config;
|
|
14
|
+
pipelineType: PipelineType;
|
|
15
|
+
trigger: PipelineTrigger;
|
|
16
|
+
}): Promise<WorkspaceContext>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) {
|
|
5
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
6
|
+
resolve(value);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.next(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function rejected(value) {
|
|
18
|
+
try {
|
|
19
|
+
step(generator["throw"](value));
|
|
20
|
+
} catch (e) {
|
|
21
|
+
reject(e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function step(result) {
|
|
25
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
26
|
+
}
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
31
|
+
var _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function () {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
},
|
|
40
|
+
f,
|
|
41
|
+
y,
|
|
42
|
+
t,
|
|
43
|
+
g;
|
|
44
|
+
return g = {
|
|
45
|
+
next: verb(0),
|
|
46
|
+
"throw": verb(1),
|
|
47
|
+
"return": verb(2)
|
|
48
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
49
|
+
return this;
|
|
50
|
+
}), g;
|
|
51
|
+
function verb(n) {
|
|
52
|
+
return function (v) {
|
|
53
|
+
return step([n, v]);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function step(op) {
|
|
57
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
58
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
59
|
+
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;
|
|
60
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
61
|
+
switch (op[0]) {
|
|
62
|
+
case 0:
|
|
63
|
+
case 1:
|
|
64
|
+
t = op;
|
|
65
|
+
break;
|
|
66
|
+
case 4:
|
|
67
|
+
_.label++;
|
|
68
|
+
return {
|
|
69
|
+
value: op[1],
|
|
70
|
+
done: false
|
|
71
|
+
};
|
|
72
|
+
case 5:
|
|
73
|
+
_.label++;
|
|
74
|
+
y = op[1];
|
|
75
|
+
op = [0];
|
|
76
|
+
continue;
|
|
77
|
+
case 7:
|
|
78
|
+
op = _.ops.pop();
|
|
79
|
+
_.trys.pop();
|
|
80
|
+
continue;
|
|
81
|
+
default:
|
|
82
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
+
_ = 0;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
+
_.label = op[1];
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
+
_.label = t[1];
|
|
92
|
+
t = op;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (t && _.label < t[2]) {
|
|
96
|
+
_.label = t[2];
|
|
97
|
+
_.ops.push(op);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (t[2]) _.ops.pop();
|
|
101
|
+
_.trys.pop();
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
op = body.call(thisArg, _);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
op = [6, e];
|
|
107
|
+
y = 0;
|
|
108
|
+
} finally {
|
|
109
|
+
f = t = 0;
|
|
110
|
+
}
|
|
111
|
+
if (op[0] & 5) throw op[1];
|
|
112
|
+
return {
|
|
113
|
+
value: op[0] ? op[1] : void 0,
|
|
114
|
+
done: true
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
Object.defineProperty(exports, "__esModule", {
|
|
119
|
+
value: true
|
|
120
|
+
});
|
|
121
|
+
exports.createWorkspaceContext = void 0;
|
|
122
|
+
var __1 = require("..");
|
|
123
|
+
var packageManager_1 = require("../pipeline/packageManager");
|
|
124
|
+
var utils_1 = require("../utils");
|
|
125
|
+
var lodash_1 = require("lodash");
|
|
126
|
+
function createWorkspaceContext(_a) {
|
|
127
|
+
return __awaiter(this, arguments, void 0, function (_b) {
|
|
128
|
+
var workspaceConfigRaw, defaults, workspaceConfig;
|
|
129
|
+
var _c;
|
|
130
|
+
var _d, _e;
|
|
131
|
+
var env = _b.env,
|
|
132
|
+
components = _b.components,
|
|
133
|
+
workspaceName = _b.workspaceName,
|
|
134
|
+
config = _b.config,
|
|
135
|
+
pipelineType = _b.pipelineType,
|
|
136
|
+
trigger = _b.trigger;
|
|
137
|
+
return __generator(this, function (_f) {
|
|
138
|
+
switch (_f.label) {
|
|
139
|
+
case 0:
|
|
140
|
+
workspaceConfigRaw = (_d = config.builds) === null || _d === void 0 ? void 0 : _d[workspaceName];
|
|
141
|
+
if (!workspaceConfigRaw) {
|
|
142
|
+
throw new Error("Workspace ".concat(workspaceName, " not found in config"));
|
|
143
|
+
}
|
|
144
|
+
defaults = __1.WORKSPACE_BUILD_TYPES[workspaceConfigRaw.type].defaults();
|
|
145
|
+
workspaceConfig = (0, utils_1.mergeWithMergingArrays)(defaults, workspaceConfigRaw);
|
|
146
|
+
_c = {
|
|
147
|
+
name: workspaceName,
|
|
148
|
+
pipelineType: pipelineType,
|
|
149
|
+
trigger: trigger,
|
|
150
|
+
type: "workspace",
|
|
151
|
+
workspaceConfig: workspaceConfig,
|
|
152
|
+
env: env,
|
|
153
|
+
components: components,
|
|
154
|
+
fullConfig: config
|
|
155
|
+
};
|
|
156
|
+
return [4 /*yield*/, (0, packageManager_1.getPackageManagerInfoBase)()];
|
|
157
|
+
case 1:
|
|
158
|
+
return [2 /*return*/, (_c.packageManagerInfo = _f.sent(), _c.build = {
|
|
159
|
+
type: "workspace",
|
|
160
|
+
dir: (_e = workspaceConfig.dir) !== null && _e !== void 0 ? _e : ".",
|
|
161
|
+
getComponentDirs: function (mode) {
|
|
162
|
+
return (0, lodash_1.uniq)(components.flatMap(function (c) {
|
|
163
|
+
return c.build.getComponentDirs(mode);
|
|
164
|
+
}));
|
|
165
|
+
},
|
|
166
|
+
buildType: workspaceConfig.type,
|
|
167
|
+
config: workspaceConfig
|
|
168
|
+
}, _c)];
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
exports.createWorkspaceContext = createWorkspaceContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BashExpression } from "../bash/BashExpression";
|
|
2
2
|
import type { EnvironmentContext } from "../types/environmentContext";
|
|
3
|
-
export declare const getBuildInfoVariables: (ctx: EnvironmentContext
|
|
3
|
+
export declare const getBuildInfoVariables: (ctx: EnvironmentContext) => {
|
|
4
4
|
BUILD_INFO_BUILD_ID: string | BashExpression;
|
|
5
5
|
BUILD_INFO_BUILD_TIME: string | BashExpression;
|
|
6
6
|
BUILD_INFO_CURRENT_VERSION: string | BashExpression;
|
|
@@ -6,13 +6,13 @@ export type SecretEnvVar = {
|
|
|
6
6
|
key: string;
|
|
7
7
|
hidden?: boolean;
|
|
8
8
|
};
|
|
9
|
-
declare const getBasePredefinedVariables: (ctx: EnvironmentContext
|
|
9
|
+
declare const getBasePredefinedVariables: (ctx: EnvironmentContext) => {
|
|
10
10
|
BUILD_INFO_BUILD_ID?: string | import("../bash/BashExpression").BashExpression | undefined;
|
|
11
11
|
BUILD_INFO_BUILD_TIME?: string | import("../bash/BashExpression").BashExpression | undefined;
|
|
12
12
|
BUILD_INFO_CURRENT_VERSION?: string | import("../bash/BashExpression").BashExpression | undefined;
|
|
13
13
|
ENV_SHORT: string;
|
|
14
14
|
APP_DIR: string;
|
|
15
|
-
ENV_TYPE: "
|
|
15
|
+
ENV_TYPE: "dev" | "review" | "stage" | "prod" | "local";
|
|
16
16
|
};
|
|
17
17
|
type BasePredefinedVariables = ReturnType<typeof getBasePredefinedVariables>;
|
|
18
18
|
export type PredefinedVariables = BasePredefinedVariables & {
|
|
@@ -163,6 +163,7 @@ exports.getSecretVarNameForContext = exports.getSecretVarName = exports.getEnvir
|
|
|
163
163
|
var lodash_1 = require("lodash");
|
|
164
164
|
var deploy_1 = require("../deploy");
|
|
165
165
|
var BashExpression_1 = require("../bash/BashExpression");
|
|
166
|
+
var types_1 = require("../build/types");
|
|
166
167
|
var getBuildInfoVariables_1 = require("./getBuildInfoVariables");
|
|
167
168
|
var getEnvironmentContext_1 = require("./getEnvironmentContext");
|
|
168
169
|
var resolveReferences_1 = require("./resolveReferences");
|
|
@@ -202,7 +203,7 @@ var getEnvironmentVariables = function (ctx_1) {
|
|
|
202
203
|
predefinedVariables = __assign(__assign(__assign(__assign({}, basePredefinedVariables), {
|
|
203
204
|
ENV_SHORT: "local",
|
|
204
205
|
ROOT_URL: url
|
|
205
|
-
}),
|
|
206
|
+
}), (0, types_1.isStandaloneBuildConfig)(buildConfigRaw) && buildConfigRaw.type === "rails" ? {} : {
|
|
206
207
|
HOST: host
|
|
207
208
|
}), {
|
|
208
209
|
HOST_INTERNAL: host,
|
|
@@ -214,7 +215,7 @@ var getEnvironmentVariables = function (ctx_1) {
|
|
|
214
215
|
HOST_INTERNAL = (_d = additionalEnvVars.HOST_INTERNAL) !== null && _d !== void 0 ? _d : "unknown-host.example.com";
|
|
215
216
|
host = (_e = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _e !== void 0 ? _e : HOST_INTERNAL;
|
|
216
217
|
url = (0, BashExpression_1.joinBashExpressions)(["https://", host]);
|
|
217
|
-
predefinedVariables = __assign(__assign(__assign(__assign({}, basePredefinedVariables),
|
|
218
|
+
predefinedVariables = __assign(__assign(__assign(__assign({}, basePredefinedVariables), (0, types_1.isStandaloneBuildConfig)(buildConfigRaw) && buildConfigRaw.type === "rails" ? {} : {
|
|
218
219
|
HOST: host
|
|
219
220
|
}), {
|
|
220
221
|
ROOT_URL: url,
|
|
@@ -255,7 +256,7 @@ var getEnvironmentVariables = function (ctx_1) {
|
|
|
255
256
|
secretEnvVarKeys: secretEnvVarKeys
|
|
256
257
|
};
|
|
257
258
|
_b = {};
|
|
258
|
-
return [4 /*yield*/, (0, transformJobOnlyVars_1.transformJobOnlyVars)(env, componentName, buildConfigRaw && buildConfigRaw.jobVars || null)];
|
|
259
|
+
return [4 /*yield*/, (0, transformJobOnlyVars_1.transformJobOnlyVars)(env, componentName, buildConfigRaw && (0, types_1.isStandaloneBuildConfig)(buildConfigRaw) && buildConfigRaw.jobVars || null)];
|
|
259
260
|
case 2:
|
|
260
261
|
_b.build = _m.sent();
|
|
261
262
|
return [4 /*yield*/, (0, transformJobOnlyVars_1.transformJobOnlyVars)(env, componentName, deployConfigRaw && deployConfigRaw.jobVars || null)];
|
|
@@ -279,6 +280,6 @@ var addIndexVar = function (vars) {
|
|
|
279
280
|
});
|
|
280
281
|
};
|
|
281
282
|
var getSecretVarNameForContext = function (context, key) {
|
|
282
|
-
return (0, exports.getSecretVarName)(context.
|
|
283
|
+
return (0, exports.getSecretVarName)(context.env, context.name, key);
|
|
283
284
|
};
|
|
284
285
|
exports.getSecretVarNameForContext = getSecretVarNameForContext;
|
|
@@ -27,15 +27,15 @@ var sanitize = function (value) {
|
|
|
27
27
|
return (0, slugify_1.default)(value).toLowerCase();
|
|
28
28
|
};
|
|
29
29
|
var getLabels = function (context) {
|
|
30
|
-
var _a, _b
|
|
30
|
+
var _a, _b;
|
|
31
31
|
var labels = __assign({
|
|
32
32
|
"customer-name": sanitize(context.fullConfig.customerName),
|
|
33
|
-
"component-name": sanitize(context.
|
|
33
|
+
"component-name": sanitize(context.name),
|
|
34
34
|
"app-name": sanitize(context.fullConfig.appName),
|
|
35
35
|
"env-type": sanitize(context.environment.envType),
|
|
36
|
-
"env-name": sanitize(context.
|
|
37
|
-
"build-type": sanitize(
|
|
38
|
-
}, (
|
|
36
|
+
"env-name": sanitize(context.env),
|
|
37
|
+
"build-type": sanitize(context.build.buildType)
|
|
38
|
+
}, (_b = (_a = context.fullConfig.meta) === null || _a === void 0 ? void 0 : _a.labels) !== null && _b !== void 0 ? _b : {});
|
|
39
39
|
return labels;
|
|
40
40
|
};
|
|
41
41
|
exports.getLabels = getLabels;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ComponentContext } from "../../types/context";
|
|
2
2
|
import type { CatladderJob } from "../../types/jobs";
|
|
3
3
|
export declare const DEPLOY_JOB_NAME = "\uD83D\uDE80 Deploy";
|
|
4
4
|
export type DeployJobDefinition = Pick<CatladderJob, "script" | "variables" | "image" | "cache" | "artifacts" | "services" | "runnerVariables">;
|
|
@@ -47,6 +47,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
47
47
|
exports.createDeployJob = exports.DEPLOY_JOB_NAME = void 0;
|
|
48
48
|
var docker_1 = require("../../build/docker");
|
|
49
49
|
var sbom_1 = require("../../build/sbom");
|
|
50
|
+
var context_1 = require("../../types/context");
|
|
50
51
|
var sbom_2 = require("../sbom");
|
|
51
52
|
var utils_1 = require("../utils");
|
|
52
53
|
var stop_1 = require("./stop");
|
|
@@ -85,14 +86,26 @@ var createDeployJob = function (context, jobDefinition) {
|
|
|
85
86
|
};
|
|
86
87
|
})) !== null && _d !== void 0 ? _d : [] : []), false),
|
|
87
88
|
// we don't want to deploy when there is a broken test
|
|
88
|
-
needsStages: [
|
|
89
|
+
needsStages: __spreadArray(__spreadArray([], __read((0, context_1.componentContextHasWorkspaceBuild)(context) ? hasDocker // docker build is per component,
|
|
90
|
+
? [
|
|
91
|
+
// we don't need artifacts, but have to wait for the component build
|
|
92
|
+
{
|
|
93
|
+
stage: "build",
|
|
94
|
+
artifacts: false
|
|
95
|
+
}] : [{
|
|
96
|
+
// pick build artifacts from workspace build
|
|
97
|
+
stage: "build",
|
|
98
|
+
artifacts: true,
|
|
99
|
+
workspaceName: context.build.workspaceName
|
|
100
|
+
}] : [{
|
|
89
101
|
stage: "build",
|
|
90
102
|
artifacts: hasDocker ? false : true // we asume that no-docker deployments need build artifacts,
|
|
91
|
-
}, {
|
|
103
|
+
}]), false), [{
|
|
92
104
|
stage: "test",
|
|
93
|
-
artifacts: false
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
artifacts: false,
|
|
106
|
+
// use test from workspace build
|
|
107
|
+
workspaceName: (0, context_1.componentContextHasWorkspaceBuild)(context) ? context.build.workspaceName : undefined
|
|
108
|
+
}], false),
|
|
96
109
|
when: whenDeploy === "auto" ? "on_success" : "manual",
|
|
97
110
|
allow_failure: whenDeploy === "manual" ? true : false,
|
|
98
111
|
stage: "deploy",
|