@catladder/pipeline 1.111.4 → 1.112.1

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 (66) hide show
  1. package/dist/build/base/createAppBuildJob.d.ts +8 -0
  2. package/dist/build/base/{createBuildJob.js → createAppBuildJob.js} +3 -3
  3. package/dist/build/base/index.d.ts +8 -0
  4. package/dist/build/base/index.js +57 -0
  5. package/dist/build/custom/buildJob.js +19 -22
  6. package/dist/build/docker.d.ts +2 -4
  7. package/dist/build/docker.js +4 -39
  8. package/dist/build/node/buildJob.js +30 -32
  9. package/dist/build/node/meteor.js +19 -21
  10. package/dist/build/rails/build.js +12 -19
  11. package/dist/build/types.d.ts +4 -3
  12. package/dist/bundles/catladder-gitlab/index.js +1 -1
  13. package/dist/constants.js +1 -1
  14. package/dist/deploy/base/deploy.d.ts +3 -2
  15. package/dist/deploy/base/deploy.js +9 -4
  16. package/dist/deploy/base/index.d.ts +10 -3
  17. package/dist/deploy/base/index.js +37 -16
  18. package/dist/deploy/base/rollback.d.ts +3 -2
  19. package/dist/deploy/base/rollback.js +8 -6
  20. package/dist/deploy/base/stop.d.ts +3 -2
  21. package/dist/deploy/base/stop.js +8 -6
  22. package/dist/deploy/cloudRun/deployJob.js +28 -26
  23. package/dist/deploy/custom/deployJob.js +14 -11
  24. package/dist/deploy/dockerTag/deployJob.js +15 -5
  25. package/dist/deploy/kubernetes/deployJob.js +14 -26
  26. package/dist/deploy/kubernetes/mongodb.d.ts +1 -1
  27. package/dist/deploy/kubernetes/mongodb.js +8 -7
  28. package/dist/deploy/types/index.d.ts +1 -1
  29. package/dist/pipeline/gitlab/createGitlabJobs.d.ts +1 -0
  30. package/dist/pipeline/gitlab/createGitlabJobs.js +4 -1
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/dist/types/gitlab-ci-yml.d.ts +769 -0
  33. package/dist/types/gitlab-ci-yml.js +9 -0
  34. package/dist/types/gitlab-types.d.ts +12 -85
  35. package/dist/types/jobs.d.ts +3 -3
  36. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +0 -36
  37. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +0 -36
  38. package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +0 -36
  39. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +0 -72
  40. package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +0 -36
  41. package/examples/__snapshots__/meteor-kubernetes.ts.snap +0 -36
  42. package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +0 -36
  43. package/package.json +4 -2
  44. package/scripts/generate-gitlab-ci-types.ts +51 -0
  45. package/src/build/base/{createBuildJob.ts → createAppBuildJob.ts} +3 -2
  46. package/src/build/base/index.ts +35 -0
  47. package/src/build/custom/buildJob.ts +32 -45
  48. package/src/build/docker.ts +14 -17
  49. package/src/build/node/buildJob.ts +50 -61
  50. package/src/build/node/meteor.ts +31 -36
  51. package/src/build/rails/build.ts +8 -10
  52. package/src/build/types.ts +4 -8
  53. package/src/deploy/base/deploy.ts +16 -2
  54. package/src/deploy/base/index.ts +22 -3
  55. package/src/deploy/base/rollback.ts +13 -2
  56. package/src/deploy/base/stop.ts +13 -4
  57. package/src/deploy/cloudRun/deployJob.ts +13 -15
  58. package/src/deploy/custom/deployJob.ts +17 -20
  59. package/src/deploy/dockerTag/deployJob.ts +6 -7
  60. package/src/deploy/kubernetes/deployJob.ts +17 -34
  61. package/src/deploy/kubernetes/mongodb.ts +3 -2
  62. package/src/pipeline/gitlab/createGitlabJobs.ts +3 -0
  63. package/src/types/gitlab-ci-yml.ts +892 -0
  64. package/src/types/gitlab-types.ts +49 -86
  65. package/src/types/jobs.ts +3 -4
  66. package/dist/build/base/createBuildJob.d.ts +0 -7
