@catladder/pipeline 0.0.0-refactor-docker-9fda97e9 → 0.0.0-refactor-docker-c24f8608

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 (169) hide show
  1. package/dist/build/base/createAppBuildJob.d.ts +2 -2
  2. package/dist/build/base/createAppBuildJob.js +1 -1
  3. package/dist/build/base/index.d.ts +2 -2
  4. package/dist/build/base/writeBuildInfo.d.ts +2 -2
  5. package/dist/build/base/writeDotEnv.d.ts +2 -2
  6. package/dist/build/custom/buildJob.d.ts +2 -2
  7. package/dist/build/custom/index.d.ts +2 -2
  8. package/dist/build/custom/testJob.d.ts +2 -2
  9. package/dist/build/docker.d.ts +11 -11
  10. package/dist/build/docker.js +6 -6
  11. package/dist/build/index.d.ts +2 -2
  12. package/dist/build/node/buildJob.d.ts +2 -2
  13. package/dist/build/node/buildJob.js +7 -7
  14. package/dist/build/node/cache.d.ts +5 -5
  15. package/dist/build/node/cache.js +4 -4
  16. package/dist/build/node/index.d.ts +4 -4
  17. package/dist/build/node/meteor.d.ts +2 -2
  18. package/dist/build/node/meteor.js +2 -2
  19. package/dist/build/node/testJob.d.ts +2 -2
  20. package/dist/build/node/testJob.js +6 -6
  21. package/dist/build/node/yarn.d.ts +4 -4
  22. package/dist/build/node/yarn.js +1 -1
  23. package/dist/build/rails/build.d.ts +2 -2
  24. package/dist/build/rails/index.d.ts +2 -2
  25. package/dist/build/rails/test.d.ts +2 -2
  26. package/dist/build/sbom.d.ts +2 -2
  27. package/dist/build/sbom.js +1 -1
  28. package/dist/bundles/catladder-gitlab/index.js +61 -46
  29. package/dist/constants.js +1 -1
  30. package/dist/context/getEnvironment.d.ts +2 -2
  31. package/dist/context/getEnvironmentContext.d.ts +2 -2
  32. package/dist/context/getEnvironmentVariables.d.ts +4 -4
  33. package/dist/context/getEnvironmentVariables.js +1 -2
  34. package/dist/context/getLabels.d.ts +2 -2
  35. package/dist/context/index.d.ts +7 -3
  36. package/dist/context/index.js +12 -3
  37. package/dist/deploy/base/deploy.d.ts +2 -2
  38. package/dist/deploy/base/index.d.ts +2 -2
  39. package/dist/deploy/base/rollback.d.ts +2 -2
  40. package/dist/deploy/base/stop.d.ts +2 -2
  41. package/dist/deploy/cloudRun/artifactsRegistry.d.ts +7 -7
  42. package/dist/deploy/cloudRun/cleanup.d.ts +2 -2
  43. package/dist/deploy/cloudRun/cloudRunRevisions.d.ts +2 -2
  44. package/dist/deploy/cloudRun/createJobs/cloudRunJobs.d.ts +6 -6
  45. package/dist/deploy/cloudRun/createJobs/cloudRunServices.d.ts +3 -3
  46. package/dist/deploy/cloudRun/createJobs/common.d.ts +4 -4
  47. package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.d.ts +2 -2
  48. package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +1 -2
  49. package/dist/deploy/cloudRun/createJobs/getCloudRunStopScripts.d.ts +2 -2
  50. package/dist/deploy/cloudRun/createJobs/index.d.ts +2 -2
  51. package/dist/deploy/cloudRun/utils/database.d.ts +3 -3
  52. package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.d.ts +2 -2
  53. package/dist/deploy/cloudRun/utils/getServiceName.d.ts +2 -2
  54. package/dist/deploy/custom/deployJob.d.ts +2 -2
  55. package/dist/deploy/custom/deployJob.js +1 -1
  56. package/dist/deploy/dockerTag/deployJob.d.ts +2 -2
  57. package/dist/deploy/index.d.ts +2 -2
  58. package/dist/deploy/kubernetes/cloudSql/index.d.ts +3 -3
  59. package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
  60. package/dist/deploy/kubernetes/kubeEnv.d.ts +2 -2
  61. package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
  62. package/dist/deploy/kubernetes/kubeValues.js +1 -3
  63. package/dist/deploy/kubernetes/mongodb.d.ts +2 -2
  64. package/dist/deploy/sbom.d.ts +4 -4
  65. package/dist/deploy/utils.d.ts +2 -2
  66. package/dist/pipeline/createJobsForComponent.d.ts +2 -2
  67. package/dist/pipeline/createJobsForComponent.js +1 -1
  68. package/dist/pipeline/generatePipelineFiles.js +15 -5
  69. package/dist/tsconfig.tsbuildinfo +1 -1
  70. package/dist/types/config.d.ts +3 -3
  71. package/dist/types/context.d.ts +16 -2
  72. package/dist/types/jobs.d.ts +1 -1
  73. package/examples/__snapshots__/cloud-run-storybook.ts.snap +1687 -0
  74. package/examples/__utils__/helpers.ts +2 -2
  75. package/examples/cloud-run-storybook.ts +24 -0
  76. package/package.json +1 -1
  77. package/scripts/generate-gitlab-ci-types.ts +2 -2
  78. package/src/bash/BashExpression.ts +4 -4
  79. package/src/bash/bashExpressionPerPipelineType.ts +1 -1
  80. package/src/bash/replaceAsync.ts +4 -4
  81. package/src/build/base/__tests__/createArtifactsConfig.test.ts +3 -3
  82. package/src/build/base/createAppBuildJob.ts +3 -3
  83. package/src/build/base/createArtifactsConfig.ts +2 -2
  84. package/src/build/base/index.ts +2 -2
  85. package/src/build/base/writeBuildInfo.ts +2 -2
  86. package/src/build/base/writeDotEnv.ts +3 -3
  87. package/src/build/custom/__tests__/testJob.test.ts +6 -6
  88. package/src/build/custom/buildJob.ts +4 -2
  89. package/src/build/custom/index.ts +2 -2
  90. package/src/build/custom/testJob.ts +7 -5
  91. package/src/build/docker.ts +18 -18
  92. package/src/build/index.ts +3 -3
  93. package/src/build/node/buildJob.ts +16 -10
  94. package/src/build/node/cache.ts +13 -13
  95. package/src/build/node/index.ts +6 -4
  96. package/src/build/node/meteor.ts +10 -5
  97. package/src/build/node/testJob.ts +14 -11
  98. package/src/build/node/yarn.ts +13 -15
  99. package/src/build/rails/build.ts +4 -2
  100. package/src/build/rails/index.ts +2 -2
  101. package/src/build/rails/test.ts +4 -2
  102. package/src/build/sbom.ts +4 -4
  103. package/src/config/configruedEnvs.ts +6 -6
  104. package/src/config/readConfig.ts +2 -2
  105. package/src/context/__tests__/resolveReferences.test.ts +1 -1
  106. package/src/context/getBuildInfoVariables.ts +5 -5
  107. package/src/context/getEnvConfig.ts +1 -1
  108. package/src/context/getEnvType.ts +1 -1
  109. package/src/context/getEnvironment.ts +2 -2
  110. package/src/context/getEnvironmentContext.ts +4 -4
  111. package/src/context/getEnvironmentVariables.ts +19 -16
  112. package/src/context/getLabels.ts +2 -2
  113. package/src/context/getReviewSlug.ts +2 -2
  114. package/src/context/index.ts +17 -7
  115. package/src/context/resolveReferences.ts +12 -9
  116. package/src/context/transformJobOnlyVars.ts +1 -1
  117. package/src/context/utils/envVars.ts +3 -3
  118. package/src/deploy/base/deploy.ts +7 -7
  119. package/src/deploy/base/index.ts +3 -3
  120. package/src/deploy/base/rollback.ts +3 -3
  121. package/src/deploy/base/stop.ts +3 -3
  122. package/src/deploy/cloudRun/artifactsRegistry.ts +17 -12
  123. package/src/deploy/cloudRun/cleanup.ts +5 -5
  124. package/src/deploy/cloudRun/cloudRunRevisions.ts +6 -6
  125. package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +20 -20
  126. package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +7 -7
  127. package/src/deploy/cloudRun/createJobs/common.ts +5 -5
  128. package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +12 -9
  129. package/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.ts +3 -3
  130. package/src/deploy/cloudRun/createJobs/index.ts +2 -2
  131. package/src/deploy/cloudRun/createJobs/volumes.ts +2 -2
  132. package/src/deploy/cloudRun/index.ts +10 -6
  133. package/src/deploy/cloudRun/utils/createArgsString.ts +1 -1
  134. package/src/deploy/cloudRun/utils/database.ts +8 -8
  135. package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +5 -3
  136. package/src/deploy/cloudRun/utils/getServiceName.ts +2 -2
  137. package/src/deploy/cloudRun/utils/jobName.ts +1 -1
  138. package/src/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.ts +1 -1
  139. package/src/deploy/cloudSql/utils.ts +2 -2
  140. package/src/deploy/custom/deployJob.ts +7 -3
  141. package/src/deploy/dockerTag/deployJob.ts +4 -2
  142. package/src/deploy/index.ts +5 -5
  143. package/src/deploy/kubernetes/cloudSql/index.ts +5 -5
  144. package/src/deploy/kubernetes/deployJob.ts +7 -7
  145. package/src/deploy/kubernetes/index.ts +1 -1
  146. package/src/deploy/kubernetes/kubeEnv.ts +3 -3
  147. package/src/deploy/kubernetes/kubeValues.ts +8 -8
  148. package/src/deploy/kubernetes/mongodb.ts +9 -9
  149. package/src/deploy/kubernetes/processSecretsAsFiles.ts +3 -3
  150. package/src/deploy/sbom.ts +8 -4
  151. package/src/deploy/utils.ts +4 -4
  152. package/src/pipeline/createAllJobs.ts +4 -4
  153. package/src/pipeline/createChildPipeline.ts +2 -2
  154. package/src/pipeline/createJobsForComponent.ts +13 -9
  155. package/src/pipeline/createMainPipeline.ts +20 -17
  156. package/src/pipeline/generatePipelineFiles.ts +21 -12
  157. package/src/pipeline/getPipelineStages.ts +1 -1
  158. package/src/pipeline/gitlab/createGitlabJobs.ts +26 -26
  159. package/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.ts +6 -6
  160. package/src/pipeline/packageManager.ts +2 -2
  161. package/src/pipeline/yarn/yarnUtils.ts +7 -7
  162. package/src/types/config.ts +4 -4
  163. package/src/types/context.ts +19 -3
  164. package/src/types/environmentContext.ts +1 -1
  165. package/src/types/jobs.ts +1 -1
  166. package/src/types/utils.ts +4 -4
  167. package/src/utils/gitlab.ts +1 -1
  168. package/src/utils/index.ts +2 -2
  169. package/src/utils/writeFiles.ts +2 -2
