@catladder/pipeline 0.0.0-refactor-env-context-834a2b56 → 0.0.0-refactor-needs-c896b98e

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 (166) hide show
  1. package/bin/catladder-gitlab-dev.js +3 -0
  2. package/dist/build/base/createBuildJob.js +15 -30
  3. package/dist/build/base/writeBuildInfo.d.ts +2 -0
  4. package/dist/build/base/{getBuildInfo.js → writeBuildInfo.js} +3 -6
  5. package/dist/build/custom/buildJob.d.ts +3 -0
  6. package/dist/build/custom/buildJob.js +82 -0
  7. package/dist/build/custom/index.d.ts +3 -0
  8. package/dist/build/custom/index.js +40 -0
  9. package/dist/build/docker.js +5 -40
  10. package/dist/build/index.js +14 -6
  11. package/dist/build/node/buildJob.js +3 -25
  12. package/dist/build/node/cache.js +10 -21
  13. package/dist/build/node/index.js +3 -16
  14. package/dist/build/node/meteor.js +3 -20
  15. package/dist/build/node/testJob.js +5 -22
  16. package/dist/build/node/yarn.js +6 -19
  17. package/dist/build/rails/build.d.ts +3 -0
  18. package/dist/build/rails/build.js +30 -0
  19. package/dist/build/rails/index.d.ts +3 -0
  20. package/dist/build/rails/index.js +41 -0
  21. package/dist/build/rails/test.d.ts +3 -0
  22. package/dist/build/rails/test.js +94 -0
  23. package/dist/build/types.d.ts +43 -10
  24. package/dist/build/types.js +0 -4
  25. package/dist/bundles/catladder-gitlab/index.js +1626 -1576
  26. package/dist/catladder-gitlab.js +6 -24
  27. package/dist/config/{configruedEnvs.test.d.ts → __tests__/configruedEnvs.test.d.ts} +0 -0
  28. package/dist/config/{configruedEnvs.test.js → __tests__/configruedEnvs.test.js} +10 -12
  29. package/dist/config/configruedEnvs.js +7 -22
  30. package/dist/config/index.js +0 -4
  31. package/dist/config/readConfig.js +2 -13
  32. package/dist/constants.js +1 -1
  33. package/dist/context/{resolveReferences.test.d.ts → __tests__/resolveReferences.test.d.ts} +0 -0
  34. package/dist/context/{resolveReferences.test.js → __tests__/resolveReferences.test.js} +52 -103
  35. package/dist/context/getEnvConfig.js +1 -9
  36. package/dist/context/getEnvType.js +0 -5
  37. package/dist/context/getEnvironment.js +13 -49
  38. package/dist/context/getEnvironmentContext.js +0 -5
  39. package/dist/context/getEnvironmentVariables.js +23 -85
  40. package/dist/context/getLabels.js +2 -13
  41. package/dist/context/index.js +13 -58
  42. package/dist/context/resolveReferences.js +36 -126
  43. package/dist/deploy/base.js +5 -20
  44. package/dist/deploy/cloudRun/deployJob.js +115 -83
  45. package/dist/deploy/cloudRun/index.js +62 -27
  46. package/dist/deploy/cloudRun/utils/database.d.ts +4 -0
  47. package/dist/deploy/cloudRun/utils/database.js +64 -0
  48. package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.js +0 -4
  49. package/dist/deploy/cloudRun/utils/jobName.d.ts +1 -0
  50. package/dist/deploy/cloudRun/utils/jobName.js +8 -0
  51. package/dist/deploy/custom/deployJob.js +7 -16
  52. package/dist/deploy/custom/index.js +0 -2
  53. package/dist/deploy/dockerTag/deployJob.js +0 -9
  54. package/dist/deploy/dockerTag/index.js +0 -2
  55. package/dist/deploy/index.d.ts +2 -2
  56. package/dist/deploy/index.js +0 -13
  57. package/dist/deploy/kubernetes/additionalSecretKeys.js +0 -9
  58. package/dist/deploy/kubernetes/cloudSql/index.d.ts +13 -0
  59. package/dist/deploy/kubernetes/cloudSql/index.js +30 -0
  60. package/dist/deploy/kubernetes/deployJob.js +3 -24
  61. package/dist/deploy/kubernetes/index.d.ts +1 -0
  62. package/dist/deploy/kubernetes/index.js +23 -14
  63. package/dist/deploy/kubernetes/kubeEnv.d.ts +0 -1
  64. package/dist/deploy/kubernetes/kubeEnv.js +5 -23
  65. package/dist/deploy/kubernetes/kubeValues.js +8 -28
  66. package/dist/deploy/kubernetes/mongodb.js +0 -24
  67. package/dist/deploy/kubernetes/processSecretsAsFiles.js +2 -10
  68. package/dist/deploy/types/base.d.ts +0 -1
  69. package/dist/deploy/types/custom.d.ts +9 -4
  70. package/dist/deploy/types/googleCloudRun.d.ts +68 -7
  71. package/dist/deploy/types/index.js +0 -10
  72. package/dist/deploy/types/kubernetes.d.ts +0 -28
  73. package/dist/deploy/utils.js +0 -11
  74. package/dist/index.js +0 -10
  75. package/dist/pipeline/commitInfo/getBuildId.d.ts +1 -0
  76. package/dist/pipeline/{createChildPipeline.test.js → commitInfo/getBuildId.js} +25 -84
  77. package/dist/pipeline/commitInfo/getCommitInfo.d.ts +2 -0
  78. package/dist/{build/tests/storybook.test.js → pipeline/commitInfo/getCommitInfo.js} +30 -104
  79. package/dist/pipeline/createChildPipeline.js +19 -76
  80. package/dist/pipeline/createJobs.js +39 -144
  81. package/dist/pipeline/gitlab/makeGitlabJob.d.ts +1 -0
  82. package/dist/pipeline/gitlab/makeGitlabJob.js +44 -15
  83. package/dist/pipeline/index.js +0 -4
  84. package/dist/pipeline/packageManager.js +20 -173
  85. package/dist/pipeline/yarn/yarnUtils.d.ts +4 -0
  86. package/dist/pipeline/yarn/yarnUtils.js +193 -0
  87. package/dist/rules/index.d.ts +2 -0
  88. package/dist/rules/index.js +7 -6
  89. package/dist/runner/index.js +0 -3
  90. package/dist/tsconfig.tsbuildinfo +1 -1
  91. package/dist/types/config.d.ts +13 -20
  92. package/dist/types/config.js +5 -15
  93. package/dist/types/context.d.ts +6 -2
  94. package/dist/types/environmentContext.d.ts +0 -1
  95. package/dist/types/gitlab-types.d.ts +13 -5
  96. package/dist/types/index.js +0 -6
  97. package/dist/types/jobs.d.ts +14 -17
  98. package/dist/types/utils.d.ts +1 -0
  99. package/dist/types/utils.js +3 -0
  100. package/dist/utils/gitlab.d.ts +5 -0
  101. package/dist/utils/gitlab.js +48 -0
  102. package/dist/utils/index.js +5 -15
  103. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +1765 -0
  104. package/examples/__snapshots__/custom-build-job.ts.snap +1174 -0
  105. package/examples/__snapshots__/custom-envs.ts.snap +261 -0
  106. package/examples/__snapshots__/wait-for-other-deploy.ts.snap +1626 -0
  107. package/examples/__utils__/helpers.ts +14 -0
  108. package/examples/cloud-run-with-sql.ts +38 -0
  109. package/examples/custom-build-job.ts +28 -0
  110. package/examples/custom-envs.ts +31 -0
  111. package/examples/wait-for-other-deploy.ts +36 -0
  112. package/package.json +3 -4
  113. package/src/build/base/createBuildJob.ts +9 -3
  114. package/src/build/base/{getBuildInfo.ts → writeBuildInfo.ts} +1 -1
  115. package/src/build/custom/buildJob.ts +63 -0
  116. package/src/build/custom/index.ts +7 -0
  117. package/src/build/index.ts +10 -0
  118. package/src/build/node/cache.ts +13 -5
  119. package/src/build/node/yarn.ts +1 -1
  120. package/src/build/rails/build.ts +28 -0
  121. package/src/build/rails/index.ts +8 -0
  122. package/src/build/rails/test.ts +82 -0
  123. package/src/build/types.ts +49 -1
  124. package/src/config/{configruedEnvs.test.ts → __tests__/configruedEnvs.test.ts} +3 -3
  125. package/src/context/{resolveReferences.test.ts → __tests__/resolveReferences.test.ts} +3 -3
  126. package/src/context/getEnvConfig.ts +1 -1
  127. package/src/context/getEnvironmentVariables.ts +2 -1
  128. package/src/context/index.ts +3 -2
  129. package/src/deploy/base.ts +1 -1
  130. package/src/deploy/cloudRun/deployJob.ts +139 -39
  131. package/src/deploy/cloudRun/index.ts +61 -5
  132. package/src/deploy/cloudRun/utils/database.ts +55 -0
  133. package/src/deploy/cloudRun/utils/jobName.ts +2 -0
  134. package/src/deploy/custom/deployJob.ts +3 -0
  135. package/src/deploy/index.ts +2 -2
  136. package/src/deploy/kubernetes/cloudSql/index.ts +28 -0
  137. package/src/deploy/kubernetes/index.ts +1 -1
  138. package/src/deploy/kubernetes/kubeValues.ts +3 -3
  139. package/src/deploy/types/custom.ts +11 -0
  140. package/src/deploy/types/googleCloudRun.ts +79 -3
  141. package/src/pipeline/commitInfo/getBuildId.ts +6 -0
  142. package/src/pipeline/commitInfo/getCommitInfo.ts +12 -0
  143. package/src/pipeline/createChildPipeline.ts +6 -1
  144. package/src/pipeline/createJobs.ts +15 -25
  145. package/src/pipeline/gitlab/makeGitlabJob.ts +9 -1
  146. package/src/pipeline/packageManager.ts +4 -38
  147. package/src/pipeline/yarn/yarnUtils.ts +37 -0
  148. package/src/rules/index.ts +8 -5
  149. package/src/types/config.ts +19 -8
  150. package/src/types/context.ts +8 -0
  151. package/src/types/gitlab-types.ts +15 -4
  152. package/src/types/jobs.ts +12 -3
  153. package/src/types/utils.ts +7 -0
  154. package/src/utils/gitlab.ts +23 -0
  155. package/tsconfig.json +1 -1
  156. package/dist/build/base/getBuildInfo.d.ts +0 -2
  157. package/dist/build/tests/storybook.test.d.ts +0 -1
  158. package/dist/deploy/cloudSql/index.d.ts +0 -8
  159. package/dist/deploy/cloudSql/index.js +0 -30
  160. package/dist/deploy/kubernetes/cloudsql.d.ts +0 -6
  161. package/dist/deploy/kubernetes/cloudsql.js +0 -16
  162. package/dist/pipeline/createChildPipeline.test.d.ts +0 -1
  163. package/src/build/tests/storybook.test.ts +0 -54
  164. package/src/deploy/cloudSql/index.ts +0 -16
  165. package/src/deploy/kubernetes/cloudsql.ts +0 -13
  166. package/src/pipeline/createChildPipeline.test.ts +0 -49
