@catladder/pipeline 1.168.0 → 1.168.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 (43) hide show
  1. package/dist/build/base/createAppBuildJob.d.ts +1 -2
  2. package/dist/build/base/createBuildJobDefinition.d.ts +3 -4
  3. package/dist/build/base/index.d.ts +1 -2
  4. package/dist/build/cache/createJobCache.d.ts +3 -2
  5. package/dist/build/cache/createJobCache.js +2 -2
  6. package/dist/build/cache/getAllCacheConfigsFromConfig.d.ts +2 -2
  7. package/dist/build/cache/getAllCacheConfigsFromConfig.js +2 -6
  8. package/dist/build/docker.d.ts +2 -3
  9. package/dist/build/node/buildJob.d.ts +1 -2
  10. package/dist/build/types.d.ts +6 -0
  11. package/dist/bundles/catladder-gitlab/index.js +1 -1
  12. package/dist/constants.js +1 -1
  13. package/dist/context/getEnvironmentVariables.d.ts +1 -1
  14. package/dist/deploy/base/deploy.d.ts +1 -1
  15. package/dist/deploy/base/deploy.js +2 -1
  16. package/dist/deploy/base/index.d.ts +1 -3
  17. package/dist/deploy/base/rollback.d.ts +1 -1
  18. package/dist/deploy/base/stop.d.ts +1 -1
  19. package/dist/deploy/custom/deployJob.js +6 -4
  20. package/dist/deploy/types/custom.d.ts +2 -6
  21. package/dist/tsconfig.tsbuildinfo +1 -1
  22. package/dist/types/config.d.ts +3 -3
  23. package/dist/types/jobDefinition.d.ts +8 -2
  24. package/examples/__snapshots__/custom-deploy.test.ts.snap +0 -4
  25. package/examples/__snapshots__/native-app.test.ts.snap +4 -0
  26. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +0 -8
  27. package/examples/native-app.ts +6 -6
  28. package/package.json +1 -1
  29. package/src/build/base/createAppBuildJob.ts +1 -2
  30. package/src/build/base/createBuildJobDefinition.ts +3 -4
  31. package/src/build/base/index.ts +4 -2
  32. package/src/build/cache/createJobCache.ts +6 -9
  33. package/src/build/cache/getAllCacheConfigsFromConfig.ts +5 -12
  34. package/src/build/docker.ts +2 -3
  35. package/src/build/node/buildJob.ts +4 -2
  36. package/src/build/types.ts +7 -0
  37. package/src/deploy/base/deploy.ts +5 -11
  38. package/src/deploy/base/index.ts +8 -3
  39. package/src/deploy/base/rollback.ts +1 -4
  40. package/src/deploy/base/stop.ts +1 -4
  41. package/src/deploy/custom/deployJob.ts +5 -2
  42. package/src/deploy/types/custom.ts +3 -7
  43. package/src/types/jobDefinition.ts +27 -2
@@ -262,7 +262,6 @@ api 🧪 test:
262
262
  - yarn deploy
263
263
  - echo 'Uploading SBOM to Dependency Track'
264
264
  - /dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" upload "pan-test-app/api" "https://unknown-host.example.com" "__sbom.json" vex.json || true
265
- cache: []
266
265
  rules:
267
266
  - when: never
268
267
  if: $CI_COMMIT_MESSAGE =~ /^chore\\(release\\).*/
@@ -387,7 +386,6 @@ api 🧪 test:
387
386
  - yarn deploy
388
387
  - echo 'Uploading SBOM to Dependency Track'
389
388
  - /dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" upload "pan-test-app/api" "https://unknown-host.example.com" "__sbom.json" vex.json || true
390
- cache: []
391
389
  rules:
392
390
  - when: on_success
393
391
  if: $CI_MERGE_REQUEST_ID
@@ -510,7 +508,6 @@ api 🧪 test:
510
508
  - yarn deploy
511
509
  - echo 'Uploading SBOM to Dependency Track'
