@catladder/pipeline 0.0.0-fix-command-710f75f1 → 0.0.0-fix-error-sql-db-delete-a719775a

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 (98) hide show
  1. package/dist/build/custom/buildJob.js +1 -0
  2. package/dist/build/docker.d.ts +4 -18
  3. package/dist/build/docker.js +15 -9
  4. package/dist/build/index.js +7 -1
  5. package/dist/build/rails/build.js +37 -16
  6. package/dist/build/rails/index.d.ts +2 -2
  7. package/dist/build/rails/test.js +1 -2
  8. package/dist/build/types.d.ts +36 -4
  9. package/dist/bundles/catladder-gitlab/index.js +543 -218
  10. package/dist/constants.js +1 -1
  11. package/dist/context/getEnvironment.js +1 -0
  12. package/dist/context/getEnvironmentContext.js +5 -3
  13. package/dist/context/getEnvironmentVariables.d.ts +5 -1
  14. package/dist/context/getEnvironmentVariables.js +7 -2
  15. package/dist/deploy/base.js +1 -1
  16. package/dist/deploy/cloudRun/index.js +14 -6
  17. package/dist/deploy/custom/deployJob.js +6 -3
  18. package/dist/deploy/index.d.ts +2 -1
  19. package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +3 -1
  20. package/dist/deploy/kubernetes/additionalSecretKeys.js +5 -1
  21. package/dist/deploy/kubernetes/deployJob.js +4 -4
  22. package/dist/deploy/kubernetes/kubeValues.d.ts +1 -0
  23. package/dist/deploy/kubernetes/kubeValues.js +9 -6
  24. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +1 -0
  25. package/dist/deploy/types/custom.d.ts +2 -1
  26. package/dist/deploy/types/googleCloudRun.d.ts +5 -1
  27. package/dist/deploy/types/kubernetes.d.ts +9 -0
  28. package/dist/pipeline/createAllJobs.d.ts +8 -0
  29. package/dist/pipeline/createAllJobs.js +164 -0
  30. package/dist/pipeline/createChildPipeline.js +24 -48
  31. package/dist/pipeline/createJobsForComponent.d.ts +3 -0
  32. package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +8 -105
  33. package/dist/pipeline/gitlab/createGitlabJobs.d.ts +14 -0
  34. package/dist/pipeline/gitlab/createGitlabJobs.js +260 -0
  35. package/dist/pipeline/index.d.ts +1 -1
  36. package/dist/pipeline/index.js +1 -1
  37. package/dist/tsconfig.tsbuildinfo +1 -1
  38. package/dist/types/config.d.ts +3 -3
  39. package/dist/types/context.d.ts +3 -1
  40. package/dist/types/environmentContext.d.ts +7 -0
  41. package/dist/types/gitlab-types.d.ts +5 -1
  42. package/dist/types/jobs.d.ts +9 -2
  43. package/dist/utils/gitlab.js +1 -1
  44. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +32 -32
  45. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +32 -32
  46. package/examples/__snapshots__/cloud-run-non-public.ts.snap +32 -32
  47. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +3116 -0
  48. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +64 -64
  49. package/examples/__snapshots__/custom-build-job.ts.snap +32 -32
  50. package/examples/__snapshots__/custom-deploy.ts.snap +1384 -0
  51. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +2280 -0
  52. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +2204 -0
  53. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +24 -24
  54. package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1911 -0
  55. package/examples/cloud-run-with-sql-reuse-db.ts +54 -0
  56. package/examples/custom-deploy.ts +25 -0
  57. package/examples/kubernetes-application-customization.ts +57 -0
  58. package/examples/kubernetes-with-cloud-sql-legacy.ts +33 -0
  59. package/examples/rails-k8s-with-worker.ts +95 -0
  60. package/package.json +1 -1
  61. package/src/build/custom/buildJob.ts +1 -0
  62. package/src/build/docker.ts +13 -6
  63. package/src/build/index.ts +7 -1
  64. package/src/build/node/cache.ts +2 -2
  65. package/src/build/rails/build.ts +20 -10
  66. package/src/build/rails/index.ts +2 -2
  67. package/src/build/rails/test.ts +43 -39
  68. package/src/build/types.ts +40 -5
  69. package/src/config/configruedEnvs.ts +2 -8
  70. package/src/context/getEnvironment.ts +1 -0
  71. package/src/context/getEnvironmentContext.ts +6 -6
  72. package/src/context/getEnvironmentVariables.ts +9 -4
  73. package/src/deploy/base.ts +1 -1
  74. package/src/deploy/cloudRun/deployJob.ts +1 -1
  75. package/src/deploy/cloudRun/index.ts +12 -4
  76. package/src/deploy/custom/deployJob.ts +9 -1
  77. package/src/deploy/index.ts +4 -1
  78. package/src/deploy/kubernetes/additionalSecretKeys.ts +1 -1
  79. package/src/deploy/kubernetes/deployJob.ts +2 -1
  80. package/src/deploy/kubernetes/kubeValues.ts +7 -5
  81. package/src/deploy/types/custom.ts +2 -1
  82. package/src/deploy/types/googleCloudRun.ts +6 -1
  83. package/src/deploy/types/kubernetes.ts +11 -1
  84. package/src/pipeline/createAllJobs.ts +38 -0
  85. package/src/pipeline/createChildPipeline.ts +6 -22
  86. package/src/pipeline/createJobsForComponent.ts +64 -0
  87. package/src/pipeline/gitlab/createGitlabJobs.ts +149 -0
  88. package/src/pipeline/index.ts +1 -1
  89. package/src/types/context.ts +3 -1
  90. package/src/types/environmentContext.ts +7 -0
  91. package/src/types/gitlab-types.ts +10 -3
  92. package/src/types/jobs.ts +11 -2
  93. package/src/utils/gitlab.ts +1 -1
  94. package/dist/pipeline/createJobs.d.ts +0 -3
  95. package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -10
  96. package/dist/pipeline/gitlab/makeGitlabJob.js +0 -44
  97. package/src/pipeline/createJobs.ts +0 -199
  98. 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: {
@@ -16,14 +16,14 @@ export declare const getDockerBuildVariables: (context: Context) => {
16
16
  DOCKER_IMAGE_NAME: string;
17
17
  DOCKER_IMAGE: string;
18
18
  DOCKER_IMAGE_TAG: string;
19
+ DOCKER_HOST: string;
20
+ DOCKER_TLS_CERTDIR: string;
21
+ DOCKER_DRIVER: string;
19
22
  DOCKER_BUILDKIT: string;
20
23
  DOCKERFILE_ADDITIONS: string | undefined;
21
24
  DOCKERFILE_ADDITIONS_END: string | undefined;
22
25
  APP_DIR: string;
23
- DOCKER_HOST: string;
24
- DOCKER_TLS_CERTDIR: string;
25
26
  DOCKER_DIR: string;
26
- DOCKER_DRIVER: string;
27
27
  KUBERNETES_CPU_REQUEST: string;
28
28
  KUBERNETES_CPU_LIMIT: string;
29
29
  KUBERNETES_MEMORY_REQUEST: string;
@@ -37,24 +37,10 @@ export declare const getDockerJobBaseProps: (context: Context) => {
37
37
  command: string[];
38
38
  }[];
39
39
  variables: {
40
- DOCKER_REGISTRY: string;
41
- DOCKER_REGISTRY_IMAGE_PATH: string;
42
- DOCKER_CACHE_IMAGE: string;
43
- DOCKER_IMAGE_NAME: string;
44
- DOCKER_IMAGE: string;
45
- DOCKER_IMAGE_TAG: string;
46
- DOCKER_BUILDKIT: string;
47
- DOCKERFILE_ADDITIONS: string | undefined;
48
- DOCKERFILE_ADDITIONS_END: string | undefined;
49
- APP_DIR: string;
50
40
  DOCKER_HOST: string;
51
41
  DOCKER_TLS_CERTDIR: string;
52
- DOCKER_DIR: string;
53
42
  DOCKER_DRIVER: string;
54
- KUBERNETES_CPU_REQUEST: string;
55
- KUBERNETES_CPU_LIMIT: string;
56
- KUBERNETES_MEMORY_REQUEST: string;
57
- KUBERNETES_MEMORY_LIMIT: string;
43
+ DOCKER_BUILDKIT: string;
58
44
  };
59
45
  };
60
46
  export declare const createDockerBuildJobBase: (context: Context, {
@@ -88,18 +88,22 @@ var requiresDockerBuild = function (context) {
88
88
  return false;
89
89
  };
90
90
  exports.requiresDockerBuild = requiresDockerBuild;
91
+ var getDockerBaseVariables = function () {
92
+ return {
93
+ DOCKER_HOST: "tcp://0.0.0.0:2375",
94
+ DOCKER_TLS_CERTDIR: "",
95
+ DOCKER_DRIVER: "overlay2",
96
+ DOCKER_BUILDKIT: "1"
97
+ };
98
+ };
91
99
  var getDockerBuildVariables = function (context) {
92
100
  var _a, _b, _c, _d;
93
- return __assign(__assign(__assign({}, DOCKER_RUNNER_BUILD_VARIABLES), {
94
- DOCKER_BUILDKIT: "1",
101
+ return __assign(__assign(__assign(__assign({}, DOCKER_RUNNER_BUILD_VARIABLES), {
95
102
  DOCKERFILE_ADDITIONS: (_b = (_a = context.componentConfig.build.docker) === null || _a === void 0 ? void 0 : _a.additionsBegin) === null || _b === void 0 ? void 0 : _b.join("\n"),
96
103
  DOCKERFILE_ADDITIONS_END: (_d = (_c = context.componentConfig.build.docker) === null || _c === void 0 ? void 0 : _c.additionsEnd) === null || _d === void 0 ? void 0 : _d.join("\n"),
97
104
  APP_DIR: context.componentConfig.dir,
98
- DOCKER_HOST: "tcp://0.0.0.0:2375",
99
- DOCKER_TLS_CERTDIR: "",
100
- DOCKER_DIR: ".",
101
- DOCKER_DRIVER: "overlay2"
102
- }), (0, exports.getDockerImageVariables)(context));
105
+ DOCKER_DIR: "."
106
+ }), getDockerBaseVariables()), (0, exports.getDockerImageVariables)(context));
103
107
  };
104
108
  exports.getDockerBuildVariables = getDockerBuildVariables;
105
109
  exports.DOCKER_BUILD_JOB_NAME = "🔨 docker";
@@ -110,7 +114,7 @@ var getDockerJobBaseProps = function (context) {
110
114
  name: "docker:20-dind",
111
115
  command: ["--tls=false"]
112
116
  }],
113
- variables: (0, exports.getDockerBuildVariables)(context)
117
+ variables: getDockerBaseVariables()
114
118
  };
115
119
  };