@@ -4,10 +4,9 @@ var __read = this && this.__read || function (o, n) {
4
4
  var m = typeof Symbol === "function" && o[Symbol.iterator];
5
5
  if (!m) return o;
6
6
  var i = m.call(o),
7
- r,
8
- ar = [],
9
- e;
10
-
7
+ r,
8
+ ar = [],
9
+ e;
11
10
  try {
12
11
  while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
13
12
  } catch (error) {
@@ -21,10 +20,8 @@ var __read = this && this.__read || function (o, n) {
21
20
  if (e) throw e.error;
22
21
  }
23
22
  }
24
-
25
23
  return ar;
26
24
  };
27
-
28
25
  var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
29
26
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
30
27
  if (ar || !(i in from)) {
@@ -34,26 +31,16 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
34
31
  }
35
32
  return to.concat(ar || Array.prototype.slice.call(from));
36
33
  };
37
-
38
34
  exports.__esModule = true;
39
35
  exports.createMeteorBuildJobs = void 0;
40
-
41
36
  var path_1 = require("path");
42
-
43
37
  var runner_1 = require("../../runner");
44
-
45
38
  var constants_1 = require("../base/constants");
46
-
47
39
  var createBuildJob_1 = require("../base/createBuildJob");
48
-
49
40
  var docker_1 = require("../docker");