@@ -9,6 +9,6 @@ export const createAllPipelines = async (config: Config) =>
9
9
  ALL_TRIGGERS.map(async (trigger) => [
10
10
  trigger,
11
11
  await createChildPipeline("gitlab", trigger, config),
12
- ])
13
- )
12
+ ]),
13
+ ),
14
14
  );
@@ -0,0 +1,24 @@
1
+ import type { Config } from "../src";
2
+ import { createAllPipelines } from "./__utils__/helpers";
3
+
4
+ const config: Config = {
5
+ appName: "test-app",
6
+ customerName: "pan",
7
+ components: {
8
+ api: {
9
+ dir: "app",
10
+ build: {
11
+ type: "storybook",
12
+ },
13
+ deploy: {
14
+ type: "google-cloudrun",
15
+ projectId: "asdf",
16
+ region: "asia-east1",
17
+ },
18
+ },
19
+ },
20
+ };
21
+
22
+ it("matches snapshot", async () => {
23
+ expect(await createAllPipelines(config)).toMatchSnapshot();
24
+ });
package/package.json CHANGED
@@ -52,7 +52,7 @@
52
52
  }
53
53
  ],
54
54
  "license": "MIT",
55
- "version": "0.0.0-refactor-docker-9fda97e9",
55
+ "version": "0.0.0-refactor-docker-c24f8608",
56
56
  "stableVersion": "0.1.0",