512
510
  - /dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" upload "pan-test-app/api" "https://unknown-host.example.com" "__sbom.json" vex.json || true
513
- cache: []
514
511
  rules:
515
512
  - when: on_success
516
513
  if: $CI_COMMIT_TAG
@@ -627,7 +624,6 @@ api 🧪 test:
627
624
  - yarn deploy
628
625
  - echo 'Uploading SBOM to Dependency Track'
629
626
  - /dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" upload "pan-test-app/api" "https://unknown-host.example.com" "__sbom.json" vex.json || true
630
- cache: []
631
627
  rules:
632
628
  - when: manual
633
629
  if: $CI_COMMIT_TAG
@@ -852,7 +848,6 @@ www 🧪 test:
852
848
  - yarn deploy
853
849
  - echo 'Uploading SBOM to Dependency Track'
854
850
  - /dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" upload "pan-test-app/www" "https://unknown-host.example.com" "__sbom.json" vex.json || true
855
- cache: []
856
851
  rules:
857
852
  - when: never
858
853
  if: $CI_COMMIT_MESSAGE =~ /^chore\\(release\\).*/
@@ -979,7 +974,6 @@ www 🧪 test:
979
974
  - yarn deploy
980
975
  - echo 'Uploading SBOM to Dependency Track'
981
976
  - /dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" upload "pan-test-app/www" "https://unknown-host.example.com" "__sbom.json" vex.json || true
982
- cache: []
983
977
  rules:
984
978
  - when: on_success
985
979
  if: $CI_MERGE_REQUEST_ID
@@ -1104,7 +1098,6 @@ www 🧪 test:
1104
1098
  - yarn deploy
1105
1099
  - echo 'Uploading SBOM to Dependency Track'
1106
1100
  - /dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" upload "pan-test-app/www" "https://unknown-host.example.com" "__sbom.json" vex.json || true
1107
- cache: []
1108
1101
  rules:
1109
1102
  - when: on_success
1110
1103
  if: $CI_COMMIT_TAG
@@ -1223,7 +1216,6 @@ www 🧪 test:
1223
1216
  - yarn deploy
1224
1217
  - echo 'Uploading SBOM to Dependency Track'
1225
1218
  - /dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" upload "pan-test-app/www" "https://unknown-host.example.com" "__sbom.json" vex.json || true
1226
- cache: []
1227
1219
  rules:
1228
1220
  - when: manual
1229
1221
  if: $CI_COMMIT_TAG
@@ -1,12 +1,12 @@
1
- import type { Config } from "../src";
1
+ import type { CacheConfig, Config } from "../src";
2
2
  import type { CatladderJob } from "../src/types/jobs";
3
3
 
4
- const APP_GEM_CACHE: CatladderJob["cache"] = [
4
+ const APP_GEM_CACHE: CacheConfig[] = [
5
5
  {
6
6
  key: {
7
- files: ["app/Gemfile.lock"],
7
+ files: ["Gemfile.lock"],
8
8
  },
9
- paths: ["app/vendor"],
9
+ paths: ["vendor"],
10
10
  },
11
11
  ];
12
12
 
@@ -41,7 +41,7 @@ const config: Config = {
41
41
  "bundle exec fastlane build",
42
42
  ],
43
43
  jobTags: ["mac-runner"],
44
- jobCache: APP_GEM_CACHE,
44
+ cache: APP_GEM_CACHE,
45
45
  },
46
46
 
47
47
  deploy: {
@@ -58,7 +58,7 @@ const config: Config = {
58
58
  "bundle exec fastlane deploy_test",
59
59
  ],
60
60
  jobTags: ["mac-runner"],
61
- jobCache: APP_GEM_CACHE,
61
+ cache: APP_GEM_CACHE,
62
62
  },
63
63
  },
