@catladder/pipeline 1.99.0 โ†’ 1.100.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.
Files changed (28) hide show
  1. package/dist/build/custom/testJob.js +26 -12
  2. package/dist/build/node/buildJob.js +1 -7
  3. package/dist/build/node/yarn.d.ts +2 -5
  4. package/dist/build/node/yarn.js +27 -15
  5. package/dist/build/types.d.ts +25 -9
  6. package/dist/bundles/catladder-gitlab/index.js +1 -1
  7. package/dist/constants.js +1 -1
  8. package/dist/pipeline/packageManager.js +4 -4
  9. package/dist/tsconfig.tsbuildinfo +1 -1
  10. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +24 -12
  11. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +24 -12
  12. package/examples/__snapshots__/cloud-run-non-public.ts.snap +24 -12
  13. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +48 -24
  14. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +48 -24
  15. package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +50 -0
  16. package/examples/__snapshots__/custom-deploy.ts.snap +24 -12
  17. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +24 -12
  18. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +24 -12
  19. package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +24 -12
  20. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +48 -24
  21. package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +24 -12
  22. package/examples/custom-build-job-with-tests.ts +9 -0
  23. package/package.json +1 -1
  24. package/src/build/custom/testJob.ts +36 -0
  25. package/src/build/node/buildJob.ts +3 -8
  26. package/src/build/node/yarn.ts +38 -25
  27. package/src/build/types.ts +26 -9
  28. package/src/pipeline/packageManager.ts +7 -6
@@ -43,6 +43,7 @@ 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");
46
47
  var utils_1 = require("../../utils");
47
48
  var types_1 = require("../types");
