@catladder/pipeline 0.0.0-refactor-untangle-gitlab-api-requests-from-vorpal-57cf3cf2 → 0.0.0-reference-database-url-1befbbee

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 (181) hide show
  1. package/dist/build/artifacts/createBuildJobArtifact.js +1 -1
  2. package/dist/build/base/index.d.ts +2 -3
  3. package/dist/build/cache/getAllCacheConfigsFromConfig.js +2 -2
  4. package/dist/build/custom/buildJob.d.ts +2 -2
  5. package/dist/build/custom/index.d.ts +2 -2
  6. package/dist/build/custom/testJob.d.ts +2 -2
  7. package/dist/build/docker.d.ts +4 -4
  8. package/dist/build/docker.js +1 -1
  9. package/dist/build/index.d.ts +2 -2
  10. package/dist/build/index.js +2 -3
  11. package/dist/build/node/buildJob.d.ts +5 -3
  12. package/dist/build/node/index.d.ts +4 -4
  13. package/dist/build/node/meteor.d.ts +2 -2
  14. package/dist/build/node/yarn.d.ts +1 -1
  15. package/dist/build/node/yarn.js +1 -1
  16. package/dist/build/rails/build.d.ts +2 -2
  17. package/dist/build/rails/build.js +1 -1
  18. package/dist/build/rails/index.d.ts +2 -2
  19. package/dist/build/rails/test.js +13 -2
  20. package/dist/build/sbom.d.ts +2 -2
  21. package/dist/build/sbom.js +4 -1
  22. package/dist/build/types.d.ts +8 -0
  23. package/dist/constants.js +1 -1
  24. package/dist/context/createComponentContext.js +11 -4
  25. package/dist/context/getLabels.js +1 -1
  26. package/dist/deploy/cloudRun/createJobs/cloudRunJobs.js +2 -2
  27. package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +34 -12
  28. package/dist/deploy/cloudRun/createJobs/execute/onDeploy.d.ts +2 -3
  29. package/dist/deploy/cloudRun/createJobs/execute/onDeploy.js +4 -9
  30. package/dist/deploy/cloudRun/createJobs/healthCheck.d.ts +5 -0
  31. package/dist/deploy/cloudRun/createJobs/healthCheck.js +82 -0
  32. package/dist/deploy/cloudRun/index.js +7 -5
  33. package/dist/deploy/cloudRun/utils/database.d.ts +21 -2
  34. package/dist/deploy/cloudRun/utils/database.js +27 -6
  35. package/dist/deploy/cloudRun/utils/getJobOrServiceArgs.d.ts +2 -0
  36. package/dist/deploy/cloudRun/utils/getJobOrServiceArgs.js +12 -0
  37. package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
  38. package/dist/deploy/kubernetes/kubeValues.js +1 -1
  39. package/dist/deploy/sbom.js +1 -1
  40. package/dist/deploy/types/googleCloudRun.d.ts +100 -0
  41. package/dist/deploy/types/googleCloudRun.js +25 -0
  42. package/dist/pipeline/createJobsForComponent.js +1 -1
  43. package/dist/tsconfig.tsbuildinfo +1 -1
  44. package/dist/types/config.d.ts +1 -1
  45. package/dist/types/context.d.ts +6 -1
  46. package/examples/__snapshots__/cloud-run-health-check-defaults.test.ts.snap +1394 -0
  47. package/examples/__snapshots__/cloud-run-health-check-only-startup.test.ts.snap +1394 -0
  48. package/examples/__snapshots__/cloud-run-health-check.test.ts.snap +1394 -0
  49. package/examples/__snapshots__/cloud-run-http2.test.ts.snap +20 -8
  50. package/examples/__snapshots__/cloud-run-llama.test.ts.snap +624 -0
  51. package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +20 -8
  52. package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +24 -12
  53. package/examples/__snapshots__/cloud-run-nextjs.test.ts.snap +20 -8
  54. package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +20 -8
  55. package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +20 -8
  56. package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +20 -8
  57. package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +20 -8
  58. package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +20 -8
  59. package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +20 -8
  60. package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +20 -8
  61. package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +20 -8
  62. package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +20 -8
  63. package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +20 -8
  64. package/examples/__snapshots__/cloud-run-with-gpu.test.ts.snap +1394 -0
  65. package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +20 -8
  66. package/examples/__snapshots__/cloud-run-with-sql-legacy-jobs.test.ts.snap +20 -8
  67. package/examples/__snapshots__/cloud-run-with-sql-multiple-dbs.test.ts.snap +4515 -0
  68. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +40 -16
  69. package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +20 -8
  70. package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +20 -8
  71. package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +20 -8
  72. package/examples/__snapshots__/custom-build-job.test.ts.snap +20 -8
  73. package/examples/__snapshots__/custom-deploy.test.ts.snap +20 -8
  74. package/examples/__snapshots__/custom-envs.test.ts.snap +24 -6
  75. package/examples/__snapshots__/custom-sbom-java.test.ts.snap +4 -4
  76. package/examples/__snapshots__/custom-verify-job.test.ts.snap +20 -8
  77. package/examples/__snapshots__/git-submodule.test.ts.snap +20 -8
  78. package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +20 -8
  79. package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +20 -8
  80. package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +40 -16
  81. package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +20 -8
  82. package/examples/__snapshots__/local-dot-env.test.ts.snap +20 -8
  83. package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +20 -8
  84. package/examples/__snapshots__/multiline-var.test.ts.snap +60 -24
  85. package/examples/__snapshots__/native-app.test.ts.snap +36 -12
  86. package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +20 -8
  87. package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +20 -8
  88. package/examples/__snapshots__/override-secrets.test.ts.snap +20 -8
  89. package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +30 -17
  90. package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +38 -29
  91. package/examples/__snapshots__/referencing-other-vars.test.ts.snap +60 -24
  92. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +32 -8
  93. package/examples/__snapshots__/workspace-api-www-turbo-cache.test.ts.snap +40 -16
  94. package/examples/__snapshots__/workspace-api-www.test.ts.snap +40 -16
  95. package/examples/cloud-run-health-check-defaults.test.ts +11 -0
  96. package/examples/cloud-run-health-check-defaults.ts +28 -0
  97. package/examples/cloud-run-health-check-only-startup.test.ts +11 -0
  98. package/examples/cloud-run-health-check-only-startup.ts +38 -0
  99. package/examples/cloud-run-health-check.test.ts +11 -0
  100. package/examples/cloud-run-health-check.ts +45 -0
  101. package/examples/cloud-run-http2.ts +2 -2
  102. package/examples/cloud-run-llama.test.ts +11 -0
  103. package/examples/cloud-run-llama.ts +40 -0
  104. package/examples/cloud-run-memory-limit.ts +2 -2
  105. package/examples/cloud-run-meteor-with-worker.ts +7 -3
  106. package/examples/cloud-run-nextjs.ts +2 -2
  107. package/examples/cloud-run-no-cpu-throttling.ts +2 -2
  108. package/examples/cloud-run-no-service.ts +2 -2
  109. package/examples/cloud-run-non-public.ts +2 -2
  110. package/examples/cloud-run-post-stop-job.ts +2 -2
  111. package/examples/cloud-run-service-custom-vpc-connector.ts +2 -2
  112. package/examples/cloud-run-service-custom-vpc.ts +2 -2
  113. package/examples/cloud-run-service-gen2.ts +2 -2
  114. package/examples/cloud-run-service-increase-timout.ts +2 -2
  115. package/examples/cloud-run-service-with-volumes.ts +2 -2
  116. package/examples/cloud-run-storybook.ts +2 -2
  117. package/examples/cloud-run-with-gpu.test.ts +11 -0
  118. package/examples/cloud-run-with-gpu.ts +30 -0
  119. package/examples/cloud-run-with-ngnix.ts +2 -2
  120. package/examples/cloud-run-with-sql-legacy-jobs.ts +2 -2
  121. package/examples/cloud-run-with-sql-multiple-dbs.test.ts +11 -0
  122. package/examples/cloud-run-with-sql-multiple-dbs.ts +87 -0
  123. package/examples/cloud-run-with-sql-reuse-db.ts +2 -2
  124. package/examples/cloud-run-with-sql.ts +2 -2
  125. package/examples/cloud-run-with-worker.ts +2 -2
  126. package/examples/custom-build-job-with-tests.ts +2 -2
  127. package/examples/custom-build-job.ts +2 -2
  128. package/examples/custom-deploy.ts +2 -2
  129. package/examples/custom-envs.ts +2 -2
  130. package/examples/custom-sbom-java.ts +2 -2
  131. package/examples/custom-verify-job.ts +2 -2
  132. package/examples/git-submodule.ts +2 -2
  133. package/examples/kubernetes-application-customization.ts +2 -2
  134. package/examples/kubernetes-with-cloud-sql.ts +2 -2
  135. package/examples/kubernetes-with-jobs.ts +2 -2
  136. package/examples/kubernetes-with-mongodb.ts +2 -2
  137. package/examples/local-dot-env.ts +2 -2
  138. package/examples/meteor-kubernetes.ts +2 -2
  139. package/examples/multiline-var.ts +2 -2
  140. package/examples/native-app.ts +2 -2
  141. package/examples/node-build-with-custom-image.ts +2 -2
  142. package/examples/node-build-with-docker-additions.ts +2 -2
  143. package/examples/override-secrets.ts +2 -2
  144. package/examples/rails-k8s-with-worker.ts +2 -2
  145. package/examples/referencing-other-vars.ts +2 -2
  146. package/examples/wait-for-other-deploy.ts +1 -1
  147. package/examples/workspace-api-www-turbo-cache.ts +2 -2
  148. package/examples/workspace-api-www.ts +2 -2
  149. package/package.json +1 -1
  150. package/src/build/artifacts/createBuildJobArtifact.ts +3 -1
  151. package/src/build/base/index.ts +5 -2
  152. package/src/build/cache/getAllCacheConfigsFromConfig.ts +7 -6
  153. package/src/build/custom/buildJob.ts +2 -2
  154. package/src/build/custom/index.ts +4 -2
  155. package/src/build/custom/testJob.ts +2 -2
  156. package/src/build/docker.ts +9 -5
  157. package/src/build/index.ts +7 -5
  158. package/src/build/node/buildJob.ts +5 -2
  159. package/src/build/node/index.ts +9 -4
  160. package/src/build/node/meteor.ts +5 -2
  161. package/src/build/node/yarn.ts +4 -2
  162. package/src/build/rails/build.ts +3 -8
  163. package/src/build/rails/index.ts +4 -2
  164. package/src/build/rails/test.ts +19 -0
  165. package/src/build/sbom.ts +8 -3
  166. package/src/build/types.ts +8 -0
  167. package/src/context/createComponentContext.ts +22 -9
  168. package/src/context/getLabels.ts +4 -1
  169. package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +2 -2
  170. package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +30 -3
  171. package/src/deploy/cloudRun/createJobs/execute/onDeploy.ts +3 -13
  172. package/src/deploy/cloudRun/createJobs/healthCheck.ts +64 -0
  173. package/src/deploy/cloudRun/index.ts +14 -5
  174. package/src/deploy/cloudRun/utils/database.ts +93 -8
  175. package/src/deploy/cloudRun/utils/getJobOrServiceArgs.ts +18 -0
  176. package/src/deploy/kubernetes/kubeValues.ts +13 -4
  177. package/src/deploy/sbom.ts +4 -3
  178. package/src/deploy/types/googleCloudRun.ts +135 -0
  179. package/src/pipeline/createJobsForComponent.ts +10 -2
  180. package/src/types/config.ts +1 -1
  181. package/src/types/context.ts +10 -1