64
64
 
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "1.168.0",
56
+ "version": "1.168.1",
57
57
  "scripts": {
58
58
  "build:tsc": "yarn tsc",
59
59
  "build": "yarn build:compile && yarn build:inline-variables && yarn build:bundle",
@@ -5,7 +5,7 @@ import type {
5
5
  WorkspaceContext,
6
6
  } from "../..";
7
7
  import { getRunnerImage } from "../..";
8
- import type { JobDefintion } from "../../types/jobDefinition";
8
+ import type { AppBuildJobDefinition } from "../../types/jobDefinition";
9
9
  import type { CatladderJob } from "../../types/jobs";
10
10
  import { ensureArray } from "../../utils";
11
11
  import { createBuildJobArtifacts } from "../artifacts/createBuildJobArtifact";
@@ -21,7 +21,6 @@ import {
21
21
  writeDotEnv,
22
22
  } from "./writeDotEnv";
23
23
 
24
- export type AppBuildJobDefinition = JobDefintion;
25
24
  export const createAppBuildJob = (
26
25
  context: ComponentContext<BuildContextStandalone> | WorkspaceContext,
27
26
  { script, variables, runnerVariables, cache, ...def }: AppBuildJobDefinition,
@@ -1,7 +1,6 @@
1
1
  import type { BuildConfigStandalone, WorkspaceBuildConfig } from "..";
2
2
  import { getRunnerImage } from "../../runner";
3
- import type { Context } from "../../types";
4
- import type { JobDefintion } from "../../types/jobDefinition";
3
+ import type { AppBuildJobDefinition, Context } from "../../types";
5
4
  import { ensureArray } from "../../utils";
6
5
  import { getAllCacheConfigsFromConfig } from "../cache/getAllCacheConfigsFromConfig";
7
6
  import { NODE_RUNNER_BUILD_VARIABLES } from "../node/constants";
@@ -9,11 +8,11 @@ import { NODE_RUNNER_BUILD_VARIABLES } from "../node/constants";
9
8
  export const createBuildJobDefinition = (
10
9
  context: Context,
11
10
  buildConfig: BuildConfigStandalone | WorkspaceBuildConfig,
12
- customize: Pick<JobDefintion, "cache"> & {
11
+ customize: Pick<AppBuildJobDefinition, "cache"> & {
13
12
  prescript?: string[];
14
13
  postscript?: string[];
15
14
  } = {},
16
- ): JobDefintion | undefined => {
15
+ ): AppBuildJobDefinition | undefined => {
17
16
  if (buildConfig.buildCommand === null) return undefined;
18
17
 
19
18
  const defaultImage = getRunnerImage("jobs-default");
@@ -5,12 +5,14 @@ import {
5
5
  componentContextIsStandaloneBuild,
6
6
  type ComponentContext,
7
7
  } from "../../types/context";
8
+ import type {
9
+ AppBuildJobDefinition,
10
+ DockerBuildJobDefinition,
11
+ } from "../../types/jobDefinition";
8
12
  import type { CatladderJob } from "../../types/jobs";
9
- import type { DockerBuildJobDefinition } from "../docker";
10
13
  import { createDockerBuildJobBase, requiresDockerBuild } from "../docker";
11
14
  import { createSbomBuildJob } from "../sbom";
12
15
  import { APP_BUILD_JOB_NAME } from "./constants";
13
- import type { AppBuildJobDefinition } from "./createAppBuildJob";
14
16
  import { createAppBuildJob } from "./createAppBuildJob";
15
17
 
16
18
  export const createComponentBuildJobs = (
@@ -1,13 +1,8 @@
1
1
  import { join } from "path";
2
- import type {
3
- BuildConfigStandalone,
4
- CacheConfig,
5
- CacheConfigAdvanced,
6
- CacheConfigSimple,
7
- WorkspaceBuildConfig,
8
- } from "..";
2
+ import type { CacheConfig, CacheConfigAdvanced, CacheConfigSimple } from "..";
9
3
  import type { Context } from "../../types";
10
4
  import type { CatladderJobCache } from "../../types/jobs";
5
+ import type { WithCacheConfig } from "../types";
11
6
  import { getAllCacheConfigsFromConfig } from "./getAllCacheConfigsFromConfig";
12
7
 
13
8
  export const createJobCacheFromCacheConfigs = (
@@ -61,6 +56,7 @@ export const createJobCacheFromCacheConfigs = (
61
56
  pathMode === "absolute" ? f : join(baseDir, f),
62
57
  ),
63
58
  };
59
+
64
60
  return {
65
61
  key: transformedKey,
66
62
  policy: policy ?? "pull-push",
@@ -70,16 +66,17 @@ export const createJobCacheFromCacheConfigs = (
70
66
  };
71
67
  },
72
68
  );
69
+
73
70
  return [...advancedCaches, ...simpleCaches];
74
71
  };
75
72
 
76
73
  /** shortcut, used in some build types */
77
74
  export const createJobCacheFromConfig = (
78
75
  context: Context,
79
- buildConfig: BuildConfigStandalone | WorkspaceBuildConfig,
76
+ configWithCache: WithCacheConfig,
80
77
  ) => {
81
78
  return createJobCacheFromCacheConfigs(
82
79
  context,
83
- getAllCacheConfigsFromConfig(context, buildConfig),
80
+ getAllCacheConfigsFromConfig(context, configWithCache),
84
81
  );
85
82
  };
@@ -1,24 +1,17 @@
1
1
  import type { Context } from "../../types";
2
2
  import { ensureArray } from "../../utils/index";
3
- import type {
4
- BuildConfigStandalone,
5
- CacheConfig,
6
- WorkspaceBuildConfig,
7
- } from "../types";
3
+ import type { CacheConfig, WithCacheConfig } from "../types";
8
4
  import { transformLegacyJobCache } from "./transformLegacyJobCache";
9
5
 
10
6
  export const getAllCacheConfigsFromConfig = (
11
7
  context: Context,
12
- buildConfig: BuildConfigStandalone | WorkspaceBuildConfig,
8
+ configWithCache: WithCacheConfig,
13
9
  ): CacheConfig[] => {
14
10
  return [
15
- ...("jobCache" in buildConfig
16
- ? transformLegacyJobCache(buildConfig.jobCache)
11
+ ...("jobCache" in configWithCache
12
+ ? transformLegacyJobCache(configWithCache.jobCache)
17
13
  : []),
18
- ...ensureArray(buildConfig.cache).map((c) => ({
19
- ...c,
20
- context,
21
- })),
14
+ ...ensureArray(configWithCache.cache),
22
15
  ...(context.type === "workspace"
23
16
  ? // also add cache configs of the components of that workspace
24
17
  context.components.flatMap<CacheConfig>(
@@ -10,7 +10,7 @@ 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, JobDefintion } from "../types";
13
+ import type { ComponentContext, DockerBuildJobDefinition } from "../types";
14
14
  import type { CatladderJob } from "../types/jobs";
15
15
  import { collapseableSection } from "../utils/gitlab";
16
16
  import { createJobCacheFromCacheConfigs } from "./cache/createJobCache";
@@ -119,10 +119,9 @@ export const getDockerJobBaseProps = (): Pick<
119
119
  };
120
120
  };
121
121
 
122
- export type DockerBuildJobDefinition = JobDefintion;
123
122
  export const createDockerBuildJobBase = (
124
123
  context: ComponentContext,
125
- { script, cache, ...def }: JobDefintion,
124
+ { script, cache, ...def }: DockerBuildJobDefinition,
126
125
  ): CatladderJob => {
127
126
  return merge(
128
127
  {
@@ -6,11 +6,13 @@ import {
6
6
  componentContextIsStandaloneBuild,
7
7
  type ComponentContext,
8
8
  } from "../../types/context";
9
+ import type {
10
+ AppBuildJobDefinition,
11
+ DockerBuildJobDefinition,
12
+ } from "../../types/jobDefinition";
9
13
  import type { CatladderJob } from "../../types/jobs";
10
14
  import { createComponentBuildJobs, createWorkspaceBuildJobs } from "../base";
11
- import type { AppBuildJobDefinition } from "../base/createAppBuildJob";
12
15
  import { createBuildJobDefinition } from "../base/createBuildJobDefinition";
13
- import type { DockerBuildJobDefinition } from "../docker";
14
16
  import { getDockerBuildScriptWithBuiltInDockerFile } from "../docker";
15
17
  import type { BuildConfigDocker } from "../types";
16
18
  import { getNextCache, getNodeCache, getYarnCache } from "./cache";
@@ -53,6 +53,13 @@ export type WithCacheConfig = {
53
53
  cache config. All Paths are relative to the context dir.
54
54
  */
55
55
  cache?: CacheConfig | CacheConfig[];
56
+
57
+ /**
58
+ * customize cache for the job
59
+ *
60
+ * @deprecated use cache
61
+ */
62
+ jobCache?: CatladderJob["cache"];
56
63
  };
57
64
 
58
65
  export type TestJobCustom = {
@@ -1,8 +1,10 @@
1
+ import { createJobCacheFromCacheConfigs } from "../../build/cache/createJobCache";
1
2
  import {
2
3
  getDockerImageVariables,
3
4
  requiresDockerBuild,
4
5
  } from "../../build/docker";
5
6
  import { SBOM_BUILD_JOB_NAME } from "../../build/sbom";
7
+ import type { DeployJobDefinition } from "../../types";
6
8
  import {
7
9
  componentContextHasWorkspaceBuild,
8
10
  type ComponentContext,
@@ -16,16 +18,6 @@ import { DEPLOY_RUNNER_VARIABLES } from "./variables";
16
18
 
17
19
  export const DEPLOY_JOB_NAME = "🚀 Deploy";
18
20
 
19
- export type DeployJobDefinition = Pick<
20
- CatladderJob,
21
- | "script"
22
- | "variables"
23
- | "image"
24
- | "cache"
25
- | "artifacts"
26
- | "services"
27
- | "runnerVariables"
28
- >;
29
21
  export const createDeployJob = (
30
22
  context: ComponentContext,
31
23
  jobDefinition: DeployJobDefinition,
@@ -58,7 +50,9 @@ export const createDeployJob = (
58
50
  name: DEPLOY_JOB_NAME,
59
51
  script: jobDefinition.script,
60
52
  image: jobDefinition.image,
61
- cache: jobDefinition.cache,
53
+ cache: jobDefinition.cache
54
+ ? createJobCacheFromCacheConfigs(context, jobDefinition.cache)
55
+ : undefined,
62
56
  artifacts: jobDefinition.artifacts,
63
57
  services: jobDefinition.services,
64
58
  envMode: "stagePerEnv", // makes it easier to run manual tasks er env
@@ -1,8 +1,13 @@
1
1
  import type { ComponentContext } from "../../types/context";
2
+ import type {
3
+ DeployJobDefinition,
4
+ RollbackJobDefinition,
5
+ StopJobDefinition,
6
+ } from "../../types/jobDefinition";
2
7
  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";
8
+ import { createDeployJob } from "./deploy";
9
+ import { createRollbackJob } from "./rollback";
10
+ import { createStopJob } from "./stop";
6
11
 
7
12
  export const createDeployementJobs = (
8
13
  context: ComponentContext,
@@ -1,13 +1,10 @@
1
1
  import type { ComponentContext } from "../../types/context";
2
+ import type { RollbackJobDefinition } from "../../types/jobDefinition";
2
3
  import type { CatladderJob } from "../../types/jobs";
3
4
  import { DEPLOY_RUNNER_VARIABLES } from "./variables";
4
5
 
5
6
  export const ROLLBACK_JOB_NAME = "↩️ Rollback ⚠️";
6
7
 
7
- export type RollbackJobDefinition = Pick<
8
- CatladderJob,
9
- "script" | "variables" | "runnerVariables" | "image"
10
- >;
11
8
  export const createRollbackJob = (
12
9
  context: ComponentContext,
13
10
  jobDefinition: RollbackJobDefinition,
@@ -1,13 +1,10 @@
1
1
  import type { ComponentContext } from "../../types/context";
2
+ import type { StopJobDefinition } from "../../types/jobDefinition";
2
3
  import type { CatladderJob } from "../../types/jobs";
3
4
 
4
5
  import { DEPLOY_RUNNER_VARIABLES } from "./variables";
5
6
  export const STOP_JOB_NAME = "🛑 Stop ⚠️";
6
7
 
7
- export type StopJobDefinition = Pick<
8
- CatladderJob,
9
- "script" | "variables" | "image" | "runnerVariables"
10
- >;
11
8
  export const createStopJob = (
12
9
  context: ComponentContext,
13
10
  jobDefinition: StopJobDefinition,
@@ -1,3 +1,4 @@
1
+ import { getAllCacheConfigsFromConfig } from "../../build/cache/getAllCacheConfigsFromConfig";
1
2
  import { getYarnInstall } from "../../build/node/yarn";
2
3
  import { getRunnerImage } from "../../runner";
3
4
  import type { ComponentContext } from "../../types/context";
@@ -22,10 +23,11 @@ export const createCustomDeployJobs = (
22
23
  const yarnInstall = getYarnInstall(context, {
23
24
  noCustomPostInstall: true,
24
25
  });
25
- return createDeployementJobs(context, {
26
+
27
+ const result = createDeployementJobs(context, {
26
28
  deploy: {
27
29
  image: deployConfig.jobImage ?? getRunnerImage("jobs-default"),
28
- cache: deployConfig.jobCache ?? [],
30
+ cache: getAllCacheConfigsFromConfig(context, deployConfig),
29
31
  script: [
30
32
  `cd ${context.build.dir}`,
31
33
  ...(deployConfig.requiresYarnInstall ? yarnInstall : []),
@@ -45,4 +47,5 @@ export const createCustomDeployJobs = (
45
47
  }
46
48
  : undefined,
47
49
  });
50
+ return result;
48
51
  };
@@ -1,5 +1,5 @@
1
+ import type { WithCacheConfig } from "../../build";
1
2
  import type { GitlabJobImage } from "../../types";
2
- import type { CatladderJob } from "../../types/jobs";
3
3
  import type { DeployConfigBase } from "./base";
4
4
 
5
5
  export type DeployConfigCustom = {
@@ -28,9 +28,5 @@ export type DeployConfigCustom = {
28
28
  * image to use
29
29
  */
30
30
  jobImage?: GitlabJobImage;
31
-
32
- /**
33
- * customize cache for the job
34
- */
35
- jobCache?: CatladderJob["cache"];
36
- } & DeployConfigBase;
31
+ } & DeployConfigBase &
32
+ WithCacheConfig;
@@ -1,9 +1,34 @@
1
1
  import type { CacheConfig } from "../build";
2
- import { CacheConfigAdvanced, CacheConfigSimple } from "../build";
3
2
  import type { CatladderJob } from "./jobs";
4
3
 
5
- export type JobDefintion = Partial<
4
+ // new intermediate types. Currently not widely used, but we will built a bit more abstraction on top of this
5
+
6
+ export type AppBuildJobDefinition = Partial<
6
7
  Omit<CatladderJob, "artifacts" | "cache">
7
8
  > & {
8
9
  cache?: CacheConfig[];
9
10
  };
11
+
12
+ export type DockerBuildJobDefinition = AppBuildJobDefinition; // currently the same
13
+
14
+ export type DeployJobDefinition = Pick<
15
+ CatladderJob,
16
+ | "script"
17
+ | "variables"
18
+ | "image"
19
+ | "artifacts"
20
+ | "services"
21
+ | "runnerVariables"
22
+ > & {
23
+ cache?: CacheConfig[];
24
+ };
25
+
26
+ export type StopJobDefinition = Pick<
27
+ CatladderJob,
28
+ "script" | "variables" | "image" | "runnerVariables"
29
+ >;
30
+
31
+ export type RollbackJobDefinition = Pick<
32
+ CatladderJob,
33
+ "script" | "variables" | "runnerVariables" | "image"
34
+ >;