48
49
  var RUNNER_CUSTOM_TEST_VARIABLES = {
@@ -52,7 +53,7 @@ var RUNNER_CUSTOM_TEST_VARIABLES = {
52
53
  KUBERNETES_MEMORY_LIMIT: "4Gi"
53
54
  };
54
55
  var createCustomTestJobs = function (context) {
55
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
56
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
56
57
  // don't run tests after release
57
58
  if (((_a = context.commitInfo) === null || _a === void 0 ? void 0 : _a.trigger) === "taggedRelease") {
58
59
  return [];
@@ -71,26 +72,39 @@ var createCustomTestJobs = function (context) {
71
72
  needs: [],
72
73
  envMode: "none"
73
74
  };
74
- var auditJob = buildConfig.audit ? __assign(__assign({
75
+ var auditJob = buildConfig.audit ? __assign(__assign(__assign({
75
76
  name: "๐Ÿ›ก audit"
76
77
  }, base), {
77
78
  image: (_d = (_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.jobImage) !== null && _d !== void 0 ? _d : buildConfig.jobImage,
78
79
  cache: undefined,
79
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),
80
81
  allow_failure: true
81
- }) : null;
82
- var lintJob = buildConfig.lint ? __assign(__assign({
82
+ }), createArtifactsConfig(context.componentConfig.dir, (_g = buildConfig.audit) === null || _g === void 0 ? void 0 : _g.artifactsReports)) : null;
83
+ var lintJob = buildConfig.lint ? __assign(__assign(__assign({
83
84
  name: "๐Ÿ‘ฎ lint"
84
85
  }, base), {
85
- image: (_h = (_g = buildConfig.lint) === null || _g === void 0 ? void 0 : _g.jobImage) !== null && _h !== void 0 ? _h : buildConfig.jobImage,
86
- script: __spreadArray([], __read((_k = (0, utils_1.ensureArray)((_j = buildConfig.lint) === null || _j === void 0 ? void 0 : _j.command)) !== null && _k !== void 0 ? _k : []), false)
87
- }) : null;
88
- var testJob = buildConfig.test ? __assign(__assign({
86
+ image: (_j = (_h = buildConfig.lint) === null || _h === void 0 ? void 0 : _h.jobImage) !== null && _j !== void 0 ? _j : buildConfig.jobImage,
87
+ script: __spreadArray([], __read((_l = (0, utils_1.ensureArray)((_k = buildConfig.lint) === null || _k === void 0 ? void 0 : _k.command)) !== null && _l !== void 0 ? _l : []), false)
88
+ }), createArtifactsConfig(context.componentConfig.dir, (_m = buildConfig.lint) === null || _m === void 0 ? void 0 : _m.artifactsReports)) : null;
89
+ var testJob = buildConfig.test ? __assign(__assign(__assign({
89
90
  name: "๐Ÿงช test"
90
91
  }, base), {
91
- image: (_m = (_l = buildConfig.test) === null || _l === void 0 ? void 0 : _l.jobImage) !== null && _m !== void 0 ? _m : buildConfig.jobImage,
92
- script: __spreadArray([], __read((_p = (0, utils_1.ensureArray)((_o = buildConfig.test) === null || _o === void 0 ? void 0 : _o.command)) !== null && _p !== void 0 ? _p : []), false)
93
- }) : null;
92
+ image: (_p = (_o = buildConfig.test) === null || _o === void 0 ? void 0 : _o.jobImage) !== null && _p !== void 0 ? _p : buildConfig.jobImage,
93
+ script: __spreadArray([], __read((_r = (0, utils_1.ensureArray)((_q = buildConfig.test) === null || _q === void 0 ? void 0 : _q.command)) !== null && _r !== void 0 ? _r : []), false)
94
+ }), createArtifactsConfig(context.componentConfig.dir, (_s = buildConfig.test) === null || _s === void 0 ? void 0 : _s.artifactsReports)) : null;
94
95
  return [auditJob, lintJob, testJob].filter(utils_1.notNil);
95
96
  };
96
- exports.createCustomTestJobs = createCustomTestJobs;
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
+ };
@@ -74,13 +74,7 @@ var createNodeBuildJobs = function (context) {
74
74
  cache: __spreadArray([], __read((0, cache_1.getYarnCache)(context, "pull")), false),
75
75
  variables: {
76
76
  // only required for non static
77
- YARN_INSTALL: (0, yarn_1.getYarnInstallCommand)(context, {
78
- prodOnly: true
79
- }),
80
- YARN_INSTALL_WITHOUT_SCRIPTS: (0, yarn_1.getYarnInstallCommand)(context, {
81
- prodOnly: true,
82
- noScripts: true
83
- }),
77
+ DOCKER_COPY_AND_INSTALL_APP: (0, yarn_1.getDockerAppCopyAndBuildScript)(context),
84
78
  DOCKER_COPY_WORKSPACE_FILES: (_e = (_d = context.packageManagerInfo) === null || _d === void 0 ? void 0 : _d.pathsToCopyInDocker.map(function (dir) {
85
79
  return "COPY --chown=node:node ".concat(dir, " /app/").concat(dir);
86
80
  })) === null || _e === void 0 ? void 0 : _e.join("\n")
@@ -1,7 +1,4 @@
1
1
  import type { Context } from "../../types";
2
- export declare const getYarnInstallCommand: (context: Context, options?: {
3
- prodOnly?: boolean | undefined;
4
- noScripts?: boolean | undefined;
5
- } | undefined) => string;
6
2
  export declare const ensureNodeVersion: (context: Context) => string[];
7
- export declare const getYarnInstall: (context: Context) => string[];
3
+ export declare const getYarnInstall: (context: Context) => string[];
4
+ export declare const getDockerAppCopyAndBuildScript: (context: Context) => string;
@@ -32,28 +32,40 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
32
32
  return to.concat(ar || Array.prototype.slice.call(from));
33
33
  };
34
34
  exports.__esModule = true;
35
- exports.getYarnInstall = exports.ensureNodeVersion = exports.getYarnInstallCommand = void 0;
36
- var getYarnInstallCommand = function (context, options) {
35
+ exports.getDockerAppCopyAndBuildScript = exports.getYarnInstall = exports.ensureNodeVersion = void 0;
36
+ var YARN_INSTALL_CLASSIC = "yarn install --frozen-lockfile";
37
+ // FIXME: check why and when rebuild is needed
38
+ var YARN_BERRY_PROD_REBUILD = "yarn workspaces focus --production && yarn rebuild";
39
+ var getYarnInstallCommand = function (context) {
37
40
  var _a;
38
41
  if ((_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.isClassic) {
39
- return "yarn install --frozen-lockfile ".concat((options === null || options === void 0 ? void 0 : options.prodOnly) ? "--production" : "", " ").concat((options === null || options === void 0 ? void 0 : options.noScripts) ? "--ignore-scripts" : "");
42
+ return YARN_INSTALL_CLASSIC;
40
43
  }
41
- // is modern
42
- // yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
43
- // trying to import those fail on this version
44
- var doesNotShipWithBuiltInPlugins = ["2", "3"].some(function (v) {
45
- var _a;
46
- return (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.version.startsWith(v);
47
- });
48
- return (options === null || options === void 0 ? void 0 : options.prodOnly) ? "".concat((options === null || options === void 0 ? void 0 : options.noScripts) ? "YARN_ENABLE_SCRIPTS=false " : "").concat(doesNotShipWithBuiltInPlugins ? "yarn plugin import workspace-tools && " : " ", "yarn workspaces focus --production && yarn rebuild") // needs yarn plugin import workspace-tools
49
- : "".concat((options === null || options === void 0 ? void 0 : options.noScripts) ? "YARN_ENABLE_SCRIPTS=false " : "", "yarn install --immutable");
44
+ return "yarn install --immutable";
50
45
  };
51
- exports.getYarnInstallCommand = getYarnInstallCommand;
52
46
  var ensureNodeVersion = function (context) {
53
47
  return ["if [ -f ./.nvmrc ]; then source /root/.nvm/nvm.sh && nvm install <<< .nvmrc; fi"];
54
48
  };
55
49
  exports.ensureNodeVersion = ensureNodeVersion;
56
50
  var getYarnInstall = function (context) {
57
- return __spreadArray(__spreadArray([], __read((0, exports.ensureNodeVersion)(context)), false), [(0, exports.getYarnInstallCommand)(context)], false);
51
+ return __spreadArray(__spreadArray([], __read((0, exports.ensureNodeVersion)(context)), false), [getYarnInstallCommand(context)], false);
52
+ };
53
+ exports.getYarnInstall = getYarnInstall;
54
+ var DOCKER_COPY_FILES = "COPY --chown=node:node $APP_DIR .";
55
+ var getDockerAppCopyAndBuildScript = function (context) {
56
+ var _a;
57
+ if ((_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.isClassic) {
58
+ return "\nRUN ".concat(YARN_INSTALL_CLASSIC, " --production --ignore-scripts\n").concat(DOCKER_COPY_FILES, "\nRUN ").concat(YARN_INSTALL_CLASSIC, " --production \n ").trim();
59
+ }
60
+ // yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
61
+ // trying to import those fail on this version
62
+ var doesNotShipWithBuiltInPlugins = ["2", "3"].some(function (v) {
63
+ var _a;
64
+ return (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.version.startsWith(v);
65
+ });
66
+ var maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins ? "RUN yarn plugin import workspace-tools" : "";
67
+ // copy first everything and then install
68
+ // rebuild first does not work as it will run postinstall and that might require files in the app
69
+ return "\n".concat(DOCKER_COPY_FILES, "\n").concat(maybeAddWorkspaceToolsCommand, "\nRUN ").concat(YARN_BERRY_PROD_REBUILD, "\n\n ").trim();
58
70
  };
59
- exports.getYarnInstall = getYarnInstall;
71
+ exports.getDockerAppCopyAndBuildScript = getDockerAppCopyAndBuildScript;
@@ -1,5 +1,14 @@
1
1
  import type { GitlabJobImage, GitlabJobService } from "../types";
2
2
  import type { CatladderJob } from "../types/jobs";
3
+ export declare type BuildConfigArtifactsReports = {
4
+ /**
5
+ * The junit report collects JUnit report format XML files.
6
+ * The collected Unit test reports upload to GitLab as an artifact.
7
+ * Paths are prefixed with component's root folder.
8
+ * eg. `["dist/test-results/TEST-*.xml", "dist/rspec.xml", ...]`
9
+ */
10
+ junit?: string[];
11
+ };
3
12
  export declare type BuildConfigBase = {
4
13
  /**
5
14
  * command to run on the image to start the app (e.g. yarn start)
@@ -50,15 +59,7 @@ export declare type BuildConfigBase = {
50
59
  * additional CI/CD artifacts reports,
51
60
  * use to display information in merge requests, pipeline views and security dashboards.
52
61
  */
53
- artifactsReports?: {
54
- /**
55
- * The junit report collects JUnit report format XML files.
56
- * The collected Unit test reports upload to GitLab as an artifact.
57
- * Paths are prefixed with component's root folder.
58
- * eg. `["dist/test-results/TEST-*.xml", "dist/rspec.xml", ...]`
59
- */
60
- junit?: string[];
61
- };
62
+ artifactsReports?: BuildConfigArtifactsReports;
62
63
  };
63
64
  export declare type BuildConfigNodeBase = BuildConfigBase;
64
65
  export declare type BuildConfigNode = {
@@ -102,6 +103,11 @@ export declare type BuildConfigCustom = Omit<BuildConfigBase, "lint" | "test" |
102
103
  lint?: {
103
104
  command?: string | string[];
104
105
  jobImage?: GitlabJobImage;
106
+ /**
107
+ * additional CI/CD artifacts reports,
108
+ * use to display information in merge requests, pipeline views and security dashboards.
109
+ */
110
+ artifactsReports?: BuildConfigArtifactsReports;
105
111
  };
106
112
  /**
107
113
  * custom test, disabled when not set
@@ -109,6 +115,11 @@ export declare type BuildConfigCustom = Omit<BuildConfigBase, "lint" | "test" |
109
115
  test?: {
110
116
  command?: string | string[];
111
117
  jobImage?: GitlabJobImage;
118
+ /**
119
+ * additional CI/CD artifacts reports,
120
+ * use to display information in merge requests, pipeline views and security dashboards.
121
+ */
122
+ artifactsReports?: BuildConfigArtifactsReports;
112
123
  };
113
124
  /**
114
125
  * custom audit, disabled when not set
@@ -116,6 +127,11 @@ export declare type BuildConfigCustom = Omit<BuildConfigBase, "lint" | "test" |
116
127
  audit?: {
117
128
  command?: string | string[];
118
129
  jobImage?: GitlabJobImage;
130
+ /**
131
+ * additional CI/CD artifacts reports,
132
+ * use to display information in merge requests, pipeline views and security dashboards.
133
+ */
134
+ artifactsReports?: BuildConfigArtifactsReports;
119
135
  };
120
136
  /**
121
137
  * custom sbom (software bill of materials), set false to disable