57
57
  "scripts": {
58
58
  "build:tsc": "yarn tsc",
@@ -8,7 +8,7 @@ const typeOutputPath = join(rootPath, "src/types/gitlab-ci-yml.ts");
8
8
 
9
9
  export const generateFromCurrentSchema = async () => {
10
10
  const response = await fetch(
11
- "https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json"
11
+ "https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json",
12
12
  );
13
13
  const gitLabCiJsonSchema = await response.json();
14
14
  const schema = await compile(gitLabCiJsonSchema, "GitlabCiYml", {
@@ -40,7 +40,7 @@ export const generateFromCurrentSchema = async () => {
40
40
  const sanitizedSchenma = schema.replace(
41
41
  // eslint-disable-next-line no-useless-escape
42
42
  /export interface HttpsGitlabComGitlabCiYml \{\n[ a-zA-Z0-9?$:;\n_!"\{\}\/*@\[\],.|\(\)]*\[k\: string\]: Job;\n\}/m,
43
- ""
43
+ "",
44
44
  );
45
45
  if (existsSync(typeOutputPath)) {
46
46
  await rm(typeOutputPath);
@@ -26,14 +26,14 @@ export class BashExpression {
26
26
  */
27
27
  public concat(...values: Array<string | BashExpression>): BashExpression {
28
28
  return new BashExpression(
29
- this.toString().concat(...values.map((v) => v.toString()))
29
+ this.toString().concat(...values.map((v) => v.toString())),
30
30
  );
31
31
  }
32
32
 
33
33
  public transformWithCommand(command: string): BashExpression {
34
34
  return new BashExpression(
35
35
  // see https://stackoverflow.com/a/2264537
36
- `$(printf %s "${this.toString()}" | ${command})`
36
+ `$(printf %s "${this.toString()}" | ${command})`,
37
37
  );
38
38
  }
39
39
  }
@@ -53,14 +53,14 @@ export const getBashVariable = (name: string) => new BashExpression(`$${name}`);
53
53
  */
54
54
  export const joinBashExpressions = (
55
55
  parts: Array<StringOrBashExpression>,
56
- joiner = ""
56
+ joiner = "",
57
57
  ): StringOrBashExpression => {
58
58
  const anyIsBashExpression = parts.some((p) => p instanceof BashExpression);
59
59
  if (anyIsBashExpression) {
60
60
  return new BashExpression(
61
61
  parts
62
62
  .map((p) => (p instanceof BashExpression ? p.toString() : p))
63
- .join(joiner)
63
+ .join(joiner),
64
64
  );
65
65
  } else {
66
66
  return parts.join(joiner);
@@ -9,7 +9,7 @@ export type BashExpressionPerPipelineType = {
9
9
 
10
10
  export const getBashExpressionPerPipelineType = (
11
11
  definition: BashExpressionPerPipelineType,
12
- pipelineType?: PipelineType
12
+ pipelineType?: PipelineType,
13
13
  ) => {
14
14
  if (!pipelineType) return definition.default;
15
15
  return definition[pipelineType] || definition.default;
@@ -8,7 +8,7 @@ export default async function replaceAsync(
8
8
  replacer: (
9
9
  substring: string,
10
10
  ...args: any[]
11
- ) => Promise<string | BashExpression>
11
+ ) => Promise<string | BashExpression>,
12
12
  ) {
13
13
  const wasBashExpression = string instanceof BashExpression;
14
14
  try {
@@ -24,12 +24,12 @@ export default async function replaceAsync(
24
24
  const result = replacer.apply(undefined, args);
25
25
  values.push(result);
26
26
  return "";
27
- }
27
+ },
28
28
  );
29
29
  const resolvedValues = await Promise.all(values);
30
30
 
31
31
  const containsBashExpression = resolvedValues.some(
32
- (value) => value instanceof BashExpression
32
+ (value) => value instanceof BashExpression,
33
33
  );
34
34
 
35
35
  const result = String.prototype.replace.call(
@@ -37,7 +37,7 @@ export default async function replaceAsync(
37
37
  searchValue,
38
38
  function () {
39
39
  return resolvedValues.shift()?.toString() ?? "";
40
- }
40
+ },
41
41
  );
42
42
  if (wasBashExpression || containsBashExpression) {
43
43
  return new BashExpression(result);
@@ -13,13 +13,13 @@ describe("createArtifactsConfig", () => {
13
13
  coverage_report: { coverage_format: "cobertura", path: "some" },
14
14
  terraform: "something",
15
15
  },
16
- })
16
+ }),
17
17
  ).toMatchSnapshot();
18
18
  });
19
19
 
20
20
  it("returns junit parts of artifactsReports", () => {
21
21
  expect(
22
- createArtifactsConfig(".", { junit: ["report.xml"] })
22
+ createArtifactsConfig(".", { junit: ["report.xml"] }),
23
23
  ).toMatchSnapshot();
24
24
  });
25
25
 
@@ -33,7 +33,7 @@ describe("createArtifactsConfig", () => {
33
33
  junit: "full-report.xml",
34
34
  terraform: "something",
35
35
  },
36
- }
36
+ },
37
37
  );
38
38
  expect(result).toMatchSnapshot();
39
39
  expect(result?.artifacts?.reports?.junit).toHaveLength(2);
@@ -1,6 +1,6 @@
1
1
  import { merge } from "lodash";
2
2
  import { join } from "path";
3
- import type { Context } from "../..";
3
+ import type { ComponentContext } from "../..";
4
4
  import { getRunnerImage } from "../..";
5
5
  import type { CatladderJob } from "../../types/jobs";
6
6
  import { ensureArray } from "../../utils";
@@ -14,7 +14,7 @@ import { writeDotEnv } from "./writeDotEnv";
14
14
 
15
15
  export type AppBuildJobDefinition = Partial<CatladderJob>;
16
16
  export const createAppBuildJob = (
17
- context: Context,
17
+ context: ComponentContext,
18
18
  { script, variables, runnerVariables, ...def }: AppBuildJobDefinition,
19
19
  ): CatladderJob => {
20
20
  return merge(
@@ -42,7 +42,7 @@ export const createAppBuildJob = (
42
42
  ? writeDotEnv(context)
43
43
  : []),
44
44
  ...writeBuildInfo(context),
45
- ...ensureNodeVersion(context), // in pure node repos, we might want to have the nvmrc file in top-level
45
+ ...ensureNodeVersion(context.buildContext), // in pure node repos, we might want to have the nvmrc file in top-level
46
46
  `cd ${context.componentConfig.dir}`,
47
47
  ...(ensureArray(script) ?? []),
48
48
  ],
@@ -6,7 +6,7 @@ import type { OptionalArtifacts } from "../custom/testJob";
6
6
  export const createArtifactsConfig = (
7
7
  rootPath: string,
8
8
  artifactsReports?: BuildConfigArtifactsReports,
9
- artifacts?: Artifacts
9
+ artifacts?: Artifacts,
10
10
  ): OptionalArtifacts =>
11
11
  artifactsReports || artifacts
12
12
  ? {
@@ -26,7 +26,7 @@ export const createArtifactsConfig = (
26
26
  .filter(Array.isArray)
27
27
  .reduce(
28
28
  (acc, curr) => [...acc, ...curr.map((p) => join(rootPath, p))],
29
- []
29
+ [],
30
30
  ),
31
31
  },
32
32
  },
@@ -1,5 +1,5 @@
1
1
  import { sbomDeactivated } from "../../deploy/sbom";
2
- import type { Context } from "../../types/context";
2
+ import type { ComponentContext } from "../../types/context";
3
3
  import type { CatladderJob } from "../../types/jobs";
4
4
  import type { DockerBuildJobDefinition } from "../docker";
5
5
  import { createDockerBuildJobBase, requiresDockerBuild } from "../docker";
@@ -9,7 +9,7 @@ import type { AppBuildJobDefinition } from "./createAppBuildJob";
9
9
  import { createAppBuildJob } from "./createAppBuildJob";
10
10
 
11
11
  export const createBuildJobs = (
12
- context: Context,
12
+ context: ComponentContext,
13
13
  definitions: {
14
14
  appBuild?: AppBuildJobDefinition;
15
15
  dockerBuild: DockerBuildJobDefinition;
@@ -1,6 +1,6 @@
1
- import type { Context } from "../../types";
1
+ import type { ComponentContext } from "../../types";
2
2
 
3
- export const writeBuildInfo = (context: Context) => {
3
+ export const writeBuildInfo = (context: ComponentContext) => {
4
4
  return [
5
5
  `echo '{"id":"${context.environment.envVars.BUILD_INFO_BUILD_ID}","time":"${context.environment.envVars.BUILD_INFO_BUILD_TIME}"}' > ${context.componentConfig.dir}/__build_info.json`,
6
6
  ];
@@ -1,12 +1,12 @@
1
1
  import { isNil } from "lodash";
2
- import type { Context } from "../../types";
2
+ import type { ComponentContext } from "../../types";
3
3
 
4
4
  /**
5
5
  * writes a .env file in the components folder
6
6
  * @param context
7
7
  * @returns
8
8
  */
9
- export const writeDotEnv = (context: Context) => {
9
+ export const writeDotEnv = (context: ComponentContext) => {
10
10
  const envVars = context.environment.envVars;
11
11
 
12
12
  // make key=value and sanitize multiline
@@ -14,7 +14,7 @@ export const writeDotEnv = (context: Context) => {
14
14
  // filter out null and undefined values
15
15
  .filter(([, value]) => !isNil(value))
16
16
  .map(
17
- ([key, value]) => `${key}=${value?.toString().replaceAll("\n", "\\n")}`
17
+ ([key, value]) => `${key}=${value?.toString().replaceAll("\n", "\\n")}`,
18
18
  )
19
19
  .join("\n");
20
20
 
@@ -1,13 +1,13 @@
1
- import type { Context } from "../../..";
1
+ import type { ComponentContext } from "../../..";
2
2
  import { createCustomTestJobs } from "../testJob";
3
3
 
4
4
  describe("createCustomTestJobs", () => {
5
- const componentConfig: Context["componentConfig"] = {
5
+ const componentConfig: ComponentContext["componentConfig"] = {
6
6
  dir: ".",
7
7
  build: { type: "custom", docker: { type: "custom" }, jobImage: "" },
8
8
  deploy: {},
9
- } as Context["componentConfig"];
10
- const baseContext: Context = {
9
+ } as ComponentContext["componentConfig"];
10
+ const baseContext: ComponentContext = {
11
11
  componentName: "testComponent",
12
12
  environment: {
13
13
  jobOnlyVars: {
@@ -15,12 +15,12 @@ describe("createCustomTestJobs", () => {
15
15
  },
16
16
  },
17
17
  componentConfig,
18
- } as Context;
18
+ } as ComponentContext;
19
19
 
20
20
  it("throws error when not build type custom", () => {
21
21
  componentConfig.build.type = "node";
22
22
  expect(() => createCustomTestJobs(baseContext)).toThrowError(
23
- "deploy config is not custom"
23
+ "deploy config is not custom",
24
24
  );
25
25
  componentConfig.build.type = "custom";
26
26
  });
@@ -1,5 +1,5 @@
1
1
  import { join } from "path";
2
- import type { Context } from "../../types/context";
2
+ import type { ComponentContext } from "../../types/context";
3
3
  import { ensureArray } from "../../utils";
4
4
  import { getDockerBuildScriptWithBuiltInDockerFile } from "../docker";
5
5
  import { isOfBuildType } from "../types";
@@ -13,7 +13,9 @@ const RUNNER_BUILD_VARIABLES = {
13
13
  KUBERNETES_MEMORY_LIMIT: "4Gi",
14
14
  };
15
15
 
16
- export const createCustomBuildJobs = (context: Context): CatladderJob[] => {
16
+ export const createCustomBuildJobs = (
17
+ context: ComponentContext,
18
+ ): CatladderJob[] => {
17
19
  const buildConfig = context.componentConfig.build;
18
20
 
19
21
  if (!isOfBuildType(buildConfig, "custom")) {
@@ -1,8 +1,8 @@
1
- import type { Context } from "../../types/context";
1
+ import type { ComponentContext } from "../../types/context";
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: Context): CatladderJob[] => {
6
+ export const createCustomJobs = (context: ComponentContext): CatladderJob[] => {
7
7
  return [...createCustomTestJobs(context), ...createCustomBuildJobs(context)];
8
8
  };
@@ -1,4 +1,4 @@
1
- import type { Context } from "../../types/context";
1
+ import type { ComponentContext } from "../../types/context";
2
2
  import type { CatladderJob } from "../../types/jobs";
3
3
  import { ensureArray, notNil } from "../../utils";
4
4
  import { isOfBuildType } from "../types";
@@ -11,7 +11,9 @@ const RUNNER_CUSTOM_TEST_VARIABLES = {
11
11
  KUBERNETES_MEMORY_LIMIT: "4Gi",
12
12
  };
13
13
 
14
- export const createCustomTestJobs = (context: Context): CatladderJob[] => {
14
+ export const createCustomTestJobs = (
15
+ context: ComponentContext,
16
+ ): CatladderJob[] => {
15
17
  // don't run tests after release
16
18
  // TODO: this will be replaced by using rules
17
19
  if (context.trigger === "taggedRelease") {
@@ -48,7 +50,7 @@ export const createCustomTestJobs = (context: Context): CatladderJob[] => {
48
50
  ...createArtifactsConfig(
49
51
  context.componentConfig.dir,
50
52
  buildConfig.audit?.artifactsReports,
51
- buildConfig.audit?.artifacts
53
+ buildConfig.audit?.artifacts,
52
54
  ),
53
55
  }
54
56
  : null;
@@ -63,7 +65,7 @@ export const createCustomTestJobs = (context: Context): CatladderJob[] => {
63
65
  ...createArtifactsConfig(
64
66
  context.componentConfig.dir,
65
67
  buildConfig.lint?.artifactsReports,
66
- buildConfig.lint?.artifacts
68
+ buildConfig.lint?.artifacts,
67
69
  ),
68
70
  }
69
71
  : null;
@@ -77,7 +79,7 @@ export const createCustomTestJobs = (context: Context): CatladderJob[] => {
77
79
  ...createArtifactsConfig(
78
80
  context.componentConfig.dir,
79
81
  buildConfig.test?.artifactsReports,
80
- buildConfig.test?.artifacts
82
+ buildConfig.test?.artifacts,
81
83
  ),
82
84
  }
83
85
  : null;
@@ -1,18 +1,18 @@
1
- import { merge } from "lodash";
2
- import { isOfDeployType } from "../deploy";
3
- import { getRunnerImage } from "../runner";
4
- import type { Context } from "../types";
5
- import type { CatladderJob } from "../types/jobs";
6
1
  import { existsSync } from "fs";
2
+ import { merge } from "lodash";
7
3
  import path from "path";
8
- import { collapseableSection } from "../utils/gitlab";
4
+ import type { BuildConfig, BuildConfigDocker } from ".";
5
+ import { isOfDeployType } from "../deploy";
9
6
  import {
10
7
  getArtifactsRegistryBuildCacheImage,
11
8
  getArtifactsRegistryHost,
12
9
  getArtifactsRegistryImageName,
13
10
  } from "../deploy/cloudRun/artifactsRegistry";
14
11
  import { gcloudServiceAccountLoginCommands } from "../deploy/cloudRun/utils/gcloudServiceAccountLoginCommands";
15
- import type { BuildConfig, BuildConfigDocker } from ".";
12
+ import { getRunnerImage } from "../runner";
13
+ import type { ComponentContext } from "../types";
14
+ import type { CatladderJob } from "../types/jobs";
15
+ import { collapseableSection } from "../utils/gitlab";
16
16
 
17
17
  const DOCKER_BUILD_RUNNER_REQUESTS = {
18
18
  KUBERNETES_CPU_REQUEST: "0.5",
@@ -20,7 +20,7 @@ const DOCKER_BUILD_RUNNER_REQUESTS = {
20
20
  KUBERNETES_MEMORY_LIMIT: "2Gi",
21
21
  };
22
22
 
23
- export const getDockerImageVariables = (context: Context) => {
23
+ export const getDockerImageVariables = (context: ComponentContext) => {
24
24
  return {
25
25
  ...(isOfDeployType(context.componentConfig.deploy, "google-cloudrun")
26
26
  ? {
@@ -49,7 +49,7 @@ export const getDockerImageVariables = (context: Context) => {
49
49
  */
50
50
  export const requiresDockerBuild = ({
51
51
  componentConfig: { deploy },
52
- }: Context): boolean =>
52
+ }: ComponentContext): boolean =>
53
53
  isOfDeployType(deploy, "kubernetes", "google-cloudrun", "dockerTag") ||
54
54
  (isOfDeployType(deploy, "custom") && deploy.requiresDocker);
55
55
 
@@ -76,10 +76,10 @@ const getDockerAdditions = (build: BuildConfig) => {
76
76
  : undefined,
77
77
  };
78
78
  };
79
- export const getDockerBuildVariables = (context: Context) => {
79
+ export const getDockerBuildVariables = (context: ComponentContext) => {
80
80
  return {
81
- ...getDockerAdditions(context.componentConfig.build),
82
- APP_DIR: context.componentConfig.dir,
81
+ ...getDockerAdditions(context.buildContext.config),
82
+ APP_DIR: context.buildContext.dir,
83
83
  DOCKER_DIR: ".", // relative to componentdir
84
84
 
85
85
  ...getDockerImageVariables(context),
@@ -89,7 +89,7 @@ export const getDockerBuildVariables = (context: Context) => {
89
89
  export const DOCKER_BUILD_JOB_NAME = "🔨 docker";
90
90
 
91
91
  export const getDockerJobBaseProps = (
92
- context: Context,
92
+ context: ComponentContext,
93
93
  ): Pick<
94
94
  CatladderJob,
95
95
  "image" | "services" | "variables" | "runnerVariables"
@@ -109,7 +109,7 @@ export const getDockerJobBaseProps = (
109
109
 
110
110
  export type DockerBuildJobDefinition = Partial<CatladderJob>;
111
111
  export const createDockerBuildJobBase = (
112
- context: Context,
112
+ context: ComponentContext,
113
113
  { script, ...def }: Partial<CatladderJob>,
114
114
  ): CatladderJob => {
115
115
  return merge(
@@ -131,7 +131,7 @@ export const createDockerBuildJobBase = (
131
131
  );
132
132
  };
133
133
 
134
- export const gitlabDockerLogin = (context: Context) =>
134
+ export const gitlabDockerLogin = (context: ComponentContext) =>
135
135
  isOfDeployType(context.componentConfig.deploy, "google-cloudrun")
136
136
  ? [
137
137
  ...gcloudServiceAccountLoginCommands(context),
@@ -151,7 +151,7 @@ const BUILT_IN_ENSURE_DOCKERFILE_SCRIPTS = {
151
151
  };
152
152
 
153
153
  export const getDockerBuildScriptWithBuiltInDockerFile = (
154
- context: Context,
154
+ context: ComponentContext,
155
155
  defaultType?: BuildConfigDocker["type"],
156
156
  ) => {
157
157
  const type =
@@ -166,7 +166,7 @@ export const getDockerBuildScriptWithBuiltInDockerFile = (
166
166
  );
167
167
  };
168
168
  export const getDockerBuildDefaultScript = (
169
- context: Context,
169
+ context: ComponentContext,
170
170
  ensureDockerFileScript?: string | null,
171
171
  ) =>
172
172
  [
@@ -191,5 +191,5 @@ export const getDockerBuildDefaultScript = (
191
191
  ]),
192
192
  ].filter(Boolean);
193
193
 
194
- export const hasDockerfile = (context: Context) =>
194
+ export const hasDockerfile = (context: ComponentContext) =>
195
195
  existsSync(path.join(context.componentConfig.dir, "Dockerfile"));
@@ -1,4 +1,4 @@
1
- import type { Context } from "../types/context";
1
+ import type { ComponentContext } from "../types/context";
2
2
  import type { EnvironmentContext } from "../types/environmentContext";
3
3
 
4
4
  import type { CatladderJob } from "../types/jobs";
@@ -12,9 +12,9 @@ export * from "./node";
12
12
 
13
13
  export type BuildTypes = {
14
14
  [type in BuildConfigType]: {
15
- jobs: (context: Context) => CatladderJob[];
15
+ jobs: (context: ComponentContext) => CatladderJob[];
16
16
  defaults: (
17
- envContext: EnvironmentContext<BuildConfigType, any>
17
+ envContext: EnvironmentContext<BuildConfigType, any>,
18
18
  ) => Partial<Extract<BuildConfig, { type: type }>>;
19
19
  };
20
20
  };
@@ -1,6 +1,6 @@
1
1
  import { join } from "path";
2
2
  import { getRunnerImage } from "../../runner";
3
- import type { Context } from "../../types/context";
3
+ import type { ComponentContext } from "../../types/context";
4
4
  import type { CatladderJob } from "../../types/jobs";
5
5
  import { ensureArray } from "../../utils";
6
6
  import { createBuildJobs } from "../base";
@@ -10,7 +10,9 @@ import { getNextCache, getNodeCache, getYarnCache } from "./cache";
10
10
  import { NODE_RUNNER_BUILD_VARIABLES } from "./constants";
11
11
  import { getDockerAppCopyAndBuildScript, getYarnInstall } from "./yarn";
12
12
 
13
- export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
13
+ export const createNodeBuildJobs = (
14
+ context: ComponentContext,
15
+ ): CatladderJob[] => {
14
16
  const buildConfig = context.componentConfig.build;
15
17
 
16
18
  if (!isOfBuildType(buildConfig, "node", "node-static", "storybook")) {
@@ -18,7 +20,7 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
18
20
  }
19
21
 
20
22
  const defaultImage = getRunnerImage("jobs-default");
21
- const yarnInstall = getYarnInstall(context);
23
+ const yarnInstall = getYarnInstall(context.buildContext);
22
24
 
23
25
  return createBuildJobs(context, {
24
26
  appBuild:
@@ -28,7 +30,7 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
28
30
  runnerVariables: NODE_RUNNER_BUILD_VARIABLES,
29
31
  cache: [
30
32
  ...(ensureArray(buildConfig.jobCache) ?? []),
31
- ...getNodeCache(context),
33
+ ...getNodeCache(context.buildContext),
32
34
  ...getNextCache(context),
33
35
  ],
34
36
  script: [
@@ -39,8 +41,8 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
39
41
  paths: [
40
42
  context.componentConfig.dir,
41
43
  // also copy workspace dependencies in monorepo if packages are shared and they create build artifacts
42
- ...(context.packageManagerInfo?.currentWorkspaceDependencies ??
43
- []),
44
+ ...(context.buildContext.packageManagerInfo
45
+ ?.currentWorkspaceDependencies ?? []),
44
46
  ].flatMap((dir) => [
45
47
  join(dir, "__build_info.json"),
46
48
  join(dir, "dist"),
@@ -59,14 +61,18 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
59
61
  dockerBuild: {
60
62
  script: getDockerBuildScriptWithBuiltInDockerFile(
61
63
  context,
62
- buildConfig.type === "node-static" ? "nginx" : "node",
64
+ buildConfig.type === "node-static" || buildConfig.type === "storybook"
65
+ ? "nginx"
66
+ : "node",
63
67
  ),
64
- cache: [...getYarnCache(context, "pull")],
68
+ cache: [...getYarnCache(context.buildContext, "pull")],
65
69
  variables: {
66
70
  // only required for non static
67
- DOCKER_COPY_AND_INSTALL_APP: getDockerAppCopyAndBuildScript(context),
71
+ DOCKER_COPY_AND_INSTALL_APP: getDockerAppCopyAndBuildScript(
72
+ context.buildContext,
73
+ ),
68
74
  DOCKER_COPY_WORKSPACE_FILES:
69
- context.packageManagerInfo?.pathsToCopyInDocker
75
+ context.buildContext.packageManagerInfo?.pathsToCopyInDocker
70
76
  .map((dir) => `COPY --chown=node:node ${dir} /app/${dir}`)
71
77
  ?.join("\n"),
72
78
  },
@@ -1,12 +1,12 @@
1
1
  import { join } from "path";
2
2
  import slugify from "slugify";
3
- import type { Context } from "../../types/context";
3
+ import type { BuildContext, ComponentContext } from "../../types/context";
4
4
  import type { GitlabJobCache } from "../../types/gitlab-types";
5
5
  import { uniq } from "lodash";
6
6
 
7
7
  export const getYarnCache = (
8
- context: Context,
9
- policy = "pull-push"
8
+ context: BuildContext,
9
+ policy = "pull-push",
10
10
  ): GitlabJobCache[] => {
11
11
  const componentIsInWorkspace =
12
12
  context.packageManagerInfo?.componentIsInWorkspace;
@@ -18,16 +18,16 @@ export const getYarnCache = (
18
18
  paths: [".yarn"],
19
19
  }
20
20
  : {
21
- key: slugify(context.componentConfig.dir) + "-yarn",
21
+ key: slugify(context.dir) + "-yarn",
22
22
  policy,
23
- paths: [join(context.componentConfig.dir, ".yarn")],
23
+ paths: [join(context.dir, ".yarn")],
24
24
  },
25
25
  ];
26
26
  };
27
27
 
28
28
  export const getNodeModulesCache = (
29
- context: Context,
30
- policy = "pull-push"
29
+ context: BuildContext,
30
+ policy = "pull-push",
31
31
  ): GitlabJobCache[] => {
32
32
  const componentIsInWorkspace =
33
33
  context.packageManagerInfo?.componentIsInWorkspace;
@@ -39,24 +39,24 @@ export const getNodeModulesCache = (
39
39
  // if component is in a shared workspace, use workspace cache. use individual cache else
40
40
  key: componentIsInWorkspace
41
41
  ? "node-modules-workspace"
42
- : slugify(context.componentConfig.dir) + "-node-modules", // we use the dirname, not the component name, because in certain cases we have two apps in the same directory and want to share the cache, e.g. when having storybook in the same package.json
42
+ : slugify(context.dir) + "-node-modules", // we use the dirname, not the component name, because in certain cases we have two apps in the same directory and want to share the cache, e.g. when having storybook in the same package.json
43
43
  policy,
44
44
  paths: [
45
45
  ...(componentIsInWorkspace
46
46
  ? uniq([
47
47
  "node_modules",
48
48
  ...(context.packageManagerInfo?.workspaces.map((w) =>
49
- join(w.location, "node_modules")
49
+ join(w.location, "node_modules"),
50
50
  ) ?? []),
51
51
  ])
52
- : [join(context.componentConfig.dir, "node_modules")]),
52
+ : [join(context.dir, "node_modules")]),
53
53
  ],
54
54
  },
55
55
  ];
56
56
  };
57
57
  export const getNodeCache = (
58
- context: Context,
59
- policy = "pull-push"
58
+ context: BuildContext,
59
+ policy = "pull-push",
60
60
  ): GitlabJobCache[] => {
61
61
  return [
62
62
  ...getYarnCache(context, policy),
@@ -64,7 +64,7 @@ export const getNodeCache = (
64
64
  ];
65
65
  };
66
66
 
67
- export const getNextCache = (context: Context): GitlabJobCache[] => [
67
+ export const getNextCache = (context: ComponentContext): GitlabJobCache[] => [
68
68
  {
69
69
  key: context.componentName + "-next-cache",
70
70
  policy: "pull-push",