@@ -0,0 +1,35 @@
1
+ import { sbomDeactivated } from "../../deploy/sbom";
2
+ import type { Context } from "../../types/context";
3
+ import type { CatladderJob } from "../../types/jobs";
4
+ import type { DockerBuildJobDefinition } from "../docker";
5
+ import { createDockerBuildJobBase, requiresDockerBuild } from "../docker";
6
+ import { createSbomBuildJob } from "../sbom";
7
+ import { APP_BUILD_JOB_NAME } from "./constants";
8
+ import type { AppBuildJobDefinition } from "./createAppBuildJob";
9
+ import { createAppBuildJob } from "./createAppBuildJob";
10
+
11
+ export const createBuildJobs = (
12
+ context: Context,
13
+ definitions: {
14
+ appBuild?: AppBuildJobDefinition;
15
+ dockerBuild: DockerBuildJobDefinition;
16
+ }
17
+ ): CatladderJob[] => {
18
+ return [
19
+ ...(definitions.appBuild
20
+ ? [createAppBuildJob(context, definitions.appBuild)]
21
+ : []),
22
+ ...(requiresDockerBuild(context)
23
+ ? [
24
+ createDockerBuildJobBase(context, {
25
+ ...definitions.dockerBuild,
26
+ needs: [
27
+ ...(definitions.dockerBuild.needs ?? []),
28
+ ...(definitions.appBuild ? [APP_BUILD_JOB_NAME] : []),
29
+ ],
30
+ }),
31
+ ]
32
+ : []),
33
+ ...(sbomDeactivated(context) ? [] : [createSbomBuildJob(context)]),
34
+ ];
35
+ };
@@ -1,14 +1,11 @@
1
1
  import { join } from "path";
2
2
  import type { Context } from "../../types/context";
3
3
  import { ensureArray } from "../../utils";
4
- import { APP_BUILD_JOB_NAME } from "../base/constants";
5
- import { createBuildJob } from "../base/createBuildJob";
6
- import { createDockerBuildJobDefault, requiresDockerBuild } from "../docker";
4
+ import { getDockerBuildDefaultScript, requiresDockerBuild } from "../docker";
7
5
  import { isOfBuildType } from "../types";
8
6
 
9
7
  import type { CatladderJob } from "../../types/jobs";
10
- import { createSbomBuildJob } from "../sbom";
11
- import { sbomDeactivated } from "../../deploy/sbom";
8
+ import { createBuildJobs } from "../base";
12
9
 
