@catladder/pipeline 0.0.0-refactor-gcloud-api-5bd4bbed → 0.0.0-refactor-gitlab-jobs-9e285eaf

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 (84) hide show
  1. package/dist/build/custom/buildJob.js +1 -0
  2. package/dist/build/index.js +7 -1
  3. package/dist/build/rails/build.js +41 -16
  4. package/dist/build/rails/index.d.ts +2 -2
  5. package/dist/build/types.d.ts +36 -4
  6. package/dist/bundles/catladder-gitlab/index.js +512 -205
  7. package/dist/constants.js +1 -1
  8. package/dist/context/__tests__/resolveReferences.test.js +15 -20
  9. package/dist/context/getEnvironment.js +1 -0
  10. package/dist/context/getEnvironmentContext.js +5 -3
  11. package/dist/context/getEnvironmentVariables.js +2 -2
  12. package/dist/context/resolveReferences.d.ts +1 -1
  13. package/dist/context/resolveReferences.js +3 -1
  14. package/dist/deploy/base.js +1 -1
  15. package/dist/deploy/cloudRun/deployJob.js +9 -7
  16. package/dist/deploy/cloudRun/index.js +7 -6
  17. package/dist/deploy/cloudRun/utils/createArgsString.d.ts +1 -1
  18. package/dist/deploy/cloudRun/utils/createArgsString.js +6 -1
  19. package/dist/deploy/kubernetes/deployJob.js +4 -4
  20. package/dist/deploy/kubernetes/kubeValues.d.ts +3 -0
  21. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +3 -0
  22. package/dist/deploy/types/custom.d.ts +2 -1
  23. package/dist/deploy/types/googleCloudRun.d.ts +11 -2
  24. package/dist/deploy/types/kubernetes.d.ts +11 -0
  25. package/dist/pipeline/createAllJobs.d.ts +8 -0
  26. package/dist/pipeline/createAllJobs.js +164 -0
  27. package/dist/pipeline/createChildPipeline.js +24 -48
  28. package/dist/pipeline/createJobsForComponent.d.ts +3 -0
  29. package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +8 -105
  30. package/dist/pipeline/gitlab/createGitlabJobs.d.ts +14 -0
  31. package/dist/pipeline/gitlab/createGitlabJobs.js +256 -0
  32. package/dist/pipeline/index.d.ts +1 -1
  33. package/dist/pipeline/index.js +1 -1
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/dist/types/context.d.ts +1 -0
  36. package/dist/types/environmentContext.d.ts +7 -0
  37. package/dist/types/gitlab-types.d.ts +25 -1
  38. package/dist/types/jobs.d.ts +9 -2
  39. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +1572 -0
  40. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +1572 -0
  41. package/examples/__snapshots__/cloud-run-non-public.ts.snap +48 -48
  42. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +3116 -0
  43. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +108 -108
  44. package/examples/__snapshots__/custom-build-job.ts.snap +48 -48
  45. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +24 -24
  46. package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1911 -0
  47. package/examples/cloud-run-memory-limit.ts +28 -0
  48. package/examples/cloud-run-no-cpu-throttling.ts +33 -0
  49. package/examples/cloud-run-with-sql-reuse-db.ts +54 -0
  50. package/examples/cloud-run-with-sql.ts +1 -1
  51. package/examples/rails-k8s-with-worker.ts +95 -0
  52. package/package.json +1 -1
  53. package/src/build/custom/buildJob.ts +1 -0
  54. package/src/build/index.ts +7 -1
  55. package/src/build/rails/build.ts +17 -10
  56. package/src/build/rails/index.ts +2 -2
  57. package/src/build/types.ts +40 -5
  58. package/src/context/__tests__/resolveReferences.test.ts +15 -30
  59. package/src/context/getEnvironment.ts +1 -0
  60. package/src/context/getEnvironmentContext.ts +6 -6
  61. package/src/context/getEnvironmentVariables.ts +7 -5
  62. package/src/context/resolveReferences.ts +3 -6
  63. package/src/deploy/base.ts +1 -1
  64. package/src/deploy/cloudRun/deployJob.ts +9 -11
  65. package/src/deploy/cloudRun/index.ts +5 -4
  66. package/src/deploy/cloudRun/utils/createArgsString.ts +9 -2
  67. package/src/deploy/kubernetes/deployJob.ts +1 -1
  68. package/src/deploy/types/custom.ts +2 -1
  69. package/src/deploy/types/googleCloudRun.ts +14 -2
  70. package/src/deploy/types/kubernetes.ts +12 -0
  71. package/src/pipeline/createAllJobs.ts +38 -0
  72. package/src/pipeline/createChildPipeline.ts +6 -22
  73. package/src/pipeline/createJobsForComponent.ts +64 -0
  74. package/src/pipeline/gitlab/createGitlabJobs.ts +147 -0
  75. package/src/pipeline/index.ts +1 -1
  76. package/src/types/context.ts +1 -0
  77. package/src/types/environmentContext.ts +7 -0
  78. package/src/types/gitlab-types.ts +18 -1
  79. package/src/types/jobs.ts +11 -2
  80. package/dist/pipeline/createJobs.d.ts +0 -3
  81. package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -10
  82. package/dist/pipeline/gitlab/makeGitlabJob.js +0 -44
  83. package/src/pipeline/createJobs.ts +0 -199
  84. package/src/pipeline/gitlab/makeGitlabJob.ts +0 -23