50
-
51
41
  var types_1 = require("../types");
52
-
53
42
  var cache_1 = require("./cache");
54
-
55
43
  var yarn_1 = require("./yarn");
56
-
57
44
  var getMeteorCache = function (context) {
58
45
  return [{
59
46
  key: context.componentName + "meteor-build-cache",
@@ -61,14 +48,11 @@ var getMeteorCache = function (context) {
61
48
  paths: [(0, path_1.join)(context.componentConfig.dir, ".meteor/local/resolver-result-cache.json"), (0, path_1.join)(context.componentConfig.dir, ".meteor/local/plugin-cache"), (0, path_1.join)(context.componentConfig.dir, ".meteor/local/isopacks"), (0, path_1.join)(context.componentConfig.dir, ".meteor/local/bundler-cache/scanner")]
62
49
  }];
63
50
  };
64
-
65
51
  var createMeteorBuildJobs = function (context) {
66
52
  var buildConfig = context.componentConfig.build;
67
-
68
53
  if (!(0, types_1.isOfBuildType)(buildConfig, "meteor")) {
69
54
  throw new Error("deploy config is not meteor");
70
55
  }
71
-
72
56
  var yarnInstall = (0, yarn_1.getYarnInstall)(context);
73
57
  var appBuildJob = buildConfig.buildCommand !== null ? (0, createBuildJob_1.createBuildJob)(context, {
74
58
  cache: __spreadArray(__spreadArray([], __read((0, cache_1.getNodeCache)(context)), false), __read(getMeteorCache(context)), false),
@@ -89,5 +73,4 @@ var createMeteorBuildJobs = function (context) {
89
73
  needs: appBuildJob ? [constants_1.APP_BUILD_JOB_NAME] : []
90
74
  })], false);
91
75
  };