13
10
  const RUNNER_BUILD_VARIABLES = {
14
11
  KUBERNETES_CPU_REQUEST: "0.5",
@@ -24,45 +21,35 @@ export const createCustomBuildJobs = (context: Context): CatladderJob[] => {
24
21
  throw new Error("deploy config is not custom");
25
22
  }
26
23
 
27
- const appBuildJob: CatladderJob | null =
28
- buildConfig.buildCommand !== null
29
- ? createBuildJob(context, {
30
- image: buildConfig.jobImage,
31
- variables: {
32
- ...RUNNER_BUILD_VARIABLES,
33
- },
34
- cache: buildConfig.jobCache,
35
- services: buildConfig.jobServices,
36
- script: [...(ensureArray(buildConfig.buildCommand) ?? [])],
37
- artifacts: {
38
- paths: [
39
- join(context.componentConfig.dir, "__build_info.json"),
40
- join(context.componentConfig.dir, "dist"),
41
- ...(buildConfig.artifactsPaths?.map((path) =>
42
- join(context.componentConfig.dir, path)
43
- ) ?? []),
44
- ],
45
- expire_in: "1 day",
46
- },
47
- })
48
- : null;
49
- return [
50
- ...(appBuildJob ? [appBuildJob] : []),
51
- ...(requiresDockerBuild(context)
52
- ? [
53
- createDockerBuildJobDefault(context, {
54
- script: [
55
- buildConfig.docker?.type === "nginx"
56
- ? "ensureNginxDockerfile"
57
- : "", // e.g. custom,
58
- ].filter(Boolean),
24
+ return createBuildJobs(context, {
25
+ appBuild:
26
+ buildConfig.buildCommand !== null
27
+ ? {
28
+ image: buildConfig.jobImage,
29
+ variables: {
30
+ ...RUNNER_BUILD_VARIABLES,
31
+ },
32
+ cache: buildConfig.jobCache,
33
+ services: buildConfig.jobServices,
34
+ script: [...(ensureArray(buildConfig.buildCommand) ?? [])],
35
+ artifacts: {
36
+ paths: [
37
+ join(context.componentConfig.dir, "__build_info.json"),
38
+ join(context.componentConfig.dir, "dist"),
39
+ ...(buildConfig.artifactsPaths?.map((path) =>
40
+ join(context.componentConfig.dir, path)
41
+ ) ?? []),
42
+ ],
43
+ expire_in: "1 day",
44
+ },
45
+ }
46
+ : undefined,
47
+ dockerBuild: {
48
+ script: getDockerBuildDefaultScript(
49
+ buildConfig.docker?.type === "nginx" ? "ensureNginxDockerfile" : ""
50
+ ),
59
51
 
60
- variables: {},
61
-
62
- needs: appBuildJob ? [APP_BUILD_JOB_NAME] : [],
63
- }),
64
- ]
65
- : []),
66
- ...(sbomDeactivated(context) ? [] : [createSbomBuildJob(context)]),
67
- ];
52
+ variables: {},
53
+ },
54
+ });
68
55
  };
@@ -57,6 +57,7 @@ export const getDockerBuildVariables = (context: Context) => {
57
57
  };
58
58
 
59
59
  export const DOCKER_BUILD_JOB_NAME = "🔨 docker";