@@ -64,6 +64,7 @@ var createCustomBuildJobs = function (context) {
64
64
  var appBuildJob = buildConfig.buildCommand !== null ? (0, createBuildJob_1.createBuildJob)(context, {
65
65
  image: buildConfig.jobImage,
66
66
  variables: __assign({}, RUNNER_BUILD_VARIABLES),
67
+ cache: buildConfig.jobCache,
67
68
  services: buildConfig.jobServices,
68
69
  script: __spreadArray([], __read((_a = (0, utils_1.ensureArray)(buildConfig.buildCommand)) !== null && _a !== void 0 ? _a : []), false),
69
70
  artifacts: {
@@ -65,7 +65,13 @@ exports.BUILD_TYPES = {
65
65
  rails: {
66
66
  jobs: rails_1.createRailsJobs,
67
67
  defaults: function () {
68
- return {};
68
+ return {
69
+ startCommand: "/cnb/process/web",
70
+ cnbBuilder: {
71
+ image: "heroku/buildpacks:20",
72
+ packVersion: "0.28.0"
73
+ }
74
+ };
69
75
  }
70
76
  }
71
77
  };
@@ -1,30 +1,55 @@
1
1
  "use strict";
2
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];
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;
8
21
  }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
22
+ }
23
+ return ar;
12
24
  };
13
25
  exports.__esModule = true;
14
26
  exports.createRailsBuildJobs = void 0;
27
+ var types_1 = require("../types");
15
28
  var docker_1 = require("../docker");
16
29
  var createRailsBuildJobs = function (context) {
30
+ var _a, _b, _c, _d, _e, _f;
31
+ var buildConfig = context.componentConfig.build;
32
+ if (!(0, types_1.isOfBuildType)(buildConfig, "rails")) {
33
+ // should not happen
34
+ throw new Error("build type is not rails");
35
+ }
36
+ var cnbConf = buildConfig.cnbBuilder;
37
+ // backwards compatabilty with CNB_ENV_VARS
38
+ // TODO: remove when all projects are migrated
39
+ var packEnvArgs = (_c = (_b = (_a = buildConfig.extraVars) === null || _a === void 0 ? void 0 : _a.CNB_ENV_VARS) === null || _b === void 0 ? void 0 : _b.split(" ").map(function (v) {
40
+ return "--env '".concat(v, "'");
41
+ })) !== null && _c !== void 0 ? _c : Object.entries((_d = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.buildVars) !== null && _d !== void 0 ? _d : {}).map(function (_a) {
42
+ var _b = __read(_a, 2),
43
+ k = _b[0],
44
+ v = _b[1];
45
+ return "--env '".concat(k).concat(v ? "=".concat(v) : "", "'");
46
+ });
17
47
  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),
