@catladder/pipeline 1.149.4 → 1.150.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.
- package/dist/bundles/catladder-gitlab/index.js +1 -1
- package/dist/constants.js +1 -1
- package/dist/context/createComponentContext.js +1 -1
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +1 -0
- package/dist/deploy/types/googleCloudRun.d.ts +8 -0
- package/dist/pipeline/createAllJobs.js +41 -74
- package/dist/pipeline/packageManager.d.ts +2 -2
- package/dist/pipeline/packageManager.js +3 -3
- package/dist/pipeline/yarn/yarnUtils.d.ts +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/context.d.ts +8 -7
- package/examples/__snapshots__/cloud-run-service-increase-timout.ts.snap +1950 -0
- package/examples/cloud-run-service-increase-timout.ts +27 -0
- package/package.json +1 -1
- package/src/context/createComponentContext.ts +2 -2
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +1 -0
- package/src/deploy/types/googleCloudRun.ts +9 -0
- package/src/pipeline/createAllJobs.ts +37 -43
- package/src/pipeline/packageManager.ts +3 -3
- package/src/pipeline/yarn/yarnUtils.ts +2 -2
- package/src/types/context.ts +8 -7
|
@@ -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
|
@@ -10,7 +10,7 @@ import type { PartialDeep } from "../types/utils";
|
|
|
10
10
|
import { mergeWithMergingArrays } from "../utils";
|
|
11
11
|
import { getEnvironment } from "./getEnvironment";
|
|
12
12
|
import { getEnvironmentContext } from "./getEnvironmentContext";
|
|
13
|
-
import {
|
|
13
|
+
import { getPackageManagerInfoForComponent } from "../pipeline/packageManager";
|
|
14
14
|
|
|
15
15
|
export type CreateComponentContextContext = {
|
|
16
16
|
config: Config;
|
|
@@ -29,7 +29,7 @@ export const createComponentContext = async (
|
|
|
29
29
|
);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const packageManagerInfo = await
|
|
32
|
+
const packageManagerInfo = await getPackageManagerInfoForComponent(
|
|
33
33
|
ctx.config,
|
|
34
34
|
ctx.componentName,
|
|
35
35
|
);
|
|
@@ -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.
|
|
@@ -21,41 +21,36 @@ export type AllJobsContext = {
|
|
|
21
21
|
pipelineType: PipelineType;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
type AllComponentContext = {
|
|
25
|
-
[componentName: string]: {
|
|
26
|
-
[env: string]: ComponentContext;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
24
|
const createAllComponentContext = async ({
|
|
31
25
|
config,
|
|
32
26
|
trigger,
|
|
33
27
|
pipelineType,
|
|
34
|
-
}: AllJobsContext): Promise<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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,
|
|
40
41
|
componentName,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
config,
|
|
46
|
-
componentName,
|
|
47
|
-
env,
|
|
48
|
-
trigger,
|
|
49
|
-
pipelineType,
|
|
50
|
-
});
|
|
42
|
+
env,
|
|
43
|
+
trigger,
|
|
44
|
+
pipelineType,
|
|
45
|
+
});
|
|
51
46
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
})
|
|
58
|
-
),
|
|
47
|
+
return {
|
|
48
|
+
env,
|
|
49
|
+
componentName,
|
|
50
|
+
context,
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
}),
|
|
59
54
|
);
|
|
60
55
|
};
|
|
61
56
|
|
|
@@ -70,18 +65,17 @@ export const createAllJobs = async ({
|
|
|
70
65
|
pipelineType,
|
|
71
66
|
});
|
|
72
67
|
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
componentName
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
);
|
|
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,
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return acc;
|
|
80
|
+
}, {} as AllCatladderJobs);
|
|
87
81
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { existsSync } from "fs";
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import { pathEqual } from "path-equal";
|
|
4
|
-
import type { Config,
|
|
4
|
+
import type { Config, PackageManagerInfoComponent } from "../types";
|
|
5
5
|
import {
|
|
6
6
|
getWorkspaces,
|
|
7
7
|
getYarnVersion,
|
|
8
8
|
getWorkspaceDependencies,
|
|
9
9
|
} from "./yarn/yarnUtils";
|
|
10
10
|
|
|
11
|
-
export const
|
|
11
|
+
export const getPackageManagerInfoForComponent = async (
|
|
12
12
|
config: Config,
|
|
13
13
|
componentName: string,
|
|
14
|
-
): Promise<
|
|
14
|
+
): Promise<PackageManagerInfoComponent> => {
|
|
15
15
|
// currently only supports yarn
|
|
16
16
|
const version = await getYarnVersion();
|
|
17
17
|
if (!version) throw new Error("could not get yarn version");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { exec } from "child-process-promise";
|
|
2
2
|
import memoizee from "memoizee";
|
|
3
|
-
import type {
|
|
3
|
+
import type { PackageManagerInfoComponent, YarnWorkspace } from "../../types";
|
|
4
4
|
|
|
5
5
|
const execOrFail = async (cmd: string, onFail: string): Promise<string> => {
|
|
6
6
|
try {
|
|
@@ -18,7 +18,7 @@ export const getYarnVersion = memoizee(
|
|
|
18
18
|
);
|
|
19
19
|
// export for mocking
|
|
20
20
|
export const getWorkspaces = memoizee(
|
|
21
|
-
async (isClassic: boolean): Promise<
|
|
21
|
+
async (isClassic: boolean): Promise<Array<YarnWorkspace>> => {
|
|
22
22
|
return isClassic
|
|
23
23
|
? Object.values(
|
|
24
24
|
JSON.parse(
|
package/src/types/context.ts
CHANGED
|
@@ -66,7 +66,7 @@ export type YarnWorkspace = {
|
|
|
66
66
|
workspaceDependencies: string[];
|
|
67
67
|
mismatchedWorkspaceDependencies: string[];
|
|
68
68
|
};
|
|
69
|
-
export type
|
|
69
|
+
export type YarnPackageManagerInfoComponent = {
|
|
70
70
|
type: "yarn";
|
|
71
71
|
version: string;
|
|
72
72
|
workspaces: YarnWorkspace[];
|
|
@@ -77,20 +77,21 @@ export type YarnPackageManagerInfo = {
|
|
|
77
77
|
currentWorkspaceDependencies: string[];
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
export type
|
|
80
|
+
export type PackageManagerInfoComponent = YarnPackageManagerInfoComponent;
|
|
81
81
|
|
|
82
82
|
export type ContextBeforeConfig = {
|
|
83
83
|
componentName: string;
|
|
84
84
|
fullConfig: Config;
|
|
85
|
-
packageManagerInfo?:
|
|
85
|
+
packageManagerInfo?: PackageManagerInfoComponent;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
export type
|
|
88
|
+
export type BuildContextComponent = {
|
|
89
89
|
dir: string;
|
|
90
|
-
packageManagerInfo:
|
|
90
|
+
packageManagerInfo: PackageManagerInfoComponent;
|
|
91
91
|
config: BuildConfig;
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
+
export type BuildContext = BuildContextComponent;
|
|
94
95
|
export type DeployContext = {
|
|
95
96
|
config: DeployConfig;
|
|
96
97
|
};
|
|
@@ -104,7 +105,7 @@ export type ComponentContext = {
|
|
|
104
105
|
*
|
|
105
106
|
*/
|
|
106
107
|
componentConfig: ComponentConfig;
|
|
107
|
-
build:
|
|
108
|
+
build: BuildContextComponent;
|
|
108
109
|
deploy?: DeployContext | null;
|
|
109
110
|
fullConfig: Config;
|
|
110
111
|
environment: Environment;
|
|
@@ -114,7 +115,7 @@ export type ComponentContext = {
|
|
|
114
115
|
/**
|
|
115
116
|
* @deprecated use buildContext.packageManagerInfo instead
|
|
116
117
|
*/
|
|
117
|
-
packageManagerInfo:
|
|
118
|
+
packageManagerInfo: PackageManagerInfoComponent;
|
|
118
119
|
|
|
119
120
|
customJobs?: CatladderJob[];
|
|
120
121
|
};
|