60
+
60
61
  export const getDockerJobBaseProps = (context: Context) => {
61
62
  return {
62
63
  image: getRunnerImage("docker-build"),
@@ -69,6 +70,8 @@ export const getDockerJobBaseProps = (context: Context) => {
69
70
  variables: getDockerBaseVariables(),
70
71
  };
71
72
  };
73
+
74
+ export type DockerBuildJobDefinition = Partial<CatladderJob>;
72
75
  export const createDockerBuildJobBase = (
73
76
  context: Context,
74
77
  { script, ...def }: Partial<CatladderJob>
@@ -90,20 +93,14 @@ export const createDockerBuildJobBase = (
90
93
 
91
94
  export const gitlabDockerLogin =
92
95
  "docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY";
93
- export const createDockerBuildJobDefault = (
94
- context: Context,
95
- { script, ...def }: Partial<CatladderJob>
96
- ): CatladderJob => {
97
- return createDockerBuildJobBase(context, {
98
- script: [
99
- ...(script || []),
100
- gitlabDockerLogin,
101
- "docker version",
102
- "docker build --network host --cache-from $DOCKER_CACHE_IMAGE --tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG -f $APP_DIR/Dockerfile . --build-arg BUILDKIT_INLINE_CACHE=1", //BUILDKIT_INLINE_CACHE, see https://testdriven.io/blog/faster-ci-builds-with-docker-cache/
103
- "docker push $DOCKER_IMAGE:$DOCKER_IMAGE_TAG",
104
- "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE",
105
- "docker push $DOCKER_CACHE_IMAGE",
106
- ],
107
- ...def,
108
- });
109
- };
96
+
97
+ export const getDockerBuildDefaultScript = (ensureDockerFileScript?: string) =>
98
+ [
99
+ ensureDockerFileScript,
100
+ gitlabDockerLogin,
101
+ "docker version",
102
+ "docker build --network host --cache-from $DOCKER_CACHE_IMAGE --tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG -f $APP_DIR/Dockerfile . --build-arg BUILDKIT_INLINE_CACHE=1", //BUILDKIT_INLINE_CACHE, see https://testdriven.io/blog/faster-ci-builds-with-docker-cache/
103
+ "docker push $DOCKER_IMAGE:$DOCKER_IMAGE_TAG",
104
+ "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE",
105
+ "docker push $DOCKER_CACHE_IMAGE",
106
+ ].filter(Boolean);
@@ -1,17 +1,14 @@
1
+ import { join } from "path";
2
+ import { getRunnerImage } from "../../runner";
1
3
  import type { Context } from "../../types/context";
4
+ import type { CatladderJob } from "../../types/jobs";
2
5
  import { ensureArray } from "../../utils";
3
- import { APP_BUILD_JOB_NAME } from "../base/constants";
4
- import { createBuildJob } from "../base/createBuildJob";
5
- import { createDockerBuildJobDefault, requiresDockerBuild } from "../docker";
6
- import { join } from "path";
6
+ import { createBuildJobs } from "../base";
7
+ import { getDockerBuildDefaultScript, requiresDockerBuild } from "../docker";
7
8
  import { isOfBuildType } from "../types";
8
9
  import { getNextCache, getNodeCache, getYarnCache } from "./cache";
9
10
  import { NODE_RUNNER_BUILD_VARIABLES } from "./constants";
10
11
  import { getDockerAppCopyAndBuildScript, getYarnInstall } from "./yarn";
11
- import type { CatladderJob } from "../../types/jobs";
12
- import { getRunnerImage } from "../../runner";
13
- import { createSbomBuildJob } from "../sbom";
14
- import { sbomDeactivated } from "../../deploy/sbom";
15
12
 
16
13
  export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
17
14
  const buildConfig = context.componentConfig.build;
@@ -22,62 +19,54 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
22
19
 
23
20
  const defaultImage = getRunnerImage("jobs-default");
24
21
  const yarnInstall = getYarnInstall(context);
25
- const appBuildJob: CatladderJob | null =
26
- buildConfig.buildCommand !== null
27
- ? createBuildJob(context, {
28
- image: buildConfig.jobImage ?? defaultImage,
29
- variables: {
30
- ...NODE_RUNNER_BUILD_VARIABLES,
31
- },
32
- cache: [
33
- ...(ensureArray(buildConfig.jobCache) ?? []),
34
- ...getNodeCache(context),
35
- ...getNextCache(context),
36
- ],
37
- script: [
38
- ...yarnInstall,
39
- ...(ensureArray(buildConfig.buildCommand) ?? []),
40
- ],
41
- artifacts: {
42
- paths: [
43
- join(context.componentConfig.dir, "__build_info.json"),
44
- join(context.componentConfig.dir, "dist"),
45
- join(context.componentConfig.dir, ".next"),
46
- ...(buildConfig.artifactsPaths?.map((path) =>
47
- join(context.componentConfig.dir, path)
48
- ) ?? []),
22
+
23
+ return createBuildJobs(context, {
24
+ appBuild:
25
+ buildConfig.buildCommand !== null
26
+ ? {
27
+ image: buildConfig.jobImage ?? defaultImage,
28
+ variables: {
29
+ ...NODE_RUNNER_BUILD_VARIABLES,
30
+ },
31
+ cache: [
32
+ ...(ensureArray(buildConfig.jobCache) ?? []),
33
+ ...getNodeCache(context),
34
+ ...getNextCache(context),
49
35
  ],
50
- expire_in: "1 day",
51
- },
52
- jobTags: buildConfig.jobTags,
53
- })
54
- : null;
55
- return [
56
- ...(appBuildJob ? [appBuildJob] : []),
57
- ...(requiresDockerBuild(context)
58
- ? [
59
- createDockerBuildJobDefault(context, {
60
36
  script: [
61
- buildConfig.type === "node-static" ||
62
- buildConfig.type === "storybook"
63
- ? "ensureNginxDockerfile"
64
- : "ensureNodeDockerfile",
37
+ ...yarnInstall,
38
+ ...(ensureArray(buildConfig.buildCommand) ?? []),
65
39
  ],
66
- cache: [...getYarnCache(context, "pull")],
67
- variables: {
68
- // only required for non static
69
- DOCKER_COPY_AND_INSTALL_APP:
70
- getDockerAppCopyAndBuildScript(context),
71
- DOCKER_COPY_WORKSPACE_FILES:
72
- context.packageManagerInfo?.pathsToCopyInDocker
73
- .map((dir) => `COPY --chown=node:node ${dir} /app/${dir}`)
74
- ?.join("\n"),
40
+ artifacts: {
41
+ paths: [
42
+ join(context.componentConfig.dir, "__build_info.json"),
43
+ join(context.componentConfig.dir, "dist"),
44
+ join(context.componentConfig.dir, ".next"),
45
+ ...(buildConfig.artifactsPaths?.map((path) =>
46
+ join(context.componentConfig.dir, path)
47
+ ) ?? []),
48
+ ],
49
+ expire_in: "1 day",
75
50
  },
51
+ jobTags: buildConfig.jobTags,
52
+ }
53
+ : undefined,
76
54
 
77
- needs: appBuildJob ? [APP_BUILD_JOB_NAME] : [],
78
- }),
79
- ]
80
- : []),
81
- ...(sbomDeactivated(context) ? [] : [createSbomBuildJob(context)]),
82
- ];
55
+ dockerBuild: {
56
+ script: getDockerBuildDefaultScript(
57
+ buildConfig.type === "node-static" || buildConfig.type === "storybook"
58
+ ? "ensureNginxDockerfile"
59
+ : "ensureNodeDockerfile"
60
+ ),
61
+ cache: [...getYarnCache(context, "pull")],
62
+ variables: {
63
+ // only required for non static
64
+ DOCKER_COPY_AND_INSTALL_APP: getDockerAppCopyAndBuildScript(context),
65
+ DOCKER_COPY_WORKSPACE_FILES:
66
+ context.packageManagerInfo?.pathsToCopyInDocker
67
+ .map((dir) => `COPY --chown=node:node ${dir} /app/${dir}`)
68
+ ?.join("\n"),
69
+ },
70
+ },
71
+ });
83
72
  };
@@ -5,14 +5,11 @@ import type { Context } from "../../types/context";
5
5
 
6
6
  import type { CatladderJob } from "../../types/jobs";
7
7
 
8
- import { APP_BUILD_JOB_NAME } from "../base/constants";
9
- import { createBuildJob } from "../base/createBuildJob";
10
- import { createDockerBuildJobDefault } from "../docker";
8
+ import { createBuildJobs } from "../base";
9
+ import { getDockerBuildDefaultScript } from "../docker";
11
10
  import { isOfBuildType } from "../types";
12
11
  import { getNodeCache } from "./cache";
13
12
  import { getYarnInstall } from "./yarn";
14
- import { sbomDeactivated } from "../../deploy/sbom";
15
- import { createSbomBuildJob } from "../sbom";
16
13
 
17
14
  const getMeteorCache = (context: Context): GitlabJobCache[] => [
18
15
  {
@@ -37,42 +34,40 @@ export const createMeteorBuildJobs = (context: Context): CatladderJob[] => {
37
34
  }
38
35
 
39
36
  const yarnInstall = getYarnInstall(context);
40
- const appBuildJob: CatladderJob | null =
41
- buildConfig.buildCommand !== null
42
- ? createBuildJob(context, {
43
- cache: [...getNodeCache(context), ...getMeteorCache(context)],
44
- image: getRunnerImage("jobs-meteor"),
45
- variables: {
46
- METEOR_DISABLE_OPTIMISTIC_CACHING: "1", // see https://forums.meteor.com/t/veeery-long-building-time-inside-docker-container/58673/17?u=macrozone
47
- },
48
- script: [
49
- ...yarnInstall,
50
37
 
51
- 'echo "add healthcheck package"',
52
- "meteor add panter:healthroute --allow-superuser",
53
- "meteor add qualia:prod-shell --allow-superuser",
38
+ return createBuildJobs(context, {
39
+ appBuild:
40
+ buildConfig.buildCommand !== null
41
+ ? {
42
+ cache: [...getNodeCache(context), ...getMeteorCache(context)],
43
+ image: getRunnerImage("jobs-meteor"),
44
+ variables: {
45
+ METEOR_DISABLE_OPTIMISTIC_CACHING: "1", // see https://forums.meteor.com/t/veeery-long-building-time-inside-docker-container/58673/17?u=macrozone
46
+ },
47
+ script: [
48
+ ...yarnInstall,
54
49
 
55
- 'TOOL_NODE_FLAGS="--max_old_space_size=3584 --min_semi_space_size=8 --max_semi_space_size=256 --optimize_for_size" meteor build ./dist --architecture os.linux.x86_64 --allow-superuser --server-only --directory',
50
+ 'echo "add healthcheck package"',
51
+ "meteor add panter:healthroute --allow-superuser",
52
+ "meteor add qualia:prod-shell --allow-superuser",
56
53
 
57
- "cp ./__build_info.json ./dist/bundle/programs/server",
58
- ],
59
- artifacts: {
60
- paths: [
61
- context.componentConfig.dir + "/__build_info.json",
62
- context.componentConfig.dir + "/dist",
54
+ 'TOOL_NODE_FLAGS="--max_old_space_size=3584 --min_semi_space_size=8 --max_semi_space_size=256 --optimize_for_size" meteor build ./dist --architecture os.linux.x86_64 --allow-superuser --server-only --directory',
55
+
56
+ "cp ./__build_info.json ./dist/bundle/programs/server",
63
57
  ],
64
- },
65
- })
66
- : null;
67
- return [
68
- ...(appBuildJob ? [appBuildJob] : []),
69
- createDockerBuildJobDefault(context, {
70
- script: ["ensureMeteorDockerfile"],
58
+ artifacts: {
59
+ paths: [
60
+ context.componentConfig.dir + "/__build_info.json",
61
+ context.componentConfig.dir + "/dist",
62
+ ],
63
+ },
64
+ }
65
+ : undefined,
66
+ dockerBuild: {
67
+ script: getDockerBuildDefaultScript("ensureMeteorDockerfile"),
71
68
  variables: {
72
69
  METEOR_INSTALL_SCRIPTS: buildConfig.installScripts ? "true" : "",
73
70
  },
74
- needs: appBuildJob ? [APP_BUILD_JOB_NAME] : [],
75
- }),
76
- ...(sbomDeactivated(context) ? [] : [createSbomBuildJob(context)]),
77
- ];
71
+ },
72
+ });
78
73
  };
@@ -1,9 +1,8 @@
1
1
  import type { Context } from "../..";
2
- import { isOfBuildType } from "../types";
3
2
  import type { CatladderJob } from "../../types/jobs";
4
- import { createDockerBuildJobBase, gitlabDockerLogin } from "../docker";
5
- import { sbomDeactivated } from "../../deploy/sbom";
6
- import { createSbomBuildJob } from "../sbom";
3
+ import { createBuildJobs } from "../base";
4
+ import { gitlabDockerLogin } from "../docker";
5
+ import { isOfBuildType } from "../types";
7
6
 
8
7
  export const createRailsBuildJobs = (context: Context): CatladderJob[] => {
9
8
  const buildConfig = context.componentConfig.build;
@@ -17,9 +16,9 @@ export const createRailsBuildJobs = (context: Context): CatladderJob[] => {
17
16
  const packEnvArgs = Object.entries(cnbConf?.buildVars ?? {})
18
17
  .map(([k, v]) => `--env '${k}${v ? `=${v}` : ""}'`)
19
18
  .join(" ");
20
-
21
- return [
22
- createDockerBuildJobBase(context, {
19
+ return createBuildJobs(context, {
20
+ appBuild: undefined,
21
+ dockerBuild: {
23
22
  variables: {
24
23
  ...context.environment.jobOnlyVars.build.envVars,
25
24
  ...context.componentConfig.build.extraVars,
@@ -38,7 +37,6 @@ export const createRailsBuildJobs = (context: Context): CatladderJob[] => {
38
37
  cnbConf?.packExtraArgs?.join(" ") ?? ""
39
38
  }`,
40
39
  ],
41
- }),
42
- ...(sbomDeactivated(context) ? [] : [createSbomBuildJob(context)]),
43
- ];
40
+ },
41
+ });
44
42
  };
@@ -1,9 +1,5 @@
1
- import type {
2
- Artifacts,
3
- EnvVars,
4
- GitlabJobImage,
5
- GitlabJobService,
6
- } from "../types";
1
+ import type { Artifacts, EnvVars, GitlabJobImage } from "../types";
2
+ import type { Services } from "../types/gitlab-ci-yml";
7
3
 
8
4
  import type { CatladderJob } from "../types/jobs";
9
5
 
@@ -168,9 +164,9 @@ export type BuildConfigCustom = Omit<
168
164
  type: "custom";
169
165
  jobImage: GitlabJobImage;
170
166
  /**
171
- * {@link GitlabJobService}s used in lint, test, audit, and build jobs.
167
+ * {@link Services}s used in lint, test, audit, and build jobs.
172
168
  */
173
- jobServices?: GitlabJobService[];
169
+ jobServices?: Services;
174
170
 
175
171
  docker: BuildConfigCustomDocker;
176
172
 
@@ -4,15 +4,23 @@ import {
4
4
  } from "../../build/docker";
5
5
  import { SBOM_BUILD_JOB_NAME } from "../../build/sbom";
6
6
  import type { Context } from "../../types/context";
7
+ import type { CatladderJob } from "../../types/jobs";
7
8
  import { sbomDeactivated } from "../sbom";
8
9
  import { contextIsStoppable } from "../utils";
9
10
  import { STOP_JOB_NAME } from "./stop";
10
- import type { JobWithoutScript } from "./types";
11
+
11
12
  import { DEPLOY_RUNNER_VARIABLES } from "./variables";
12
13
 
13
14
  export const DEPLOY_JOB_NAME = "🚀 Deploy";
14
15
 
15
- export const getBaseDeploymentJob = (context: Context): JobWithoutScript => {
16
+ export type DeployJobDefinition = Pick<
17
+ CatladderJob,
18
+ "script" | "variables" | "image" | "cache" | "artifacts" | "services"
19
+ >;
20
+ export const createDeployJob = (
21
+ context: Context,
22
+ jobDefinition: DeployJobDefinition
23
+ ): CatladderJob => {
16
24
  const hasDocker = requiresDockerBuild(context);
17
25
  const isStoppable = contextIsStoppable(context);
18
26
 
@@ -39,6 +47,11 @@ export const getBaseDeploymentJob = (context: Context): JobWithoutScript => {
39
47
 
40
48
  return {
41
49
  name: DEPLOY_JOB_NAME,
50
+ script: jobDefinition.script,
51
+ image: jobDefinition.image,
52
+ cache: jobDefinition.cache,
53
+ artifacts: jobDefinition.artifacts,
54
+ services: jobDefinition.services,
42
55
  envMode: "stagePerEnv", // makes it easier to run manual tasks er env
43
56
 
44
57
  needs: [
@@ -83,6 +96,7 @@ export const getBaseDeploymentJob = (context: Context): JobWithoutScript => {
83
96
  ...(context.componentConfig.deploy
84
97
  ? context.componentConfig.deploy.extraVars ?? {}
85
98
  : {}),
99
+ ...jobDefinition.variables,
86
100
  },
87
101
  environment: {
88
102
  ...context.environment.gitlabEnvironment,
@@ -1,3 +1,22 @@
1
- export * from "./deploy";
2
- export * from "./rollback";
3
- export * from "./stop";
1
+ import type { Context } from "../../types/context";
2
+ import type { CatladderJob } from "../../types/jobs";
3
+ import { createDeployJob, type DeployJobDefinition } from "./deploy";
4
+ import { createRollbackJob, type RollbackJobDefinition } from "./rollback";
5
+ import { createStopJob, type StopJobDefinition } from "./stop";
6
+
7
+ export const createDeployementJobs = (
8
+ context: Context,
9
+ definitions: {
10
+ deploy: DeployJobDefinition;
11
+ stop?: StopJobDefinition;
12
+ rollback?: RollbackJobDefinition;
13
+ }
14
+ ): CatladderJob[] => {
15
+ return [
16
+ createDeployJob(context, definitions.deploy),
17
+ ...(definitions.stop ? [createStopJob(context, definitions.stop)] : []),
18
+ ...(definitions.rollback
19
+ ? [createRollbackJob(context, definitions.rollback)]
20
+ : []),
21
+ ];
22
+ };
@@ -1,12 +1,20 @@
1
1
  import type { Context } from "../../types/context";
2
- import type { JobWithoutScript } from "./types";
2
+ import type { CatladderJob } from "../../types/jobs";
3
3
  import { DEPLOY_RUNNER_VARIABLES } from "./variables";
4
4
 
5
5
  export const ROLLBACK_JOB_NAME = "↩️ Rollback ⚠️";
6
6
 
7
- export const getBaseRollbackJob = (context: Context): JobWithoutScript => {
7
+ export type RollbackJobDefinition = Pick<
8
+ CatladderJob,
9
+ "script" | "variables" | "image"
10
+ >;
11
+ export const createRollbackJob = (
12
+ context: Context,
13
+ jobDefinition: RollbackJobDefinition
14
+ ): CatladderJob => {
8
15
  return {
9
16
  name: ROLLBACK_JOB_NAME,
17
+ image: jobDefinition.image,
10
18
  envMode: "stagePerEnv", // makes it easier to run manual tasks er env
11
19
  needs: [], // can be executed even if the deploy job failed
12
20
  rules: [
@@ -19,11 +27,14 @@ export const getBaseRollbackJob = (context: Context): JobWithoutScript => {
19
27
  ...DEPLOY_RUNNER_VARIABLES,
20
28
  ...context.environment.jobOnlyVars.deploy.envVars,
21
29
  GIT_STRATEGY: "none",
30
+ ...jobDefinition.variables,
22
31
  },
23
32
  stage: "rollback",
24
33
  environment: {
25
34
  ...context.environment.gitlabEnvironment,
26
35
  action: "access",
27
36
  },
37
+
38
+ script: jobDefinition.script,
28
39
  };
29
40
  };
@@ -1,13 +1,20 @@
1
1
  import type { Context } from "../../types/context";
2
- import type { JobWithoutScript } from "./types";
2
+ import type { CatladderJob } from "../../types/jobs";
3
+
3
4
  import { DEPLOY_RUNNER_VARIABLES } from "./variables";
4
5
  export const STOP_JOB_NAME = "🛑 Stop ⚠️";
5
6
 
6
- export const getBaseDeploymentStopJob = (
7
- context: Context
8
- ): JobWithoutScript => {
7
+ export type StopJobDefinition = Pick<
8
+ CatladderJob,
9
+ "script" | "variables" | "image"
10
+ >;
11
+ export const createStopJob = (
12
+ context: Context,
13
+ jobDefinition: StopJobDefinition
14
+ ): CatladderJob => {
9
15
  return {
10
16
  name: STOP_JOB_NAME,
17
+ image: jobDefinition.image,
11
18
  envMode: "stagePerEnv", // makes it easier to run manual tasks er env
12
19
  needs: [], // can be executed even if the deploy job failed
13
20
  rules: [
@@ -25,11 +32,13 @@ export const getBaseDeploymentStopJob = (
25
32
  ...DEPLOY_RUNNER_VARIABLES,
26
33
  ...context.environment.jobOnlyVars.deploy.envVars,
27
34
  GIT_STRATEGY: "none",
35
+ ...jobDefinition.variables,
28
36
  },
29
37
  stage: "stop",
30
38
  environment: {
31
39
  ...context.environment.gitlabEnvironment,
32
40
  action: "stop",
33
41
  },
42
+ script: jobDefinition.script,
34
43
  };
35
44
  };