92
-
93
76
  exports.createMeteorBuildJobs = createMeteorBuildJobs;
@@ -4,24 +4,19 @@ var __assign = this && this.__assign || function () {
4
4
  __assign = Object.assign || function (t) {
5
5
  for (var s, i = 1, n = arguments.length; i < n; i++) {
6
6
  s = arguments[i];
7
-
8
7
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
9
8
  }
10
-
11
9
  return t;
12
10
  };
13
-
14
11
  return __assign.apply(this, arguments);
15
12
  };
16
-
17
13
  var __read = this && this.__read || function (o, n) {
18
14
  var m = typeof Symbol === "function" && o[Symbol.iterator];
19
15
  if (!m) return o;
20
16
  var i = m.call(o),
21
- r,
22
- ar = [],
23
- e;
24
-
17
+ r,
18
+ ar = [],
19
+ e;
25
20
  try {
26
21
  while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
27
22
  } catch (error) {
@@ -35,10 +30,8 @@ var __read = this && this.__read || function (o, n) {
35
30
  if (e) throw e.error;
36
31
  }
37
32
  }
38
-
39
33
  return ar;
40
34
  };
41
-
42
35
  var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
43
36
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
44
37
  if (ar || !(i in from)) {
@@ -48,28 +41,19 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
48
41
  }
49
42
  return to.concat(ar || Array.prototype.slice.call(from));
50
43
  };
51
-
52
44
  exports.__esModule = true;