116
120
  exports.getDockerJobBaseProps = getDockerJobBaseProps;
@@ -123,7 +127,9 @@ var createDockerBuildJobBase = function (context, _a) {
123
127
  stage: "build"
124
128
  }, (0, exports.getDockerJobBaseProps)(context)), {
125
129
  script: script || []
126
- }), def);
130
+ }), {
131
+ variables: (0, exports.getDockerBuildVariables)(context)
132
+ }, def);
127
133
  };
128
134
  exports.createDockerBuildJobBase = createDockerBuildJobBase;
129
135
  exports.gitlabDockerLogin = "docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY";
@@ -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,51 @@
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;
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
+ var packEnvArgs = Object.entries((_a = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.buildVars) !== null && _a !== void 0 ? _a : {}).map(function (_a) {
38
+ var _b = __read(_a, 2),
39
+ k = _b[0],
40
+ v = _b[1];
41
+ return "--env '".concat(k).concat(v ? "=".concat(v) : "", "'");
42
+ }).join(" ");
17
43
  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),
44
+ variables: context.componentConfig.build.extraVars,
24
45
  // 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",
46
+ 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
47
  // 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"]
48
+ "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 : "")]
28
49
  })];
29
50
  };
30
51
  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[];
@@ -63,9 +63,8 @@ var createRailsTestJobs = function (context) {
63
63
  var bundlerCache = {
64
64
  key: {
65
65
  files: ["Gemfile.lock"],
66
- prefix: "$CI_JOB_IMAGE" // a changed image might have different OS libraries which no longer work with the cached gems
66
+ prefix: "$CI_JOB_IMAGE"
67
67
  },
68
-
69
68
  paths: [bundlerCacheDir]
70
69
  };
71
70
  var auditJob = buildConfig.audit !== false ? __assign(__assign({
@@ -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";