48
+ variables: context.componentConfig.build.extraVars,
24
49
  // 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",
50
+ 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",
26
51
  // 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"]
52
+ "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.join(" "), " ").concat((_f = (_e = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _e === void 0 ? void 0 : _e.join(" ")) !== null && _f !== void 0 ? _f : "")]
28
53
  })];
29
54
  };
30
55
  exports.createRailsBuildJobs = createRailsBuildJobs;
@@ -1,3 +1,3 @@
1
- import { Context } from "../../types";
2
- import { CatladderJob } from "../../types/jobs";
1
+ import type { Context } from "../../types";
2
+ import type { CatladderJob } from "../../types/jobs";
3
3
  export declare const createRailsJobs: (context: Context) => CatladderJob[];
@@ -1,4 +1,5 @@
1
- import type { GitlabJobService } from "../types";
1
+ import type { GitlabJobImage, GitlabJobService } from "../types";
2
+ import type { CatladderJob } from "../types/jobs";
2
3
  export declare type BuildConfigBase = {
3
4
  /**
4
5
  * command to run on the image to start the app (e.g. yarn start)
@@ -24,21 +25,21 @@ export declare type BuildConfigBase = {
24
25
  */
25
26
  lint?: false | {
26
27
  command?: string | string[];
27
- jobImage?: string;
28
+ jobImage?: GitlabJobImage;
28
29
  };
29
30
  /**
30
31
  * customize test, set false to disable
31
32
  */
32
33
  test?: false | {
33
34
  command?: string | string[];
34
- jobImage?: string;
35
+ jobImage?: GitlabJobImage;
35
36
  };
36
37
  /**
37
38
  * customize audit, set false to disable
38
39
  */
39
40
  audit?: false | {
40
41
  command?: string | string[];
41
- jobImage?: string;
42
+ jobImage?: GitlabJobImage;
42
43
  };
43
44
  /**
44
45
  * additional paths for artifacts,
@@ -91,9 +92,40 @@ export declare type BuildConfigCustom = BuildConfigBase & {
91
92
  jobImage: string;
92
93
  jobServices?: GitlabJobService[];
93
94
  docker: BuildConfigCustomDocker;
95
+ /**
96
+ * customize cache for the job
97
+ */
98
+ jobCache?: CatladderJob["cache"];
94
99
  };
95
100
  export declare type BuildConfigRails = BuildConfigBase & {
96
101
  type: "rails";
102
+ cnbBuilder?: {
103
+ /**
104
+ * The Cloud Native Buildpacks builder image to use.
105
+ * See e.g. https://github.com/heroku/builder or others.
106
+ * Default: heroku/buildpacks:20
107
+ */
108
+ image?: string;
109
+ /**
110
+ * The version of the Cloud Native Buildpacks pack command to use.
111
+ * See https://buildpacks.io/docs/tools/pack/
112
+ * Default: 0.28.0
113
+ */
114
+ packVersion?: string;
115
+ /**
116
+ * Additional command arguments passed to the pack command.
117
+ * See https://buildpacks.io/docs/tools/pack/
118
+ */
119
+ packExtraArgs?: string[];
120
+ /**
121
+ * Variables needed for Bundler and Rails asset precompilation.
122
+ *
123
+ * Specify a key with the value `undefined` to inherit it from the EnvVars.
124
+ *
125
+ * See https://github.com/rails/rails/issues/32947
126
+ */
127
+ buildVars?: Record<string, string | undefined>;
128
+ };
97
129
  };
98
130
  export declare type BuildConfigStorybook = BuildConfigNodeBase & {
99
131
  type: "storybook";