@catladder/pipeline 1.110.1 → 1.110.3
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/base/__tests__/createArtifactsConfig.test.d.ts +1 -0
- package/dist/build/base/__tests__/createArtifactsConfig.test.js +40 -0
- package/dist/build/base/createArtifactsConfig.d.ts +4 -0
- package/dist/build/base/createArtifactsConfig.js +63 -0
- package/dist/build/custom/__tests__/testJob.test.d.ts +1 -0
- package/dist/build/custom/__tests__/testJob.test.js +37 -0
- package/dist/build/custom/buildJob.js +4 -2
- package/dist/build/custom/testJob.d.ts +5 -1
- package/dist/build/custom/testJob.js +10 -23
- package/dist/build/node/buildJob.js +4 -2
- package/dist/build/node/testJob.js +12 -11
- package/dist/build/rails/build.js +13 -2
- package/dist/build/sbom.d.ts +5 -0
- package/dist/build/sbom.js +29 -0
- package/dist/build/types.d.ts +39 -40
- package/dist/bundles/catladder-gitlab/index.js +3 -3
- package/dist/constants.js +1 -1
- package/dist/deploy/base.js +38 -2
- package/dist/deploy/cloudRun/deployJob.js +5 -4
- package/dist/deploy/custom/deployJob.js +3 -2
- package/dist/deploy/kubernetes/deployJob.js +3 -2
- package/dist/deploy/sbom.d.ts +4 -0
- package/dist/deploy/sbom.js +17 -0
- package/dist/pipeline/createJobsForComponent.js +1 -3
- package/dist/pipeline/gitlab/createGitlabJobs.js +5 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/gitlab-types.d.ts +13 -22
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +40 -96
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +40 -96
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +40 -96
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +80 -192
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +80 -192
- package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +40 -96
- package/examples/__snapshots__/custom-build-job.ts.snap +40 -96
- package/examples/__snapshots__/custom-deploy.ts.snap +40 -96
- package/examples/__snapshots__/custom-envs.ts.snap +6 -126
- package/examples/__snapshots__/custom-sbom-java.ts.snap +40 -96
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +40 -96
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +40 -96
- package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +40 -96
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +80 -192
- package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +40 -96
- package/examples/__snapshots__/native-app.ts.snap +72 -192
- package/examples/__snapshots__/node-build-with-custom-image.ts.snap +40 -96
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +40 -96
- package/examples/__snapshots__/wait-for-other-deploy.ts.snap +64 -192
- package/package.json +1 -1
- package/src/build/base/__tests__/__snapshots__/createArtifactsConfig.test.ts.snap +49 -0
- package/src/build/base/__tests__/createArtifactsConfig.test.ts +41 -0
- package/src/build/base/createArtifactsConfig.ts +34 -0
- package/src/build/custom/__tests__/testJob.test.ts +32 -0
- package/src/build/custom/buildJob.ts +3 -0
- package/src/build/custom/testJob.ts +8 -21
- package/src/build/node/buildJob.ts +3 -0
- package/src/build/node/testJob.ts +16 -0
- package/src/build/rails/build.ts +3 -0
- package/src/build/sbom.ts +43 -0
- package/src/build/types.ts +45 -46
- package/src/deploy/base.ts +14 -7
- package/src/deploy/cloudRun/deployJob.ts +6 -0
- package/src/deploy/custom/deployJob.ts +9 -1
- package/src/deploy/kubernetes/deployJob.ts +10 -1
- package/src/deploy/sbom.ts +24 -0
- package/src/pipeline/createJobsForComponent.ts +1 -3
- package/src/pipeline/gitlab/createGitlabJobs.ts +6 -2
- package/src/types/gitlab-types.ts +12 -12
- package/dist/verify/reporting.d.ts +0 -3
- package/dist/verify/reporting.js +0 -48
- package/src/verify/reporting.ts +0 -69
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
var createArtifactsConfig_1 = require("../createArtifactsConfig");
|
|
5
|
+
describe("createArtifactsConfig", function () {
|
|
6
|
+
it("returns undefined if no artifacts or artifactsReports", function () {
|
|
7
|
+
expect((0, createArtifactsConfig_1.createArtifactsConfig)(".")).toBeUndefined();
|
|
8
|
+
});
|
|
9
|
+
it("returns artifacts if no artifactsReports", function () {
|
|
10
|
+
expect((0, createArtifactsConfig_1.createArtifactsConfig)(".", undefined, {
|
|
11
|
+
paths: ["testpath"],
|
|
12
|
+
reports: {
|
|
13
|
+
coverage_report: {
|
|
14
|
+
coverage_format: "cobertura",
|
|
15
|
+
path: "some"
|
|
16
|
+
},
|
|
17
|
+
terraform: "something"
|
|
18
|
+
}
|
|
19
|
+
})).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
it("returns junit parts of artifactsReports", function () {
|
|
22
|
+
expect((0, createArtifactsConfig_1.createArtifactsConfig)(".", {
|
|
23
|
+
junit: ["report.xml"]
|
|
24
|
+
})).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
it("merges junit files if both given", function () {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
var result = (0, createArtifactsConfig_1.createArtifactsConfig)(".", {
|
|
29
|
+
junit: ["partial-report.xml"]
|
|
30
|
+
}, {
|
|
31
|
+
paths: ["testpath"],
|
|
32
|
+
reports: {
|
|
33
|
+
junit: "full-report.xml",
|
|
34
|
+
terraform: "something"
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
expect(result).toMatchSnapshot();
|
|
38
|
+
expect((_b = (_a = result === null || result === void 0 ? void 0 : result.artifacts) === null || _a === void 0 ? void 0 : _a.reports) === null || _b === void 0 ? void 0 : _b.junit).toHaveLength(2);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BuildConfigArtifactsReports } from "../types";
|
|
2
|
+
import type { Artifacts } from "../../types";
|
|
3
|
+
import type { OptionalArtifacts } from "../custom/testJob";
|
|
4
|
+
export declare const createArtifactsConfig: (rootPath: string, artifactsReports?: BuildConfigArtifactsReports | undefined, artifacts?: Artifacts | undefined) => OptionalArtifacts;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __read = this && this.__read || function (o, n) {
|
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
+
if (!m) return o;
|
|
16
|
+
var i = m.call(o),
|
|
17
|
+
r,
|
|
18
|
+
ar = [],
|
|
19
|
+
e;
|
|
20
|
+
try {
|
|
21
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
e = {
|
|
24
|
+
error: error
|
|
25
|
+
};
|
|
26
|
+
} finally {
|
|
27
|
+
try {
|
|
28
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
29
|
+
} finally {
|
|
30
|
+
if (e) throw e.error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
36
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
37
|
+
if (ar || !(i in from)) {
|
|
38
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
39
|
+
ar[i] = from[i];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
43
|
+
};
|
|
44
|
+
exports.__esModule = true;
|
|
45
|
+
exports.createArtifactsConfig = void 0;
|
|
46
|
+
var path_1 = require("path");
|
|
47
|
+
var createArtifactsConfig = function (rootPath, artifactsReports, artifacts) {
|
|
48
|
+
var _a, _b, _c, _d;
|
|
49
|
+
return artifactsReports || artifacts ? {
|
|
50
|
+
artifacts: __assign(__assign({
|
|
51
|
+
paths: []
|
|
52
|
+
}, artifacts), {
|
|
53
|
+
reports: __assign(__assign({}, artifacts === null || artifacts === void 0 ? void 0 : artifacts.reports), {
|
|
54
|
+
junit: [artifactsReports === null || artifactsReports === void 0 ? void 0 : artifactsReports.junit, Array.isArray((_a = artifacts === null || artifacts === void 0 ? void 0 : artifacts.reports) === null || _a === void 0 ? void 0 : _a.junit) && ((_b = artifacts === null || artifacts === void 0 ? void 0 : artifacts.reports) === null || _b === void 0 ? void 0 : _b.junit), typeof ((_c = artifacts === null || artifacts === void 0 ? void 0 : artifacts.reports) === null || _c === void 0 ? void 0 : _c.junit) === "string" && [(_d = artifacts === null || artifacts === void 0 ? void 0 : artifacts.reports) === null || _d === void 0 ? void 0 : _d.junit]].filter(Array.isArray).reduce(function (acc, curr) {
|
|
55
|
+
return __spreadArray(__spreadArray([], __read(acc), false), __read(curr.map(function (p) {
|
|
56
|
+
return (0, path_1.join)(rootPath, p);
|
|
57
|
+
})), false);
|
|
58
|
+
}, [])
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
} : undefined;
|
|
62
|
+
};
|
|
63
|
+
exports.createArtifactsConfig = createArtifactsConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
var testJob_1 = require("../testJob");
|
|
5
|
+
describe("createCustomTestJobs", function () {
|
|
6
|
+
var componentConfig = {
|
|
7
|
+
dir: ".",
|
|
8
|
+
build: {
|
|
9
|
+
type: "custom",
|
|
10
|
+
docker: {
|
|
11
|
+
type: "custom"
|
|
12
|
+
},
|
|
13
|
+
jobImage: ""
|
|
14
|
+
},
|
|
15
|
+
deploy: {}
|
|
16
|
+
};
|
|
17
|
+
var baseContext = {
|
|
18
|
+
componentName: "testComponent",
|
|
19
|
+
environment: {
|
|
20
|
+
jobOnlyVars: {
|
|
21
|
+
build: {}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
componentConfig: componentConfig
|
|
25
|
+
};
|
|
26
|
+
it("throws error when not build type custom", function () {
|
|
27
|
+
componentConfig.build.type = "node";
|
|
28
|
+
expect(function () {
|
|
29
|
+
return (0, testJob_1.createCustomTestJobs)(baseContext);
|
|
30
|
+
}).toThrowError("deploy config is not custom");
|
|
31
|
+
componentConfig.build.type = "custom";
|
|
32
|
+
});
|
|
33
|
+
it("returns empty array if no audit, lint, and test definition", function () {
|
|
34
|
+
var jobs = (0, testJob_1.createCustomTestJobs)(baseContext);
|
|
35
|
+
expect(jobs).toEqual([]);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -49,6 +49,8 @@ var constants_1 = require("../base/constants");
|
|
|
49
49
|
var createBuildJob_1 = require("../base/createBuildJob");
|
|
50
50
|
var docker_1 = require("../docker");
|
|
51
51
|
var types_1 = require("../types");
|
|
52
|
+
var sbom_1 = require("../sbom");
|
|
53
|
+
var sbom_2 = require("../../deploy/sbom");
|
|
52
54
|
var RUNNER_BUILD_VARIABLES = {
|
|
53
55
|
KUBERNETES_CPU_REQUEST: "0.5",
|
|
54
56
|
KUBERNETES_CPU_LIMIT: "2",
|
|
@@ -74,11 +76,11 @@ var createCustomBuildJobs = function (context) {
|
|
|
74
76
|
expire_in: "1 day"
|
|
75
77
|
}
|
|
76
78
|
}) : null;
|
|
77
|
-
return __spreadArray(__spreadArray([], __read(appBuildJob ? [appBuildJob] : []), false), __read((0, docker_1.requiresDockerBuild)(context) ? [(0, docker_1.createDockerBuildJobDefault)(context, {
|
|
79
|
+
return __spreadArray(__spreadArray(__spreadArray([], __read(appBuildJob ? [appBuildJob] : []), false), __read((0, docker_1.requiresDockerBuild)(context) ? [(0, docker_1.createDockerBuildJobDefault)(context, {
|
|
78
80
|
script: [((_d = buildConfig.docker) === null || _d === void 0 ? void 0 : _d.type) === "nginx" ? "ensureNginxDockerfile" : "" // e.g. custom,
|
|
79
81
|
].filter(Boolean),
|
|
80
82
|
variables: {},
|
|
81
83
|
needs: appBuildJob ? [constants_1.APP_BUILD_JOB_NAME] : []
|
|
82
|
-
})] : []), false);
|
|
84
|
+
})] : []), false), __read((0, sbom_2.sbomDeactivated)(context) ? [] : [(0, sbom_1.createSbomBuildJob)(context)]), false);
|
|
83
85
|
};
|
|
84
86
|
exports.createCustomBuildJobs = createCustomBuildJobs;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type { Context } from "../../types/context";
|
|
2
2
|
import type { CatladderJob } from "../../types/jobs";
|
|
3
|
-
|
|
3
|
+
import type { Artifacts } from "../../types";
|
|
4
|
+
export declare const createCustomTestJobs: (context: Context) => CatladderJob[];
|
|
5
|
+
export declare type OptionalArtifacts = {
|
|
6
|
+
artifacts: Artifacts;
|
|
7
|
+
} | undefined;
|
|
@@ -43,9 +43,9 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
43
43
|
};
|
|
44
44
|
exports.__esModule = true;
|
|
45
45
|
exports.createCustomTestJobs = void 0;
|
|
46
|
-
var path_1 = require("path");
|
|
47
46
|
var utils_1 = require("../../utils");
|
|
48
47
|
var types_1 = require("../types");
|
|
48
|
+
var createArtifactsConfig_1 = require("../base/createArtifactsConfig");
|
|
49
49
|
var RUNNER_CUSTOM_TEST_VARIABLES = {
|
|
50
50
|
KUBERNETES_CPU_REQUEST: "0.5",
|
|
51
51
|
KUBERNETES_CPU_LIMIT: "2",
|
|
@@ -53,7 +53,7 @@ var RUNNER_CUSTOM_TEST_VARIABLES = {
|
|
|
53
53
|
KUBERNETES_MEMORY_LIMIT: "4Gi"
|
|
54
54
|
};
|
|
55
55
|
var createCustomTestJobs = function (context) {
|
|
56
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
56
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
57
57
|
// don't run tests after release
|
|
58
58
|
if (((_a = context.commitInfo) === null || _a === void 0 ? void 0 : _a.trigger) === "taggedRelease") {
|
|
59
59
|
return [];
|
|
@@ -79,32 +79,19 @@ var createCustomTestJobs = function (context) {
|
|
|
79
79
|
cache: undefined,
|
|
80
80
|
script: __spreadArray([], __read((_f = (0, utils_1.ensureArray)((_e = buildConfig.audit) === null || _e === void 0 ? void 0 : _e.command)) !== null && _f !== void 0 ? _f : []), false),
|
|
81
81
|
allow_failure: true
|
|
82
|
-
}), createArtifactsConfig(context.componentConfig.dir, (_g = buildConfig.audit) === null || _g === void 0 ? void 0 : _g.artifactsReports)) : null;
|
|
82
|
+
}), (0, createArtifactsConfig_1.createArtifactsConfig)(context.componentConfig.dir, (_g = buildConfig.audit) === null || _g === void 0 ? void 0 : _g.artifactsReports, (_h = buildConfig.audit) === null || _h === void 0 ? void 0 : _h.artifacts)) : null;
|
|
83
83
|
var lintJob = buildConfig.lint ? __assign(__assign(__assign({
|
|
84
84
|
name: "👮 lint"
|
|
85
85
|
}, base), {
|
|
86
|
-
image: (
|
|
87
|
-
script: __spreadArray([], __read((
|
|
88
|
-
}), createArtifactsConfig(context.componentConfig.dir, (
|
|
86
|
+
image: (_k = (_j = buildConfig.lint) === null || _j === void 0 ? void 0 : _j.jobImage) !== null && _k !== void 0 ? _k : buildConfig.jobImage,
|
|
87
|
+
script: __spreadArray([], __read((_m = (0, utils_1.ensureArray)((_l = buildConfig.lint) === null || _l === void 0 ? void 0 : _l.command)) !== null && _m !== void 0 ? _m : []), false)
|
|
88
|
+
}), (0, createArtifactsConfig_1.createArtifactsConfig)(context.componentConfig.dir, (_o = buildConfig.lint) === null || _o === void 0 ? void 0 : _o.artifactsReports, (_p = buildConfig.lint) === null || _p === void 0 ? void 0 : _p.artifacts)) : null;
|
|
89
89
|
var testJob = buildConfig.test ? __assign(__assign(__assign({
|
|
90
90
|
name: "🧪 test"
|
|
91
91
|
}, base), {
|
|
92
|
-
image: (
|
|
93
|
-
script: __spreadArray([], __read((
|
|
94
|
-
}), createArtifactsConfig(context.componentConfig.dir, (
|
|
92
|
+
image: (_r = (_q = buildConfig.test) === null || _q === void 0 ? void 0 : _q.jobImage) !== null && _r !== void 0 ? _r : buildConfig.jobImage,
|
|
93
|
+
script: __spreadArray([], __read((_t = (0, utils_1.ensureArray)((_s = buildConfig.test) === null || _s === void 0 ? void 0 : _s.command)) !== null && _t !== void 0 ? _t : []), false)
|
|
94
|
+
}), (0, createArtifactsConfig_1.createArtifactsConfig)(context.componentConfig.dir, (_u = buildConfig.test) === null || _u === void 0 ? void 0 : _u.artifactsReports, (_v = buildConfig.test) === null || _v === void 0 ? void 0 : _v.artifacts)) : null;
|
|
95
95
|
return [auditJob, lintJob, testJob].filter(utils_1.notNil);
|
|
96
96
|
};
|
|
97
|
-
exports.createCustomTestJobs = createCustomTestJobs;
|
|
98
|
-
var createArtifactsConfig = function (rootPath, artifactsReports) {
|
|
99
|
-
var _a, _b;
|
|
100
|
-
return artifactsReports ? {
|
|
101
|
-
artifacts: {
|
|
102
|
-
paths: [],
|
|
103
|
-
reports: {
|
|
104
|
-
junit: (_b = (_a = artifactsReports === null || artifactsReports === void 0 ? void 0 : artifactsReports.junit) === null || _a === void 0 ? void 0 : _a.map(function (p) {
|
|
105
|
-
return (0, path_1.join)(rootPath, p);
|
|
106
|
-
})) !== null && _b !== void 0 ? _b : []
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
} : undefined;
|
|
110
|
-
};
|
|
97
|
+
exports.createCustomTestJobs = createCustomTestJobs;
|
|
@@ -53,6 +53,8 @@ var cache_1 = require("./cache");
|
|
|
53
53
|
var constants_2 = require("./constants");
|
|
54
54
|
var yarn_1 = require("./yarn");
|
|
55
55
|
var runner_1 = require("../../runner");
|
|
56
|
+
var sbom_1 = require("../sbom");
|
|
57
|
+
var sbom_2 = require("../../deploy/sbom");
|
|
56
58
|
var createNodeBuildJobs = function (context) {
|
|
57
59
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
58
60
|
var buildConfig = context.componentConfig.build;
|
|
@@ -74,7 +76,7 @@ var createNodeBuildJobs = function (context) {
|
|
|
74
76
|
},
|
|
75
77
|
jobTags: buildConfig.jobTags
|
|
76
78
|
}) : null;
|
|
77
|
-
return __spreadArray(__spreadArray([], __read(appBuildJob ? [appBuildJob] : []), false), __read((0, docker_1.requiresDockerBuild)(context) ? [(0, docker_1.createDockerBuildJobDefault)(context, {
|
|
79
|
+
return __spreadArray(__spreadArray(__spreadArray([], __read(appBuildJob ? [appBuildJob] : []), false), __read((0, docker_1.requiresDockerBuild)(context) ? [(0, docker_1.createDockerBuildJobDefault)(context, {
|
|
78
80
|
script: [buildConfig.type === "node-static" || buildConfig.type === "storybook" ? "ensureNginxDockerfile" : "ensureNodeDockerfile"],
|
|
79
81
|
cache: __spreadArray([], __read((0, cache_1.getYarnCache)(context, "pull")), false),
|
|
80
82
|
variables: {
|
|
@@ -85,6 +87,6 @@ var createNodeBuildJobs = function (context) {
|
|
|
85
87
|
})) === null || _g === void 0 ? void 0 : _g.join("\n")
|
|
86
88
|
},
|
|
87
89
|
needs: appBuildJob ? [constants_1.APP_BUILD_JOB_NAME] : []
|
|
88
|
-
})] : []), false);
|
|
90
|
+
})] : []), false), __read((0, sbom_2.sbomDeactivated)(context) ? [] : [(0, sbom_1.createSbomBuildJob)(context)]), false);
|
|
89
91
|
};
|
|
90
92
|
exports.createNodeBuildJobs = createNodeBuildJobs;
|
|
@@ -48,8 +48,9 @@ var utils_1 = require("../../utils");
|
|
|
48
48
|
var cache_1 = require("./cache");
|
|
49
49
|
var constants_1 = require("./constants");
|
|
50
50
|
var yarn_1 = require("./yarn");
|
|
51
|
+
var createArtifactsConfig_1 = require("../base/createArtifactsConfig");
|
|
51
52
|
var createNodeTestJobs = function (context) {
|
|
52
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
53
54
|
// don't run tests after release
|
|
54
55
|
if (((_a = context.commitInfo) === null || _a === void 0 ? void 0 : _a.trigger) === "taggedRelease") {
|
|
55
56
|
return [];
|
|
@@ -65,7 +66,7 @@ var createNodeTestJobs = function (context) {
|
|
|
65
66
|
envMode: "none"
|
|
66
67
|
};
|
|
67
68
|
var yarnInstall = (0, yarn_1.getYarnInstall)(context);
|
|
68
|
-
var auditJob = buildConfig.audit !== false ? __assign(__assign({
|
|
69
|
+
var auditJob = buildConfig.audit !== false ? __assign(__assign(__assign({
|
|
69
70
|
name: "🛡 audit"
|
|
70
71
|
}, base), {
|
|
71
72
|
image: (_d = (_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.jobImage) !== null && _d !== void 0 ? _d : defaultImage,
|
|
@@ -73,21 +74,21 @@ var createNodeTestJobs = function (context) {
|
|
|
73
74
|
script: __spreadArray(["cd ".concat(context.componentConfig.dir)], __read((_f = (0, utils_1.ensureArray)((_e = buildConfig.audit) === null || _e === void 0 ? void 0 : _e.command)) !== null && _f !== void 0 ? _f : [((_g = context.packageManagerInfo) === null || _g === void 0 ? void 0 : _g.isClassic) ? "yarn audit" : "yarn npm audit --environment production" // yarn 2
|
|
74
75
|
]), false),
|
|
75
76
|
allow_failure: true
|
|
76
|
-
}) : null;
|
|
77
|
-
var lintJob = buildConfig.lint !== false ? __assign(__assign({
|
|
77
|
+
}), (0, createArtifactsConfig_1.createArtifactsConfig)(context.componentConfig.dir, (_h = buildConfig.audit) === null || _h === void 0 ? void 0 : _h.artifactsReports, (_j = buildConfig.audit) === null || _j === void 0 ? void 0 : _j.artifacts)) : null;
|
|
78
|
+
var lintJob = buildConfig.lint !== false ? __assign(__assign(__assign({
|
|
78
79
|
name: "👮 lint"
|
|
79
80
|
}, base), {
|
|
80
|
-
image: (
|
|
81
|
+
image: (_l = (_k = buildConfig.lint) === null || _k === void 0 ? void 0 : _k.jobImage) !== null && _l !== void 0 ? _l : defaultImage,
|
|
81
82
|
cache: (0, cache_1.getNodeCache)(context),
|
|
82
|
-
script: __spreadArray(__spreadArray(["cd ".concat(context.componentConfig.dir)], __read(yarnInstall), false), __read((
|
|
83
|
-
}) : null;
|
|
84
|
-
var testJob = buildConfig.test !== false ? __assign(__assign({
|
|
83
|
+
script: __spreadArray(__spreadArray(["cd ".concat(context.componentConfig.dir)], __read(yarnInstall), false), __read((_o = (0, utils_1.ensureArray)((_m = buildConfig.lint) === null || _m === void 0 ? void 0 : _m.command)) !== null && _o !== void 0 ? _o : ["yarn lint"]), false)
|
|
84
|
+
}), (0, createArtifactsConfig_1.createArtifactsConfig)(context.componentConfig.dir, (_p = buildConfig.lint) === null || _p === void 0 ? void 0 : _p.artifactsReports, (_q = buildConfig.lint) === null || _q === void 0 ? void 0 : _q.artifacts)) : null;
|
|
85
|
+
var testJob = buildConfig.test !== false ? __assign(__assign(__assign({
|
|
85
86
|
name: "🧪 test"
|
|
86
87
|
}, base), {
|
|
87
|
-
image: (
|
|
88
|
+
image: (_s = (_r = buildConfig.test) === null || _r === void 0 ? void 0 : _r.jobImage) !== null && _s !== void 0 ? _s : (0, runner_1.getRunnerImage)("jobs-testing-chrome"),
|
|
88
89
|
cache: (0, cache_1.getNodeCache)(context),
|
|
89
|
-
script: __spreadArray(__spreadArray(["cd ".concat(context.componentConfig.dir)], __read(yarnInstall), false), __read((
|
|
90
|
-
}) : null;
|
|
90
|
+
script: __spreadArray(__spreadArray(["cd ".concat(context.componentConfig.dir)], __read(yarnInstall), false), __read((_u = (0, utils_1.ensureArray)((_t = buildConfig.test) === null || _t === void 0 ? void 0 : _t.command)) !== null && _u !== void 0 ? _u : ["yarn test"]), false)
|
|
91
|
+
}), (0, createArtifactsConfig_1.createArtifactsConfig)(context.componentConfig.dir, (_v = buildConfig.test) === null || _v === void 0 ? void 0 : _v.artifactsReports, (_w = buildConfig.test) === null || _w === void 0 ? void 0 : _w.artifacts)) : null;
|
|
91
92
|
return [auditJob, lintJob, testJob].filter(utils_1.notNil);
|
|
92
93
|
};
|
|
93
94
|
exports.createNodeTestJobs = createNodeTestJobs;
|
|
@@ -32,10 +32,21 @@ var __read = this && this.__read || function (o, n) {
|
|
|
32
32
|
}
|
|
33
33
|
return ar;
|
|
34
34
|
};
|
|
35
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
36
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
37
|
+
if (ar || !(i in from)) {
|
|
38
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
39
|
+
ar[i] = from[i];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
43
|
+
};
|
|
35
44
|
exports.__esModule = true;
|
|
36
45
|
exports.createRailsBuildJobs = void 0;
|
|
37
46
|
var types_1 = require("../types");
|
|
38
47
|
var docker_1 = require("../docker");
|
|
48
|
+
var sbom_1 = require("../../deploy/sbom");
|
|
49
|
+
var sbom_2 = require("../sbom");
|
|
39
50
|
var createRailsBuildJobs = function (context) {
|
|
40
51
|
var _a, _b, _c;
|
|
41
52
|
var buildConfig = context.componentConfig.build;
|
|
@@ -50,12 +61,12 @@ var createRailsBuildJobs = function (context) {
|
|
|
50
61
|
v = _b[1];
|
|
51
62
|
return "--env '".concat(k).concat(v ? "=".concat(v) : "", "'");
|
|
52
63
|
}).join(" ");
|
|
53
|
-
return [(0, docker_1.createDockerBuildJobBase)(context, {
|
|
64
|
+
return __spreadArray([(0, docker_1.createDockerBuildJobBase)(context, {
|
|
54
65
|
variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), context.componentConfig.build.extraVars),
|
|
55
66
|
// custom script
|
|
56
67
|
script: [docker_1.gitlabDockerLogin, "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
|
|
57
68
|
// replace private git ssh gem sources with https to make bundler with credentials via env var work
|
|
58
69
|
"sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "pack build \"$DOCKER_IMAGE:$DOCKER_IMAGE_TAG\" --builder '".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.image, "' --publish --cache-image \"$DOCKER_CACHE_IMAGE\" ").concat(packEnvArgs, " ").concat((_c = (_b = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _b === void 0 ? void 0 : _b.join(" ")) !== null && _c !== void 0 ? _c : "")]
|
|
59
|
-
})];
|
|
70
|
+
})], __read((0, sbom_1.sbomDeactivated)(context) ? [] : [(0, sbom_2.createSbomBuildJob)(context)]), false);
|
|
60
71
|
};
|
|
61
72
|
exports.createRailsBuildJobs = createRailsBuildJobs;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Context } from "../types/context";
|
|
2
|
+
import type { CatladderJob } from "../types/jobs";
|
|
3
|
+
export declare const SBOM_BUILD_JOB_NAME = "\uD83E\uDDFE sbom";
|
|
4
|
+
export declare const SBOM_FILE = "__sbom.json";
|
|
5
|
+
export declare const createSbomBuildJob: (context: Context) => CatladderJob;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.createSbomBuildJob = exports.SBOM_FILE = exports.SBOM_BUILD_JOB_NAME = void 0;
|
|
5
|
+
var utils_1 = require("../utils");
|
|
6
|
+
exports.SBOM_BUILD_JOB_NAME = "🧾 sbom";
|
|
7
|
+
exports.SBOM_FILE = "__sbom.json";
|
|
8
|
+
var createSbomBuildJob = function (context) {
|
|
9
|
+
var _a, _b, _c, _d, _e;
|
|
10
|
+
var buildConfig = context.componentConfig.build;
|
|
11
|
+
var defaultImage = "aquasec/trivy:0.38.3";
|
|
12
|
+
var defaultScript = ["trivy fs --quiet --format cyclonedx --output \"".concat(exports.SBOM_FILE, "\" ").concat(((_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.componentIsInWorkspace) ? "." : context.componentConfig.dir)];
|
|
13
|
+
var image = buildConfig.type === "custom" && buildConfig.sbom !== false ? (_c = (_b = buildConfig.sbom) === null || _b === void 0 ? void 0 : _b.jobImage) !== null && _c !== void 0 ? _c : defaultImage : defaultImage;
|
|
14
|
+
var script = buildConfig.type === "custom" && buildConfig.sbom !== false ? (_e = (0, utils_1.ensureArray)((_d = buildConfig.sbom) === null || _d === void 0 ? void 0 : _d.command)) !== null && _e !== void 0 ? _e : defaultScript : defaultScript;
|
|
15
|
+
return {
|
|
16
|
+
name: exports.SBOM_BUILD_JOB_NAME,
|
|
17
|
+
stage: "build",
|
|
18
|
+
envMode: "jobPerEnv",
|
|
19
|
+
variables: {},
|
|
20
|
+
cache: undefined,
|
|
21
|
+
image: image,
|
|
22
|
+
script: script,
|
|
23
|
+
allow_failure: true,
|
|
24
|
+
artifacts: {
|
|
25
|
+
paths: [exports.SBOM_FILE]
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
exports.createSbomBuildJob = createSbomBuildJob;
|
package/dist/build/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EnvVars, GitlabJobImage, GitlabJobService } from "../types";
|
|
1
|
+
import type { Artifacts, EnvVars, GitlabJobImage, GitlabJobService } from "../types";
|
|
2
2
|
import type { CatladderJob } from "../types/jobs";
|
|
3
3
|
export declare type BuildConfigArtifactsReports = {
|
|
4
4
|
/**
|
|
@@ -9,6 +9,21 @@ export declare type BuildConfigArtifactsReports = {
|
|
|
9
9
|
*/
|
|
10
10
|
junit?: string[];
|
|
11
11
|
};
|
|
12
|
+
export declare type TestJobCustom = {
|
|
13
|
+
command?: string | string[];
|
|
14
|
+
jobImage?: GitlabJobImage;
|
|
15
|
+
/**
|
|
16
|
+
* additional CI/CD artifacts reports,
|
|
17
|
+
* use to display information in merge requests, pipeline views and security dashboards.
|
|
18
|
+
*/
|
|
19
|
+
artifactsReports?: BuildConfigArtifactsReports;
|
|
20
|
+
/**
|
|
21
|
+
* GitLab {@link Artifacts} configuration.
|
|
22
|
+
*
|
|
23
|
+
* {@link TestJobCustom.artifacts}.reports.junit is merged with {@link TestJobCustom.artifactsReports} in case both given.
|
|
24
|
+
*/
|
|
25
|
+
artifacts?: Artifacts;
|
|
26
|
+
};
|
|
12
27
|
export declare type BuildConfigBase = {
|
|
13
28
|
/**
|
|
14
29
|
* command to run on the image to start the app (e.g. yarn start)
|
|
@@ -33,30 +48,35 @@ export declare type BuildConfigBase = {
|
|
|
33
48
|
* customize docker build
|
|
34
49
|
*/
|
|
35
50
|
docker?: {
|
|
51
|
+
/**
|
|
52
|
+
* Custom Dockerfile lines integrated in the generated Dockerfile before the standard build steps.
|
|
53
|
+
*
|
|
54
|
+
* - [runner-images/docker-build/scripts/ensureNodeDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureNodeDockerfile)
|
|
55
|
+
* - [runner-images/docker-build/scripts/ensureNginxDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureNginxDockerfile)
|
|
56
|
+
* - [runner-images/docker-build/scripts/ensureMeteorDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureMeteorDockerfile)
|
|
57
|
+
*/
|
|
36
58
|
additionsBegin?: string[];
|
|
59
|
+
/**
|
|
60
|
+
* Custom Dockerfile lines integrated in the generated Dockerfile after the standard build steps.
|
|
61
|
+
*
|
|
62
|
+
* - [runner-images/docker-build/scripts/ensureNodeDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureNodeDockerfile)
|
|
63
|
+
* - [runner-images/docker-build/scripts/ensureNginxDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureNginxDockerfile)
|
|
64
|
+
* - [runner-images/docker-build/scripts/ensureMeteorDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureMeteorDockerfile)
|
|
65
|
+
*/
|
|
37
66
|
additionsEnd?: string[];
|
|
38
67
|
};
|
|
39
68
|
/**
|
|
40
69
|
* customize lint, set false to disable
|
|
41
70
|
*/
|
|
42
|
-
lint?: false |
|
|
43
|
-
command?: string | string[];
|
|
44
|
-
jobImage?: GitlabJobImage;
|
|
45
|
-
};
|
|
71
|
+
lint?: false | TestJobCustom;
|
|
46
72
|
/**
|
|
47
73
|
* customize test, set false to disable
|
|
48
74
|
*/
|
|
49
|
-
test?: false |
|
|
50
|
-
command?: string | string[];
|
|
51
|
-
jobImage?: GitlabJobImage;
|
|
52
|
-
};
|
|
75
|
+
test?: false | TestJobCustom;
|
|
53
76
|
/**
|
|
54
77
|
* customize audit, set false to disable
|
|
55
78
|
*/
|
|
56
|
-
audit?: false |
|
|
57
|
-
command?: string | string[];
|
|
58
|
-
jobImage?: GitlabJobImage;
|
|
59
|
-
};
|
|
79
|
+
audit?: false | TestJobCustom;
|
|
60
80
|
/**
|
|
61
81
|
* additional paths for artifacts,
|
|
62
82
|
* by default "dist" and ".next" are allways included
|
|
@@ -116,44 +136,23 @@ export declare type BuildConfigCustomDocker = BuildConfigBase["docker"] & ({
|
|
|
116
136
|
export declare type BuildConfigCustom = Omit<BuildConfigBase, "lint" | "test" | "audit"> & {
|
|
117
137
|
type: "custom";
|
|
118
138
|
jobImage: GitlabJobImage;
|
|
139
|
+
/**
|
|
140
|
+
* {@link GitlabJobService}s used in lint, test, audit, and build jobs.
|
|
141
|
+
*/
|
|
119
142
|
jobServices?: GitlabJobService[];
|
|
120
143
|
docker: BuildConfigCustomDocker;
|
|
121
144
|
/**
|
|
122
145
|
* custom lint, disabled when not set
|
|
123
146
|
*/
|
|
124
|
-
lint?:
|
|
125
|
-
command?: string | string[];
|
|
126
|
-
jobImage?: GitlabJobImage;
|
|
127
|
-
/**
|
|
128
|
-
* additional CI/CD artifacts reports,
|
|
129
|
-
* use to display information in merge requests, pipeline views and security dashboards.
|
|
130
|
-
*/
|
|
131
|
-
artifactsReports?: BuildConfigArtifactsReports;
|
|
132
|
-
};
|
|
147
|
+
lint?: TestJobCustom;
|
|
133
148
|
/**
|
|
134
149
|
* custom test, disabled when not set
|
|
135
150
|
*/
|
|
136
|
-
test?:
|
|
137
|
-
command?: string | string[];
|
|
138
|
-
jobImage?: GitlabJobImage;
|
|
139
|
-
/**
|
|
140
|
-
* additional CI/CD artifacts reports,
|
|
141
|
-
* use to display information in merge requests, pipeline views and security dashboards.
|
|
142
|
-
*/
|
|
143
|
-
artifactsReports?: BuildConfigArtifactsReports;
|
|
144
|
-
};
|
|
151
|
+
test?: TestJobCustom;
|
|
145
152
|
/**
|
|
146
153
|
* custom audit, disabled when not set
|
|
147
154
|
*/
|
|
148
|
-
audit?:
|
|
149
|
-
command?: string | string[];
|
|
150
|
-
jobImage?: GitlabJobImage;
|
|
151
|
-
/**
|
|
152
|
-
* additional CI/CD artifacts reports,
|
|
153
|
-
* use to display information in merge requests, pipeline views and security dashboards.
|
|
154
|
-
*/
|
|
155
|
-
artifactsReports?: BuildConfigArtifactsReports;
|
|
156
|
-
};
|
|
155
|
+
audit?: TestJobCustom;
|
|
157
156
|
/**
|
|
158
157
|
* custom sbom (software bill of materials), set false to disable
|
|
159
158
|
*/
|