@@ -1,6 +1,6 @@
1
1
  import type { Config } from "../src";
2
2
 
3
- const config: Config = {
3
+ const config = {
4
4
  appName: "test-app",
5
5
  customerName: "pan",
6
6
  components: {
@@ -74,7 +74,7 @@ const config: Config = {
74
74
  },
75
75
  },
76
76
  },
77
- };
77
+ } satisfies Config;
78
78
 
79
79
  export default config;
80
80
 
@@ -28,7 +28,7 @@ const config: Config<{ CustomEnvs: "asdf" | "bla" }> = {
28
28
  },
29
29
  },
30
30
  },
31
- };
31
+ } satisfies Config;
32
32
 
33
33
  export default config;
34
34
 
@@ -5,7 +5,7 @@ const DEPLOY_CONFIG: DeployConfig = {
5
5
  projectId: "google-project-id",
6
6
  region: "europe-west6",
7
7
  };
8
- const config: Config = {
8
+ const config = {
9
9
  appName: "test-app",
10
10
  customerName: "pan",
11
11
  builds: {
@@ -43,7 +43,7 @@ const config: Config = {
43
43
  },
44
44
  },
45
45
  },
46
- };
46
+ } satisfies Config;
47
47
 
48
48
  export default config;
49
49
 
@@ -5,7 +5,7 @@ const DEPLOY_CONFIG: DeployConfig = {
5
5
  projectId: "google-project-id",
6
6
  region: "europe-west6",
7
7
  };