53
45
  exports.createNodeTestJobs = void 0;
54
-
55
46
  var runner_1 = require("../../runner");
56
-
57
47
  var utils_1 = require("../../utils");
58
-
59
48
  var cache_1 = require("./cache");
60
-
61
49
  var constants_1 = require("./constants");
62
-
63
50
  var yarn_1 = require("./yarn");
64
-
65
51
  var createNodeTestJobs = function (context) {
66
- var _a, _b, _c, _d, _e, _f, _g, _h, _j; // don't run tests after release
67
-
68
-
52
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
53
+ // don't run tests after release
69
54
  if (((_a = context.commitInfo) === null || _a === void 0 ? void 0 : _a.trigger) === "taggedRelease") {
70
55
  return [];
71
56
  }
72
-
73
57
  var buildConfig = context.componentConfig.build;
74
58
  var base = {
75
59
  variables: __assign(__assign({
@@ -103,5 +87,4 @@ var createNodeTestJobs = function (context) {
103
87
  }) : null;
104
88
  return [auditJob, lintJob, testJob].filter(utils_1.notNil);
105
89
  };
106
-
107
90
  exports.createNodeTestJobs = createNodeTestJobs;
@@ -4,10 +4,9 @@ var __read = this && this.__read || function (o, n) {
4
4
  var m = typeof Symbol === "function" && o[Symbol.iterator];
5
5
  if (!m) return o;
6
6
  var i = m.call(o),
7
- r,
8
- ar = [],
9
- e;
10
-
7
+ r,
8
+ ar = [],
9
+ e;
11
10
  try {
12
11
  while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
13
12
  } catch (error) {
@@ -21,10 +20,8 @@ var __read = this && this.__read || function (o, n) {
21
20
  if (e) throw e.error;
22
21
  }
23
22
  }
24
-
25
23
  return ar;
26
24
  };
27
-
28
25
  var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
29
26
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
30
27
  if (ar || !(i in from)) {
@@ -34,39 +31,29 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
34
31
  }
35
32
  return to.concat(ar || Array.prototype.slice.call(from));
36
33
  };
37
-
38
34
  exports.__esModule = true;
39
35
  exports.getYarnInstall = exports.ensureNodeVersion = exports.getYarnInstallCommand = void 0;
40
-
41
36
  var getYarnInstallCommand = function (context, options) {
42
37
  var _a;
43
-
44
38
  if ((_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.isClassic) {
45
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" : "");
46
- } // is modern
40
+ }
41
+ // is modern
47
42
  // yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
48
43
  // trying to import those fail on this version
49
-
50
-
51
44
  var doesNotShipWithBuiltInPlugins = ["2", "3"].some(function (v) {
52
45
  var _a;
53
-
54
46
  return (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.version.startsWith(v);
55
47
  });
56
- 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") // needs yarn plugin import workspace-tools
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
57
49
  : "".concat((options === null || options === void 0 ? void 0 : options.noScripts) ? "YARN_ENABLE_SCRIPTS=false " : "", "yarn install --immutable");
58
50
  };
59
-
60
51
  exports.getYarnInstallCommand = getYarnInstallCommand;
61
-
62
52
  var ensureNodeVersion = function (context) {
63
53
  return ["if [ -f ./.nvmrc ]; then source /root/.nvm/nvm.sh && nvm install <<< .nvmrc; fi"];
64
54
  };
65
-
66
55
  exports.ensureNodeVersion = ensureNodeVersion;
67
-
68
56
  var getYarnInstall = function (context) {
69
57
  return __spreadArray(__spreadArray([], __read((0, exports.ensureNodeVersion)(context)), false), [(0, exports.getYarnInstallCommand)(context)], false);
70
58
  };
71
-
72
59
  exports.getYarnInstall = getYarnInstall;
@@ -0,0 +1,3 @@
1
+ import type { Context } from "../..";
2
+ import type { CatladderJob } from "../../types/jobs";
3
+ export declare const createRailsBuildJobs: (context: Context) => CatladderJob[];
@@ -0,0 +1,30 @@
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
+ exports.__esModule = true;
14
+ exports.createRailsBuildJobs = void 0;
15
+ var docker_1 = require("../docker");
16
+ var createRailsBuildJobs = function (context) {
17
+ return [(0, docker_1.createDockerBuildJobBase)(context, {
18
+ variables: __assign({
19
+ CNB_BUILDER: "heroku/buildpacks:18",
20
+ CNB_ENV_VARS: "BUNDLE_GIT__PANTER__CH",
21
+ CNB_EXTRA_ARGS: "",
22
+ CNB_PACK_VERSION: "0.20.0"
23
+ }, context.componentConfig.build.extraVars),
24
+ // custom script
25
+ script: [docker_1.gitlabDockerLogin, "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v$CNB_PACK_VERSION/pack-v$CNB_PACK_VERSION-linux.tgz | tar -zx --directory /usr/local/bin pack", "chmod +x /usr/local/bin/pack",
26
+ // replace private git ssh gem sources with https to make bundler with credentials via env var work
27
+ "sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "for v in $CNB_ENV_VARS; do env_args=\"$env_args --env $v\"; done", "pack build $DOCKER_IMAGE:$DOCKER_IMAGE_TAG --builder $CNB_BUILDER --publish --cache-image $DOCKER_CACHE_IMAGE $env_args $CNB_EXTRA_ARGS"]
28
+ })];
29
+ };
30
+ exports.createRailsBuildJobs = createRailsBuildJobs;
@@ -0,0 +1,3 @@
1
+ import { Context } from "../../types";
2
+ import { CatladderJob } from "../../types/jobs";
3
+ export declare const createRailsJobs: (context: Context) => CatladderJob[];
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var __read = this && this.__read || function (o, n) {
4
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
5
+ if (!m) return o;
6
+ var i = m.call(o),
7
+ r,
8
+ ar = [],
9
+ e;
10
+ try {
11
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12
+ } catch (error) {
13
+ e = {
14
+ error: error
15
+ };
16
+ } finally {
17
+ try {
18
+ if (r && !r.done && (m = i["return"])) m.call(i);
19
+ } finally {
20
+ if (e) throw e.error;
21
+ }
22
+ }
23
+ return ar;
24
+ };
25
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
26
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
27
+ if (ar || !(i in from)) {
28
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
29
+ ar[i] = from[i];
30
+ }
31
+ }
32
+ return to.concat(ar || Array.prototype.slice.call(from));
33
+ };
34
+ exports.__esModule = true;
35
+ exports.createRailsJobs = void 0;
36
+ var build_1 = require("./build");
37
+ var test_1 = require("./test");
38
+ var createRailsJobs = function (context) {
39
+ return __spreadArray(__spreadArray([], __read((0, test_1.createRailsTestJobs)(context)), false), __read((0, build_1.createRailsBuildJobs)(context)), false);
40
+ };
41
+ exports.createRailsJobs = createRailsJobs;
@@ -0,0 +1,3 @@
1
+ import type { Context } from "../..";
2
+ import type { CatladderJob } from "../../types/jobs";
3
+ export declare const createRailsTestJobs: (context: Context) => CatladderJob[];
@@ -0,0 +1,94 @@
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.createRailsTestJobs = void 0;
46
+ var utils_1 = require("../../utils");
47
+ var createRailsTestJobs = function (context) {
48
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
49
+ // don't run tests after release
50
+ if (((_a = context.commitInfo) === null || _a === void 0 ? void 0 : _a.trigger) === "taggedRelease") {
51
+ return [];
52
+ }
53
+ var buildConfig = context.componentConfig.build;
54
+ var base = {
55
+ variables: (_b = buildConfig.extraVars) !== null && _b !== void 0 ? _b : {},
56
+ stage: "test",
57
+ needs: [],
58
+ envMode: "none"
59
+ };
60
+ var defaultImage = "docker.io/ruby";
61
+ var bundlerCacheDir = "tmp/cache";
62
+ var bundlerInstall = ["bundle config set path '".concat(bundlerCacheDir, "'"), "bundle install -j $(nproc)"];
63
+ var bundlerCache = {
64
+ key: {
65
+ files: ["Gemfile.lock"],
66
+ prefix: "$CI_JOB_IMAGE"
67
+ },
68
+ paths: [bundlerCacheDir]
69
+ };
70
+ var auditJob = buildConfig.audit !== false ? __assign(__assign({
71
+ name: "🛡 audit"
72
+ }, base), {
73
+ cache: undefined,
74
+ image: (_d = (_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.jobImage) !== null && _d !== void 0 ? _d : defaultImage,
75
+ 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 : ["gem install bundler-audit", "bundle audit check"]), false),
76
+ allow_failure: true
77
+ }) : null;
78
+ var lintJob = buildConfig.lint !== false ? __assign(__assign({
79
+ name: "👮 lint"
80
+ }, base), {
81
+ cache: bundlerCache,
82
+ image: (_h = (_g = buildConfig.lint) === null || _g === void 0 ? void 0 : _g.jobImage) !== null && _h !== void 0 ? _h : defaultImage,
83
+ script: __spreadArray(__spreadArray(["cd ".concat(context.componentConfig.dir)], __read(bundlerInstall), false), __read((_k = (0, utils_1.ensureArray)((_j = buildConfig.lint) === null || _j === void 0 ? void 0 : _j.command)) !== null && _k !== void 0 ? _k : ["bundle exec rubocop"]), false)
84
+ }) : null;
85
+ var testJob = buildConfig.test !== false ? __assign(__assign({
86
+ name: "🧪 test"
87
+ }, base), {
88
+ cache: bundlerCache,
89
+ image: (_m = (_l = buildConfig.test) === null || _l === void 0 ? void 0 : _l.jobImage) !== null && _m !== void 0 ? _m : defaultImage,
90
+ script: __spreadArray(__spreadArray(["cd ".concat(context.componentConfig.dir)], __read(bundlerInstall), false), __read((_p = (0, utils_1.ensureArray)((_o = buildConfig.test) === null || _o === void 0 ? void 0 : _o.command)) !== null && _p !== void 0 ? _p : ["bundle exec rspec"]), false)
91
+ }) : null;
92
+ return [auditJob, lintJob, testJob].filter(utils_1.notNil);
93
+ };
94
+ exports.createRailsTestJobs = createRailsTestJobs;
@@ -1,3 +1,4 @@
1
+ import type { GitlabJobService } from "../types";
1
2
  export declare type BuildConfigBase = {
2
3
  /**
3
4
  * command to run on the image to start the app (e.g. yarn start)
@@ -6,17 +7,14 @@ export declare type BuildConfigBase = {
6
7
  /**
7
8
  * additional env vars for the buid jobs
8
9
  */
9
-
10
10
  extraVars?: Record<string, string>;
11
11
  /**
12
12
  * define the build command
13
13
  */
14
-
15
14
  buildCommand?: string | string[] | null;
16
15
  /**
17
16
  * customize docker build
18
17
  */
19
-
20
18
  docker?: {
21
19
  additionsBegin?: string[];
22
20
  additionsEnd?: string[];
@@ -24,30 +22,42 @@ export declare type BuildConfigBase = {
24
22
  /**
25
23
  * customize lint, set false to disable
26
24
  */
27
-
28
25
  lint?: false | {
29
26
  command?: string | string[];
27
+ jobImage?: string;
30
28
  };
31
29
  /**
32
30
  * customize test, set false to disable
33
31
  */
34
-
35
32
  test?: false | {
36
33
  command?: string | string[];
34
+ jobImage?: string;
37
35
  };
38
36
  /**
39
37
  * customize audit, set false to disable
40
38
  */
41
-
42
39
  audit?: false | {
43
40
  command?: string | string[];
41
+ jobImage?: string;
44
42
  };
45
43
  /**
46
44
  * additional paths for artifacts,
47
45
  * by default "dist" and ".next" are allways included
48
46
  */
49
-
50
47
  artifactsPaths?: string[];
48
+ /**
49
+ * additional CI/CD artifacts reports,
50
+ * use to display information in merge requests, pipeline views and security dashboards.
51
+ */
52
+ artifactsReports?: {
53
+ /**
54
+ * The junit report collects JUnit report format XML files.
55
+ * The collected Unit test reports upload to GitLab as an artifact.
56
+ * Paths are prefixed with component's root folder.
57
+ * eg. `["dist/test-results/TEST-*.xml", "dist/rspec.xml", ...]`
58
+ */
59
+ junit?: string[];
60
+ };
51
61
  };
52
62
  export declare type BuildConfigNodeBase = BuildConfigBase;
53
63
  export declare type BuildConfigNode = {
@@ -63,24 +73,47 @@ export declare type BuildConfigMeteor = BuildConfigNodeBase & {
63
73
  * whether to run yarn install inside the source folder in the docker image.
64
74
  * This is only required if you have custom scripts in your image
65
75
  */
66
-
67
76
  installScripts?: boolean;
68
77
  };
78
+ export declare type BuildConfigCustomDocker = BuildConfigBase["docker"] & ({
79
+ /**
80
+ * use the built-in nginx image for simple static apps
81
+ */
82
+ type: "nginx";
83
+ } | {
84
+ /**
85
+ * custom docker build, expect that a Dockerfile in your directory
86
+ */
87
+ type: "custom";
88
+ });
89
+ export declare type BuildConfigCustom = BuildConfigBase & {
90
+ type: "custom";
91
+ jobImage: string;
92
+ jobServices?: GitlabJobService[];
93
+ docker: BuildConfigCustomDocker;
94
+ };
95
+ export declare type BuildConfigRails = BuildConfigBase & {
96
+ type: "rails";
97
+ };
69
98
  export declare type BuildConfigStorybook = BuildConfigNodeBase & {
70
99
  type: "storybook";
71
100
  startCommand?: never;
72
101
  };
73
- export declare type BuildConfig = BuildConfigNode | BuildConfigNodeStatic | BuildConfigStorybook | BuildConfigMeteor;
102
+ export declare type BuildConfig = BuildConfigNode | BuildConfigNodeStatic | BuildConfigStorybook | BuildConfigMeteor | BuildConfigCustom | BuildConfigRails;
74
103
  export declare type BuildConfigType = BuildConfig["type"];
75
104
  export declare type BuildConfigGeneric<T extends BuildConfigType> = Extract<BuildConfig, {
76
105
  type: T;
77
106
  }>;
78
- export declare const isOfBuildType: <T extends ("node" | "node-static" | "meteor" | "storybook")[]>(t: BuildConfig, ...types: T) => t is Extract<BuildConfigNode, {
107
+ export declare const isOfBuildType: <T extends ("node" | "node-static" | "meteor" | "custom" | "rails" | "storybook")[]>(t: BuildConfig, ...types: T) => t is Extract<BuildConfigNode, {
79
108
  type: T[number];
80
109
  }> | Extract<BuildConfigNodeStatic, {
81
110
  type: T[number];
82
111
  }> | Extract<BuildConfigMeteor, {
83
112
  type: T[number];
113
+ }> | Extract<BuildConfigCustom, {
114
+ type: T[number];
115
+ }> | Extract<BuildConfigRails, {
116
+ type: T[number];
84
117
  }> | Extract<BuildConfigStorybook, {
85
118
  type: T[number];
86
119
  }>;
@@ -2,15 +2,11 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.isOfBuildType = void 0;
5
-
6
5
  var isOfBuildType = function (t) {
7
6
  var types = [];
8
-
9
7
  for (var _i = 1; _i < arguments.length; _i++) {
10
8
  types[_i - 1] = arguments[_i];
11
9
  }
12
-
13
10
  return types.includes(t.type);
14
11
  };
15
-
16
12
  exports.isOfBuildType = isOfBuildType;