@catladder/pipeline 1.149.3 → 1.150.0

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.
@@ -0,0 +1,27 @@
1
+ import type { Config } from "../src";
2
+ import { createAllPipelines } from "./__utils__/helpers";
3
+ const config: Config = {
4
+ appName: "test-app",
5
+ customerName: "pan",
6
+ components: {
7
+ api: {
8
+ dir: "api",
9
+ build: {
10
+ type: "node",
11
+ },
12
+ deploy: {
13
+ type: "google-cloudrun",
14
+ projectId: "google-project-id",
15
+ region: "europe-west6",
16
+
17
+ service: {
18
+ timeout: "10m20s",
19
+ },
20
+ },
21
+ },
22
+ },
23
+ };
24
+
25
+ it("matches snapshot", async () => {
26
+ expect(await createAllPipelines(config)).toMatchSnapshot();
27
+ });
package/package.json CHANGED
@@ -52,7 +52,7 @@
52
52
  }
53
53
  ],
54
54
  "license": "MIT",
55
- "version": "1.149.3",
55
+ "version": "1.150.0",
56
56
  "scripts": {
57
57
  "build:tsc": "yarn tsc",
58
58
  "build": "yarn build:compile && yarn build:inline-variables && yarn build:bundle",
@@ -49,6 +49,7 @@ export const getServiceDeployScript = (
49
49
  "cpu-throttling": customConfig?.noCpuThrottling !== true,
50
50
  cpu: customConfig?.cpu,
51
51
  memory: customConfig?.memory,
52
+ timeout: customConfig?.timeout,
52
53
  "allow-unauthenticated": customConfig?.allowUnauthenticated ?? true,
53
54
  ingress: customConfig?.ingress ?? "all",
54
55
  "cpu-boost": true,
@@ -139,6 +139,15 @@ export type DeployConfigCloudRunService = {
139
139
  */
140
140
  memory?: Memory;
141
141
 
142
+ /**
143
+ * timeout of the service, defaults to 5 minutes.
144
+ *
145
+ * you can specify something like 10m30s. if its just a number, it will be interpreted as seconds
146
+ *
147
+ * max supported is 60min
148
+ */
149
+ timeout?: string;
150
+
142
151
  /**
143
152
  *
144
153
  * set the execution environment.
@@ -1,11 +1,13 @@
1
1
  import { getAllEnvsByTrigger } from "../config";
2
+ import { createComponentContext } from "../context";
2
3
  import type {
3
4
  CatladderJobWithContext,
5
+ ComponentContext,
4
6
  Config,
5
7
  PipelineTrigger,
6
8
  PipelineType,
7
9
  } from "../types";
8
- import { createJobsForComponent } from "./createJobsForComponent";
10
+ import { createJobsForComponentContext } from "./createJobsForComponent";
9
11
 
10
12
  export type AllCatladderJobs = {
11
13
  [componentName: string]: {
@@ -19,34 +21,61 @@ export type AllJobsContext = {
19
21
  pipelineType: PipelineType;
20
22
  };
21
23
 
24
+ const createAllComponentContext = async ({
25
+ config,
26
+ trigger,
27
+ pipelineType,
28
+ }: AllJobsContext): Promise<
29
+ Array<{
30
+ env: string;
31
+ componentName: string;
32
+ context: ComponentContext;
33
+ }>
34
+ > => {
35
+ return await Promise.all(
36
+ Object.keys(config.components).flatMap((componentName) => {
37
+ const envs = getAllEnvsByTrigger(config, componentName, trigger);
38
+ return envs.map(async (env) => {
39
+ const context = await createComponentContext({
40
+ config,
41
+ componentName,
42
+ env,
43
+ trigger,
44
+ pipelineType,
45
+ });
46
+
47
+ return {
48
+ env,
49
+ componentName,
50
+ context,
51
+ };
52
+ });
53
+ }),
54
+ );
55
+ };
56
+
22
57
  export const createAllJobs = async ({
23
58
  config,
24
59
  trigger,
25
60
  pipelineType,
26
61
  }: AllJobsContext): Promise<AllCatladderJobs> => {
27
- return Object.fromEntries(
28
- await Promise.all(
29
- Object.keys(config.components).map(async (componentName) => {
30
- const envs = getAllEnvsByTrigger(config, componentName, trigger);
31
- return [
32
- componentName,
33
- Object.fromEntries(
34
- await Promise.all(
35
- envs.map(async (env) => [
36
- env,
62
+ const allComponentContext = await createAllComponentContext({
63
+ config,
64
+ trigger,
65
+ pipelineType,
66
+ });
37
67
 
38
- await createJobsForComponent({
39
- config,
40
- componentName,
41
- env,
42
- trigger,
43
- pipelineType,
44
- }),
45
- ]),
46
- ),
47
- ),
48
- ];
68
+ return allComponentContext.reduce((acc, { componentName, env, context }) => {
69
+ if (!acc[componentName]) {
70
+ acc[componentName] = {};
71
+ }
72
+ acc[componentName][env] = createJobsForComponentContext(context).map(
73
+ (job) => ({
74
+ ...job,
75
+ context,
49
76
  }),
50
- ),
51
- );
77
+ );
78
+
79
+ return acc;
80
+ }, {} as AllCatladderJobs);
52
81
  };
@@ -1,12 +1,6 @@
1
1
  import { BUILD_TYPES } from "../build";
2
- import type { CreateComponentContextContext } from "../context";
3
- import { createComponentContext } from "../context";
4
2
  import { DEPLOY_TYPES } from "../deploy";
5
- import type {
6
- CatladderJobWithContext,
7
- ComponentContext,
8
- Context,
9
- } from "../types/context";
3
+ import type { ComponentContext } from "../types/context";
10
4
  import type { CatladderJob } from "../types/jobs";
11
5
 
12
6
  const injectDefaultVarsInCustomJobs = (
@@ -27,7 +21,9 @@ const getCustomJobs = (context: ComponentContext) => {
27
21
  const rawJobs = context.customJobs;
28
22
  return injectDefaultVarsInCustomJobs(context, rawJobs);
29
23
  };
30
- const createRawJobs = (context: Context): CatladderJob[] => {
24
+ export const createJobsForComponentContext = (
25
+ context: ComponentContext,
26
+ ): CatladderJob[] => {
31
27
  const buildJobs = BUILD_TYPES[context.build.config.type].jobs(context);
32
28
  const deployJobs = context.deploy?.config
33
29
  ? DEPLOY_TYPES[context.deploy?.config.type].jobs(context)
@@ -36,10 +32,3 @@ const createRawJobs = (context: Context): CatladderJob[] => {
36
32
  const customJobs = getCustomJobs(context);
37
33
  return [...buildJobs, ...deployJobs, ...customJobs];
38
34
  };
39
-
40
- export const createJobsForComponent = async (
41
- contextContext: CreateComponentContextContext,
42
- ): Promise<Array<CatladderJobWithContext>> => {
43
- const context = await createComponentContext(contextContext);
44
- return createRawJobs(context).map((job) => ({ ...job, context }));
45
- };