8
- const config: Config = {
8
+ const config = {
9
9
  appName: "test-app",
10
10
  customerName: "pan",
11
11
  builds: {
@@ -37,7 +37,7 @@ const config: Config = {
37
37
  },
38
38
  },
39
39
  },
40
- };
40
+ } satisfies Config;
41
41
 
42
42
  export default config;
43
43
 
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "0.0.0-refactor-untangle-gitlab-api-requests-from-vorpal-57cf3cf2",
56
+ "version": "0.0.0-reference-database-url-1befbbee",
57
57
  "stableVersion": "0.1.0",
58
58
  "scripts": {
59
59
  "build:tsc": "yarn tsc",
@@ -41,7 +41,9 @@ const getArtifactsPathForComponent = (
41
41
  additionalPaths?: string[],
42
42
  ): string[] => {
43
43
  return [
44
- ...(c.build.config.artifactsPaths ?? []),
44
+ ...(c.build.type !== "disabled"
45
+ ? (c.build.config.artifactsPaths ?? [])
46
+ : []),
45
47
  ...(additionalPaths ?? []),
46
48
  ]?.flatMap((artifact) =>
47
49
  c.build
@@ -1,5 +1,8 @@
1
1
  import { sbomDeactivated } from "../../deploy/sbom";
2
- import type { WorkspaceContext } from "../../types/context";
2
+ import type {
3
+ ComponentContextWithBuild,
4
+ WorkspaceContext,
5
+ } from "../../types/context";
3
6
  import {
4
7
  componentContextHasWorkspaceBuild,
5
8
  componentContextIsStandaloneBuild,
@@ -16,7 +19,7 @@ import { APP_BUILD_JOB_NAME } from "./constants";
16
19
  import { createAppBuildJob } from "./createAppBuildJob";
17
20
 
18
21
  export const createComponentBuildJobs = (
19
- context: ComponentContext,
22
+ context: ComponentContextWithBuild,
20
23
  definitions: {
21
24
  appBuild?: AppBuildJobDefinition;
22
25
  dockerBuild: DockerBuildJobDefinition;
@@ -16,12 +16,13 @@ export const getAllCacheConfigsFromConfig = (
16
16
  ? // also add cache configs of the components of that workspace
17
17
  // FIXNME: this only works currently for the build config
18
18
  // we would probably need to introduce a path to the right config property (build-->test or so)
19
- context.components.flatMap<CacheConfig>(
20
- (componentContext) =>
21
- ensureArray(componentContext.build.config.cache).map((c) => ({
22
- ...c,
23
- baseDir: componentContext.build.dir,
24
- })) ?? [],
19
+ context.components.flatMap<CacheConfig>((componentContext) =>
20
+ componentContext.build.type !== "disabled"
21
+ ? (ensureArray(componentContext.build.config.cache).map((c) => ({
22
+ ...c,
23
+ baseDir: componentContext.build.dir,
24
+ })) ?? [])
25
+ : [],
25
26
  )
26
27
  : []),
27
28
  ];
@@ -1,4 +1,4 @@
1
- import type { ComponentContext } from "../../types/context";
1
+ import type { ComponentContextWithBuild } from "../../types/context";
2
2
  import { getDockerBuildScriptWithBuiltInDockerFile } from "../docker";
3
3
  import { isOfBuildType } from "../types";
4
4
 
@@ -7,7 +7,7 @@ import { createComponentBuildJobs } from "../base";
7
7
  import { createBuildJobDefinition } from "../base/createBuildJobDefinition";
8
8
 
9
9
  export const createCustomBuildJobs = (
10
- context: ComponentContext,
10
+ context: ComponentContextWithBuild,
11
11
  ): CatladderJob[] => {
12
12
  const buildConfig = context.build.config;
13
13
 
@@ -1,8 +1,10 @@
1
- import type { ComponentContext } from "../../types/context";
1
+ import type { ComponentContextWithBuild } from "../../types";
2
2
  import type { CatladderJob } from "../../types/jobs";
3
3
  import { createCustomBuildJobs } from "./buildJob";
4
4
  import { createCustomTestJobs } from "./testJob";
5
5
 
6
- export const createCustomJobs = (context: ComponentContext): CatladderJob[] => {
6
+ export const createCustomJobs = (
7
+ context: ComponentContextWithBuild,
8
+ ): CatladderJob[] => {
7
9
  return [...createCustomTestJobs(context), ...createCustomBuildJobs(context)];
8
10
  };
@@ -1,5 +1,5 @@
1
1
  import type { Artifacts } from "../../types";
2
- import type { ComponentContext } from "../../types/context";
2
+ import type { ComponentContextWithBuild } from "../../types/context";
3
3
  import type { CatladderJob } from "../../types/jobs";
4
4
  import { ensureArray, notNil } from "../../utils";
5
5
  import { createArtifactsConfig } from "../base/createArtifactsConfig";
@@ -13,7 +13,7 @@ const RUNNER_CUSTOM_TEST_VARIABLES = {
13
13
  };
14
14
 
15
15
  export const createCustomTestJobs = (
16
- context: ComponentContext,
16
+ context: ComponentContextWithBuild,
17
17
  ): CatladderJob[] => {
18
18
  // don't run tests after release
19
19
  // TODO: this will be replaced by using rules
@@ -10,7 +10,11 @@ import {
10
10
  } from "../deploy/cloudRun/artifactsRegistry";
11
11
  import { gcloudServiceAccountLoginCommands } from "../deploy/cloudRun/utils/gcloudServiceAccountLoginCommands";
12
12
  import { getRunnerImage } from "../runner";
13
- import type { ComponentContext, DockerBuildJobDefinition } from "../types";
13
+ import type {
14
+ ComponentContext,
15
+ ComponentContextWithBuild,
16
+ DockerBuildJobDefinition,
17
+ } from "../types";
14
18
  import type { CatladderJob } from "../types/jobs";
15
19
  import { collapseableSection } from "../utils/gitlab";
16
20
  import { createJobCacheFromCacheConfigs } from "./cache/createJobCache";
@@ -63,7 +67,7 @@ export const requiresDockerBuild = (context: ComponentContext): boolean => {
63
67
 
64
68
  // those need to be runner variables
65
69
  const getDockerBuildRunnerVariables = () => ({
66
- DOCKER_HOST: "tcp://0.0.0.0:2375",
70
+ DOCKER_HOST: "tcp://docker:2375",
67
71
  DOCKER_TLS_CERTDIR: "",
68
72
  DOCKER_DRIVER: "overlay2",
69
73
  DOCKER_BUILDKIT: "1", // see https://docs.docker.com/develop/develop-images/build_enhancements/
@@ -84,7 +88,7 @@ const getDockerAdditions = (build: BuildConfig) => {
84
88
  : undefined,
85
89
  };
86
90
  };
87
- export const getDockerBuildVariables = (context: ComponentContext) => {
91
+ export const getDockerBuildVariables = (context: ComponentContextWithBuild) => {
88
92
  return {
89
93
  ...getDockerAdditions(context.build.config),
90
94
  APP_DIR: context.build.dir,
@@ -120,7 +124,7 @@ export const getDockerJobBaseProps = (): Pick<
120
124
  };
121
125
 
122
126
  export const createDockerBuildJobBase = (
123
- context: ComponentContext,
127
+ context: ComponentContextWithBuild,
124
128
  { script, cache, ...def }: DockerBuildJobDefinition,
125
129
  ): CatladderJob => {
126
130
  return merge(
@@ -163,7 +167,7 @@ const BUILT_IN_ENSURE_DOCKERFILE_SCRIPTS = {
163
167
  };
164
168
 
165
169
  export const getDockerBuildScriptWithBuiltInDockerFile = (
166
- context: ComponentContext,
170
+ context: ComponentContextWithBuild,
167
171
  defaultType?: BuildConfigDocker["type"],
168
172
  ) => {
169
173
  const type =
@@ -1,4 +1,7 @@
1
- import type { ComponentContext, WorkspaceContext } from "../types/context";
1
+ import type {
2
+ ComponentContextWithBuild,
3
+ WorkspaceContext,
4
+ } from "../types/context";
2
5
  import type { EnvironmentContext } from "../types/environmentContext";
3
6
 
4
7
  import type { CatladderJob } from "../types/jobs";
@@ -16,7 +19,7 @@ export * from "./types";
16
19
 
17
20
  export type BuildTypes = {
18
21
  [type in BuildConfigStandaloneType]: {
19
- jobs: (context: ComponentContext) => CatladderJob[];
22
+ jobs: (context: ComponentContextWithBuild) => CatladderJob[];
20
23
  defaults: (
21
24
  envContext: EnvironmentContext,
22
25
  ) => Partial<Extract<BuildConfig, { type: type }>>;
@@ -62,10 +65,9 @@ export const BUILD_TYPES: BuildTypes = {
62
65
  rails: {
63
66
  jobs: createRailsJobs,
64
67
  defaults: () => ({
65
- startCommand: "/cnb/process/web",
66
68
  cnbBuilder: {
67
- image: "heroku/builder:22",
68
- packVersion: "0.32.1",
69
+ image: "heroku/builder:24",
70
+ packVersion: "0.36.4",
69
71
  },
70
72
  }),
71
73
  },
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  BuildContextStandalone,
3
+ ComponentContextWithBuild,
3
4
  WorkspaceContext,
4
5
  } from "../../types/context";
5
6
  import {
@@ -19,7 +20,7 @@ import { getNodeCache, getYarnCache } from "./cache";
19
20
  import { getDockerAppCopyAndBuildScript, getYarnInstall } from "./yarn";
20
21
 
21
22
  export const createNodeBuildJobs = (
22
- context: ComponentContext | WorkspaceContext,
23
+ context: ComponentContextWithBuild | WorkspaceContext,
23
24
  ): CatladderJob[] => {
24
25
  if (context.type === "workspace") {
25
26
  return createWorkspaceBuildJobs(context, {
@@ -47,8 +48,10 @@ export const createNodeBuildJobDefinition = (
47
48
  });
48
49
  };
49
50
 
51
+ type NewType = ComponentContextWithBuild;
52
+
50
53
  export const createNodeDockerJobDefinition = (
51
- context: ComponentContext,
54
+ context: NewType,
52
55
  ): DockerBuildJobDefinition => {
53
56
  // get the default docker built-in type based on the build type
54
57
  const dockerDefaultBuiltIn: BuildConfigDocker["type"] =
@@ -1,21 +1,26 @@
1
- import type { ComponentContext, WorkspaceContext } from "../../types/context";
1
+ import type {
2
+ ComponentContextWithBuild,
3
+ WorkspaceContext,
4
+ } from "../../types/context";
2
5
  import type { CatladderJob } from "../../types/jobs";
3
6
  import { createNodeBuildJobs } from "./buildJob";
4
7
  import { createMeteorBuildJobs } from "./meteor";
5
8
  import { createNodeTestJobs } from "./testJob";
6
9
 
7
10
  export const createNodeJobs = (
8
- context: ComponentContext | WorkspaceContext,
11
+ context: ComponentContextWithBuild | WorkspaceContext,
9
12
  ): CatladderJob[] => {
10
13
  return [...createNodeTestJobs(context), ...createNodeBuildJobs(context)];
11
14
  };
12
15
 
13
16
  export const createStorybookJobs = (
14
- context: ComponentContext,
17
+ context: ComponentContextWithBuild,
15
18
  ): CatladderJob[] => {
16
19
  return [...createNodeBuildJobs(context)];
17
20
  };
18
21
 
19
- export const createMeteorJobs = (context: ComponentContext): CatladderJob[] => {
22
+ export const createMeteorJobs = (
23
+ context: ComponentContextWithBuild,
24
+ ): CatladderJob[] => {
20
25
  return [...createNodeTestJobs(context), ...createMeteorBuildJobs(context)];
21
26
  };
@@ -1,5 +1,8 @@
1
1
  import { getRunnerImage } from "../../runner";
2
- import type { ComponentContext } from "../../types/context";
2
+ import type {
3
+ ComponentContext,
4
+ ComponentContextWithBuild,
5
+ } from "../../types/context";
3
6
 
4
7
  import type { CatladderJob } from "../../types/jobs";
5
8
 
@@ -23,7 +26,7 @@ const getMeteorCache = (context: ComponentContext): CacheConfig[] => [
23
26
  },
24
27
  ];
25
28
  export const createMeteorBuildJobs = (
26
- context: ComponentContext,
29
+ context: ComponentContextWithBuild,
27
30
  ): CatladderJob[] => {
28
31
  const buildConfig = context.build.config;
29
32
 
@@ -1,5 +1,5 @@
1
1
  import { BashExpression } from "../../bash/BashExpression";
2
- import type { Context } from "../../types";
2
+ import { type Context } from "../../types";
3
3
  import { ensureArray } from "../../utils";
4
4
  import { collapseableSection } from "../../utils/gitlab";
5
5
 
@@ -32,7 +32,9 @@ export const getYarnInstall = (
32
32
  },
33
33
  ) => {
34
34
  const postInstall =
35
- context.type !== "workspace" && "postInstall" in context.build.config
35
+ context.type !== "workspace" &&
36
+ context.build.type !== "disabled" &&
37
+ "postInstall" in context.build.config
36
38
  ? context.build.config.postInstall
37
39
  : null;
38
40
  return [
@@ -1,9 +1,5 @@
1
- import {
2
- componentContextIsStandaloneBuild,
3
- type BuildConfigRails,
4
- type BuildContextStandalone,
5
- type ComponentContext,
6
- } from "../..";
1
+ import type { ComponentContextWithBuild } from "../..";
2
+ import { componentContextIsStandaloneBuild } from "../..";
7
3
  import type { CatladderJob } from "../../types/jobs";
8
4
  import { createComponentBuildJobs } from "../base";
9
5
  import {
@@ -14,7 +10,7 @@ import {
14
10
  import { isOfBuildType } from "../types";
15
11
 
16
12
  export const createRailsBuildJobs = (
17
- context: ComponentContext,
13
+ context: ComponentContextWithBuild,
18
14
  ): CatladderJob[] => {
19
15
  const buildConfig = context.build.config;
20
16
  if (!isOfBuildType(buildConfig, "rails")) {
@@ -52,7 +48,6 @@ export const createRailsBuildJobs = (
52
48
  script: [
53
49
  ...gitlabDockerLogin(context),
54
50
  `cd ${context.build.dir}`,
55
- `docker pull $DOCKER_CACHE_IMAGE || true`,
56
51
  `wget --output-document=- https://github.com/buildpacks/pack/releases/download/v${cnbConf?.packVersion}/pack-v${cnbConf?.packVersion}-linux.tgz | tar -zx --directory /usr/local/bin pack`,
57
52
  `chmod +x /usr/local/bin/pack`,
58
53
  // replace private git ssh gem sources with https to make bundler with credentials via env var work
@@ -1,8 +1,10 @@
1
- import type { ComponentContext } from "../../types";
1
+ import type { ComponentContextWithBuild } from "../../types";
2
2
  import type { CatladderJob } from "../../types/jobs";
3
3
  import { createRailsBuildJobs } from "./build";
4
4
  import { createRailsTestJobs } from "./test";
5
5
 
6
- export const createRailsJobs = (context: ComponentContext): CatladderJob[] => {
6
+ export const createRailsJobs = (
7
+ context: ComponentContextWithBuild,
8
+ ): CatladderJob[] => {
7
9
  return [...createRailsTestJobs(context), ...createRailsBuildJobs(context)];
8
10
  };
@@ -93,9 +93,28 @@ export const createRailsTestJobs = (
93
93
  `cd ${context.build.dir}`,
94
94
  ...bundlerInstall,
95
95
  ...(ensureArrayOrNull(buildConfig.test?.command) ?? [
96
+ "bundle exec rake db:test:prepare",
97
+ "bundle exec rake assets:precompile assets:clean",
96
98
  "bundle exec rspec",
97
99
  ]),
98
100
  ],
101
+ runnerVariables: {
102
+ RAILS_ENV: "test",
103
+ DATABASE_URL: "postgresql://postgres@database",
104
+ },
105
+ services: [
106
+ {
107
+ name:
108
+ buildConfig.test && "databaseImage" in buildConfig.test
109
+ ? (buildConfig?.test?.databaseImage ??
110
+ "docker.io/postgres:latest")
111
+ : "docker.io/postgres:latest",
112
+ alias: "database",
113
+ variables: {
114
+ POSTGRES_HOST_AUTH_METHOD: "trust",
115
+ },
116
+ },
117
+ ],
99
118
  }
100
119
  : null;
101
120
  return [auditJob, lintJob, testJob].filter(notNil);
package/src/build/sbom.ts CHANGED
@@ -1,15 +1,20 @@
1
1
  import { isStandaloneBuildConfig } from ".";
2
- import type { ComponentContext } from "../types/context";
2
+ import type { ComponentContextWithBuild } from "../types/context";
3
3
  import type { CatladderJob } from "../types/jobs";
4
4
  import { ensureArrayOrNull } from "../utils";
5
5
 
6
6
  export const SBOM_BUILD_JOB_NAME = "🧾 sbom";
7
7
  export const SBOM_FILE = "__sbom.json";
8
8
 
9
- export const createSbomBuildJob = (context: ComponentContext): CatladderJob => {
9
+ export const createSbomBuildJob = (
10
+ context: ComponentContextWithBuild,
11
+ ): CatladderJob => {
10
12
  const buildConfig = context.build.config;
11
13
 
12
- const defaultImage = "aquasec/trivy:0.38.3";
14
+ const defaultImage = {
15
+ name: "aquasec/trivy:0.58.2",
16
+ entrypoint: [""],
17
+ };
13
18
  const defaultScript = [
14
19
  `trivy fs --quiet --format cyclonedx --output "${SBOM_FILE}" ${
15
20
  context.packageManagerInfo.componentIsInWorkspace
@@ -277,6 +277,14 @@ export type BuildConfigCustom = Omit<
277
277
 
278
278
  export type BuildConfigRails = BuildConfigBase & {
279
279
  type: "rails";
280
+ test?: Pick<BuildConfigBase, "test"> & {
281
+ /**
282
+ * The container image to use as the database.
283
+ * Currently only supports PostgreSQL.
284
+ * Defaults to `docker.io/postgres:latest`
285
+ */
286
+ databaseImage?: string;
287
+ };
280
288
  /**
281
289
  * The [Cloud Native Buildpacks](https://buildpacks.io/) builder configuration.
282
290
  *
@@ -42,26 +42,31 @@ export const createComponentContext = async (
42
42
 
43
43
  const componentConfigWithoutDefaults = envContext.envConfigRaw;
44
44
 
45
- const resolvedBuildType = isStandaloneBuildConfig(
46
- componentConfigWithoutDefaults.build,
47
- )
48
- ? componentConfigWithoutDefaults.build.type
49
- : ctx.config.builds?.[componentConfigWithoutDefaults.build.from].type;
50
- if (!resolvedBuildType) {
45
+ const resolvedBuildType =
46
+ componentConfigWithoutDefaults.build === false
47
+ ? false
48
+ : isStandaloneBuildConfig(componentConfigWithoutDefaults.build)
49
+ ? componentConfigWithoutDefaults.build.type
50
+ : ctx.config.builds?.[componentConfigWithoutDefaults.build.from].type;
51
+ if (resolvedBuildType === undefined) {
51
52
  throw new Error("build type not found, is the build config correct?");
52
53
  }
53
54
  const defaults: {
54
- build: PartialDeep<BuildConfig>;
55
+ build: PartialDeep<BuildConfig | false>;
55
56
  deploy: PartialDeep<DeployConfig>;
56
57
  } = componentConfigWithoutDefaults.deploy
57
58
  ? {
58
- build: BUILD_TYPES[resolvedBuildType].defaults(envContext),
59
+ build:
60
+ resolvedBuildType &&
61
+ BUILD_TYPES[resolvedBuildType].defaults(envContext),
59
62
  deploy: DEPLOY_TYPES[
60
63
  componentConfigWithoutDefaults.deploy.type as DeployConfigType
61
64
  ].defaults(envContext as any),
62
65
  }
63
66
  : {
64
- build: BUILD_TYPES[resolvedBuildType].defaults(envContext),
67
+ build:
68
+ resolvedBuildType &&
69
+ BUILD_TYPES[resolvedBuildType].defaults(envContext),
65
70
  deploy: {},
66
71
  };
67
72
 
@@ -80,6 +85,14 @@ export const createComponentContext = async (
80
85
  : []),
81
86
  ];
82
87
  const _getBuildContext = (): BuildContextComponent => {
88
+ if (build === false) {
89
+ return {
90
+ type: "disabled",
91
+ getComponentDirs,
92
+ dir,
93
+ };
94
+ }
95
+
83
96
  if (isStandaloneBuildConfig(build)) {
84
97
  return {
85
98
  dir: dir,
@@ -14,7 +14,10 @@ export const getLabels = (context: ComponentContext) => {
14
14
  "app-name": sanitize(context.fullConfig.appName),
15
15
  "env-type": sanitize(context.environment.envType),
16
16
  "env-name": sanitize(context.env),
17
- "build-type": sanitize(context.build.buildType),
17
+ "build-type":
18
+ context.build.type === "disabled"
19
+ ? "disabled"
20
+ : sanitize(context.build.buildType),
18
21
  ...(context.fullConfig.meta?.labels ?? {}),
19
22
  };
20
23
  return labels;
@@ -14,7 +14,7 @@ import {
14
14
  } from "./common";
15
15
  import { ENV_VARS_FILENAME } from "./constants";
16
16
  import { createVolumeConfig } from "./volumes";
17
- import { getCloudRunJobArgsArg } from "./execute/onDeploy";
17
+ import { getCloudRunServiceOrJobArgsArg } from "../utils/getJobOrServiceArgs";
18
18
 
19
19
  export const getDeleteJobsScripts = (context: ComponentContext) => {
20
20
  const commonArgs = getCommonCloudRunArgs(context);
@@ -44,7 +44,7 @@ export const getJobCreateScripts = (context: ComponentContext): string[] =>
44
44
  const commonDeployArgsString = createArgsString(
45
45
  {
46
46
  command: `"${commandArray.join(",")}"`,
47
- args: getCloudRunJobArgsArg(job.args),
47
+ args: getCloudRunServiceOrJobArgsArg(job.args),
48
48
  labels: `"${makeLabelString(getLabels(context))},cloud-run-job-name=$current_job_name"`,
49
49
  image: `"${job.image ?? commonImage}"`,
50
50
  project,
@@ -3,6 +3,7 @@ import type { ComponentContext } from "../../../types/context";
3
3
 
4
4
  import type { DeployConfigCloudRunService } from "../../types/googleCloudRun";
5
5
  import { createArgsString } from "../utils/createArgsString";
6
+ import { getCloudRunServiceOrJobArgsArg } from "../utils/getJobOrServiceArgs";
6
7
  import { getServiceName } from "../utils/getServiceName";
7
8
  import {
8
9
  gcloudRunCmd,
@@ -11,6 +12,7 @@ import {
11
12
  makeLabelString,
12
13
  } from "./common";
13
14
  import { ENV_VARS_FILENAME } from "./constants";
15
+ import { healthCheckCliArgs } from "./healthCheck";
14
16
  import { createVolumeConfig } from "./volumes";
15
17
 
16
18
  export const getServiceDeployScript = (
@@ -25,7 +27,10 @@ export const getServiceDeployScript = (
25
27
  const customConfig = service !== true ? service : undefined;
26
28
  const command =
27
29
  service !== true
28
- ? (service?.command ?? context.build.config.startCommand)
30
+ ? (service?.command ??
31
+ (context.build.type !== "disabled"
32
+ ? context.build.config.startCommand
33
+ : undefined))
29
34
  : undefined;
30
35
 
31
36
  const commandArray = command
@@ -34,11 +39,14 @@ export const getServiceDeployScript = (
34
39
  : command.split(" ")
35
40
  : undefined;
36
41
  const fullServiceName = serviceName.concat(nameSuffix ?? "");
42
+
37
43
  const argsString = createArgsString(
38
44
  {
39
45
  // command as empty string resets it to default (uses the image's entrypoint)
40
46
  command: commandArray ? '"' + commandArray.join(",") + '"' : '""',
47
+ args: getCloudRunServiceOrJobArgsArg(customConfig?.args),
41
48
  ...commonDeployArgs,
49
+ image: customConfig?.image ?? commonDeployArgs.image,
42
50
  labels: makeLabelString({
43
51
  ...getLabels(context),
44
52
  "cloud-run-service-name": fullServiceName,
@@ -59,11 +67,14 @@ export const getServiceDeployScript = (
59
67
  ingress: customConfig?.ingress ?? "all",
60
68
  "cpu-boost": true,
61
69
  "execution-environment": customConfig?.executionEnvironment,
70
+ gpu: customConfig?.gpu,
71
+ "gpu-type": customConfig?.gpuType,
72
+ ...healthCheckCliArgs(customConfig?.healthCheck),
62
73
  },
63
74
  ...createVolumeConfig(customConfig?.volumes, "service"),
64
75
  );
65
-
66
- return `${gcloudRunCmd()} deploy ${fullServiceName} ${argsString}`;
76
+ const version = requiresBeta(customConfig) ? "beta" : undefined;
77
+ return `${gcloudRunCmd(version)} deploy ${fullServiceName} ${argsString}`;
67
78
  };
68
79
 
69
80
  export const getServiceDeleteScript = (
@@ -84,3 +95,19 @@ export const getServiceDeleteScript = (
84
95
  `${gcloudRunCmd()} services delete ${fullServiceName} ${commonArgsString}`,
85
96
  ];
86
97
  };
98
+ const requiresBeta = (config: DeployConfigCloudRunService | undefined) => {
99
+ if (!config) {
100
+ return false;
101
+ }
102
+
103
+ if (config.gpuType) {
104
+ return true;
105
+ }
106
+ if (config.gpu && config.gpu > 0) {
107
+ return true;
108
+ }
109
+ if (config.healthCheck !== undefined) {
110
+ return true;
111
+ }
112
+ return false;
113
+ };