@catladder/pipeline 3.6.0 → 3.8.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.
- package/dist/build/artifacts/createBuildJobArtifact.js +1 -1
- package/dist/build/base/index.d.ts +2 -3
- package/dist/build/cache/getAllCacheConfigsFromConfig.js +2 -2
- package/dist/build/custom/buildJob.d.ts +2 -2
- package/dist/build/custom/index.d.ts +2 -2
- package/dist/build/custom/testJob.d.ts +2 -2
- package/dist/build/docker.d.ts +4 -4
- package/dist/build/index.d.ts +2 -2
- package/dist/build/node/buildJob.d.ts +5 -3
- package/dist/build/node/index.d.ts +4 -4
- package/dist/build/node/meteor.d.ts +2 -2
- package/dist/build/node/yarn.d.ts +1 -1
- package/dist/build/node/yarn.js +1 -1
- package/dist/build/rails/build.d.ts +2 -2
- package/dist/build/rails/index.d.ts +2 -2
- package/dist/build/sbom.d.ts +2 -2
- package/dist/constants.js +1 -1
- package/dist/context/createComponentContext.js +11 -4
- package/dist/context/getLabels.js +1 -1
- package/dist/deploy/cloudRun/createJobs/cloudRunJobs.js +2 -2
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +16 -9
- package/dist/deploy/cloudRun/createJobs/execute/onDeploy.d.ts +2 -3
- package/dist/deploy/cloudRun/createJobs/execute/onDeploy.js +4 -9
- package/dist/deploy/cloudRun/createJobs/healthCheck.d.ts +5 -0
- package/dist/deploy/cloudRun/createJobs/healthCheck.js +82 -0
- package/dist/deploy/cloudRun/utils/getJobOrServiceArgs.d.ts +2 -0
- package/dist/deploy/cloudRun/utils/getJobOrServiceArgs.js +12 -0
- package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
- package/dist/deploy/kubernetes/kubeValues.js +1 -1
- package/dist/deploy/sbom.js +1 -1
- package/dist/deploy/types/googleCloudRun.d.ts +80 -0
- package/dist/deploy/types/googleCloudRun.js +25 -0
- package/dist/pipeline/createJobsForComponent.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/context.d.ts +6 -1
- package/examples/__snapshots__/cloud-run-health-check-defaults.test.ts.snap +1382 -0
- package/examples/__snapshots__/cloud-run-health-check-only-startup.test.ts.snap +1382 -0
- package/examples/__snapshots__/cloud-run-health-check.test.ts.snap +1382 -0
- package/examples/__snapshots__/cloud-run-llama.test.ts.snap +624 -0
- package/examples/cloud-run-health-check-defaults.test.ts +11 -0
- package/examples/cloud-run-health-check-defaults.ts +28 -0
- package/examples/cloud-run-health-check-only-startup.test.ts +11 -0
- package/examples/cloud-run-health-check-only-startup.ts +38 -0
- package/examples/cloud-run-health-check.test.ts +11 -0
- package/examples/cloud-run-health-check.ts +45 -0
- package/examples/cloud-run-llama.test.ts +11 -0
- package/examples/cloud-run-llama.ts +40 -0
- package/package.json +1 -1
- package/src/build/artifacts/createBuildJobArtifact.ts +3 -1
- package/src/build/base/index.ts +5 -2
- package/src/build/cache/getAllCacheConfigsFromConfig.ts +7 -6
- package/src/build/custom/buildJob.ts +2 -2
- package/src/build/custom/index.ts +4 -2
- package/src/build/custom/testJob.ts +2 -2
- package/src/build/docker.ts +8 -4
- package/src/build/index.ts +5 -2
- package/src/build/node/buildJob.ts +5 -2
- package/src/build/node/index.ts +9 -4
- package/src/build/node/meteor.ts +5 -2
- package/src/build/node/yarn.ts +4 -2
- package/src/build/rails/build.ts +3 -7
- package/src/build/rails/index.ts +4 -2
- package/src/build/sbom.ts +4 -2
- package/src/context/createComponentContext.ts +22 -9
- package/src/context/getLabels.ts +4 -1
- package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +2 -2
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +13 -1
- package/src/deploy/cloudRun/createJobs/execute/onDeploy.ts +3 -13
- package/src/deploy/cloudRun/createJobs/healthCheck.ts +64 -0
- package/src/deploy/cloudRun/utils/getJobOrServiceArgs.ts +18 -0
- package/src/deploy/kubernetes/kubeValues.ts +13 -4
- package/src/deploy/sbom.ts +4 -3
- package/src/deploy/types/googleCloudRun.ts +112 -0
- package/src/pipeline/createJobsForComponent.ts +10 -2
- package/src/types/config.ts +1 -1
- package/src/types/context.ts +10 -1
|
@@ -3,8 +3,10 @@ import type { ComponentContext } from "../../../../types/context";
|
|
|
3
3
|
import type {
|
|
4
4
|
DeployConfigCloudRunExecuteOnDeploy,
|
|
5
5
|
DeployConfigCloudRunJob,
|
|
6
|
+
DeployConfigCloudRunService,
|
|
6
7
|
} from "../../../types/googleCloudRun";
|
|
7
8
|
import { createArgsString } from "../../utils/createArgsString";
|
|
9
|
+
import { getCloudRunServiceOrJobArgsArg } from "../../utils/getJobOrServiceArgs";
|
|
8
10
|
import { getFullJobName } from "../../utils/jobName";
|
|
9
11
|
import { getCloudRunJobsWithNames } from "../cloudRunJobs";
|
|
10
12
|
import {
|
|
@@ -93,20 +95,8 @@ const getJobRunScriptForExecute = (
|
|
|
93
95
|
const argString = createArgsString({
|
|
94
96
|
...commonArgs,
|
|
95
97
|
wait: waitForCompletion === true ? true : undefined,
|
|
96
|
-
args:
|
|
98
|
+
args: getCloudRunServiceOrJobArgsArg(config.args),
|
|
97
99
|
});
|
|
98
100
|
const fullJobName = getFullJobName(context, jobName);
|
|
99
101
|
return `${gcloudRunCmd()} jobs execute ${fullJobName.toString()} ${argString}`;
|
|
100
102
|
};
|
|
101
|
-
|
|
102
|
-
export const getCloudRunJobArgsArg = (
|
|
103
|
-
args:
|
|
104
|
-
| DeployConfigCloudRunExecuteOnDeploy["args"]
|
|
105
|
-
| DeployConfigCloudRunJob["args"],
|
|
106
|
-
) => {
|
|
107
|
-
return args !== undefined
|
|
108
|
-
? args.length > 0
|
|
109
|
-
? args?.map((arg) => `"${arg}"`).join(",")
|
|
110
|
-
: ""
|
|
111
|
-
: undefined;
|
|
112
|
-
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { DeployConfigCloudRunProbeShared } from "../../types";
|
|
2
|
+
import {
|
|
3
|
+
defaultLivenessProbe,
|
|
4
|
+
defaultStartupProbe,
|
|
5
|
+
type DeployConfigCloudRunProbe,
|
|
6
|
+
type DeployConfigCloudRunService,
|
|
7
|
+
} from "../../types";
|
|
8
|
+
|
|
9
|
+
const PORT = 8080;
|
|
10
|
+
|
|
11
|
+
export function healthCheckCliArgs(
|
|
12
|
+
healthCheck: DeployConfigCloudRunService["healthCheck"],
|
|
13
|
+
) {
|
|
14
|
+
const shouldNotSetHealthCheck = healthCheck === undefined;
|
|
15
|
+
if (shouldNotSetHealthCheck) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const shouldUseDefaultProbe = healthCheck === true;
|
|
20
|
+
|
|
21
|
+
if (shouldUseDefaultProbe) {
|
|
22
|
+
return {
|
|
23
|
+
"startup-probe": toArgValue(probeToKeyValuePairs(defaultStartupProbe)),
|
|
24
|
+
"liveness-probe": toArgValue(probeToKeyValuePairs(defaultLivenessProbe)),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
"startup-probe": toArgValue(probeToKeyValuePairs(healthCheck.startupProbe)),
|
|
30
|
+
"liveness-probe": healthCheck.livenessProbe
|
|
31
|
+
? toArgValue(probeToKeyValuePairs(healthCheck.livenessProbe))
|
|
32
|
+
: "", // NOTE: empty string ("") removes liveness probe
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function probeToKeyValuePairs(
|
|
37
|
+
probe: DeployConfigCloudRunProbe,
|
|
38
|
+
): [string, unknown][] {
|
|
39
|
+
const sharedArgs = Object.entries({
|
|
40
|
+
initialDelaySeconds: probe.initialDelaySeconds,
|
|
41
|
+
timeoutSeconds: probe.timeoutSeconds,
|
|
42
|
+
periodSeconds: probe.periodSeconds,
|
|
43
|
+
failureThreshold: probe.failureThreshold,
|
|
44
|
+
} satisfies DeployConfigCloudRunProbeShared);
|
|
45
|
+
|
|
46
|
+
switch (probe.type) {
|
|
47
|
+
case "tcp":
|
|
48
|
+
return [...sharedArgs, ["tcpSocket.port", PORT]];
|
|
49
|
+
case "http1":
|
|
50
|
+
return [
|
|
51
|
+
...sharedArgs,
|
|
52
|
+
["httpGet.port", PORT],
|
|
53
|
+
["httpGet.path", probe.path],
|
|
54
|
+
// NOTE: headers are not supported by "gcloud beta" at the moment
|
|
55
|
+
];
|
|
56
|
+
default:
|
|
57
|
+
probe satisfies never;
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function toArgValue(keyValues: [string, unknown][]) {
|
|
63
|
+
return keyValues.map(([key, value]) => `${key}=${value}`).join(",");
|
|
64
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DeployConfigCloudRunExecuteOnDeploy,
|
|
3
|
+
DeployConfigCloudRunJob,
|
|
4
|
+
DeployConfigCloudRunService,
|
|
5
|
+
} from "../../types";
|
|
6
|
+
|
|
7
|
+
export const getCloudRunServiceOrJobArgsArg = (
|
|
8
|
+
args:
|
|
9
|
+
| DeployConfigCloudRunExecuteOnDeploy["args"]
|
|
10
|
+
| DeployConfigCloudRunJob["args"]
|
|
11
|
+
| DeployConfigCloudRunService["args"],
|
|
12
|
+
) => {
|
|
13
|
+
return args !== undefined
|
|
14
|
+
? args.length > 0
|
|
15
|
+
? args?.map((arg) => `"${arg}"`).join(",")
|
|
16
|
+
: ""
|
|
17
|
+
: undefined;
|
|
18
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { merge } from "lodash";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
BuildContextComponent,
|
|
5
|
+
ComponentContext,
|
|
6
|
+
} from "../../types/context";
|
|
4
7
|
import { mergeWithMergingArrays } from "../../utils";
|
|
5
8
|
import type { DeployConfigKubernetesValues } from "../types";
|
|
6
9
|
import { isOfDeployType } from "../types";
|
|
@@ -13,7 +16,7 @@ import { createKubeEnv } from "./kubeEnv";
|
|
|
13
16
|
import { createMongodbBaseConfig } from "./mongodb";
|
|
14
17
|
|
|
15
18
|
const createAppConfig = (
|
|
16
|
-
context: ComponentContext
|
|
19
|
+
context: ComponentContext<BuildContextComponent>,
|
|
17
20
|
application: DeployConfigKubernetesValues["application"],
|
|
18
21
|
): DeployConfigKubernetesValues["application"] => {
|
|
19
22
|
if (application === false) {
|
|
@@ -27,7 +30,11 @@ const createAppConfig = (
|
|
|
27
30
|
return mergeWithMergingArrays(
|
|
28
31
|
{
|
|
29
32
|
host: context.environment.envVars.HOSTNAME,
|
|
30
|
-
command:
|
|
33
|
+
command:
|
|
34
|
+
command ??
|
|
35
|
+
(context.build.type !== "disabled"
|
|
36
|
+
? context.build.config.startCommand
|
|
37
|
+
: undefined),
|
|
31
38
|
livenessProbe: {
|
|
32
39
|
httpGet: {
|
|
33
40
|
path: healthRoute ?? "__health",
|
|
@@ -55,7 +62,9 @@ const removeFalsy = <T>(record?: Record<string, false | T>) => {
|
|
|
55
62
|
);
|
|
56
63
|
};
|
|
57
64
|
|
|
58
|
-
export const createKubeValues = (
|
|
65
|
+
export const createKubeValues = (
|
|
66
|
+
context: ComponentContext<BuildContextComponent>,
|
|
67
|
+
) => {
|
|
59
68
|
const deployConfig = context.deploy?.config;
|
|
60
69
|
if (!deployConfig) {
|
|
61
70
|
return [];
|
package/src/deploy/sbom.ts
CHANGED
|
@@ -6,9 +6,10 @@ import {
|
|
|
6
6
|
} from "../types/context";
|
|
7
7
|
|
|
8
8
|
export const sbomDeactivated = (context: ComponentContext) =>
|
|
9
|
-
|
|
10
|
-
context
|
|
11
|
-
|
|
9
|
+
context.build.type === "disabled" ||
|
|
10
|
+
(componentContextIsStandaloneBuild(context) &&
|
|
11
|
+
context.build.config.type === "custom" &&
|
|
12
|
+
context.build.config.sbom === false);
|
|
12
13
|
|
|
13
14
|
export const getDependencyTrackUploadScript = (
|
|
14
15
|
context: ComponentContext,
|
|
@@ -180,9 +180,121 @@ export type DeployConfigCloudRunService = {
|
|
|
180
180
|
* gpu type to use. Refer to https://cloud.google.com/run/docs/configuring/services/gpu#gcloud for defaults
|
|
181
181
|
*/
|
|
182
182
|
gpuType?: string;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* the image to use. Defaults to the image from the build.
|
|
186
|
+
*
|
|
187
|
+
* If you specify an image, you usually want to disable the build by setting build: false
|
|
188
|
+
*/
|
|
189
|
+
image?: string;
|
|
190
|
+
/**
|
|
191
|
+
* args to pass to the command
|
|
192
|
+
*/
|
|
193
|
+
args?: string[];
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Configuration of the health check.
|
|
197
|
+
*
|
|
198
|
+
* When set to `true`, startup and liveness probes will be
|
|
199
|
+
* configured to `defaultStartupProbe` and `defaultLivenessProbe`.
|
|
200
|
+
*
|
|
201
|
+
* When not set, default Cloud Run's health check
|
|
202
|
+
* configuration is used (startup TCP probe and no liveness probe).
|
|
203
|
+
*/
|
|
204
|
+
healthCheck?:
|
|
205
|
+
| true
|
|
206
|
+
| {
|
|
207
|
+
/**
|
|
208
|
+
* Startup probe configuration.
|
|
209
|
+
*/
|
|
210
|
+
startupProbe: DeployConfigCloudRunProbe;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Liveness probe configuration.
|
|
214
|
+
* `false` disables the liveness probe.
|
|
215
|
+
*/
|
|
216
|
+
livenessProbe: false | DeployConfigCloudRunProbe;
|
|
217
|
+
};
|
|
183
218
|
} & DeployConfigCloudRunWithVolumes &
|
|
184
219
|
DeployConfigCloudRunNetworkConfig;
|
|
185
220
|
|
|
221
|
+
export const defaultStartupProbe: DeployConfigCloudRunProbe = {
|
|
222
|
+
type: "http1",
|
|
223
|
+
path: "/__health",
|
|
224
|
+
|
|
225
|
+
initialDelaySeconds: 5,
|
|
226
|
+
timeoutSeconds: 1,
|
|
227
|
+
periodSeconds: 30,
|
|
228
|
+
failureThreshold: 3,
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export const defaultLivenessProbe: DeployConfigCloudRunProbe = {
|
|
232
|
+
...defaultStartupProbe,
|
|
233
|
+
|
|
234
|
+
initialDelaySeconds: 0,
|
|
235
|
+
timeoutSeconds: 10,
|
|
236
|
+
periodSeconds: 30,
|
|
237
|
+
failureThreshold: 3,
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
export type DeployConfigCloudRunProbe =
|
|
241
|
+
| DeployConfigCloudRunHttp1Probe
|
|
242
|
+
| DeployConfigCloudRunTcpProbe;
|
|
243
|
+
|
|
244
|
+
export type DeployConfigCloudRunProbeShared = {
|
|
245
|
+
/**
|
|
246
|
+
* The period in seconds at which to perform the probe.
|
|
247
|
+
* For example 2 to perform the probe every 2 seconds.
|
|
248
|
+
* Specify a value **from 1 second to 240** seconds.
|
|
249
|
+
*/
|
|
250
|
+
periodSeconds: number;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The number of seconds to wait after the container has started before performing the first probe.
|
|
254
|
+
* Specify a value **from 0 seconds to 240** seconds.
|
|
255
|
+
*/
|
|
256
|
+
initialDelaySeconds: number;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* The number of seconds to wait until the probe times out.
|
|
260
|
+
* This value cannot exceed the value specified for `period`.
|
|
261
|
+
* Specify a value **from 1 to 240**.
|
|
262
|
+
*/
|
|
263
|
+
timeoutSeconds: number;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* The number of times to retry the probe before shutting down the container.
|
|
267
|
+
*/
|
|
268
|
+
failureThreshold: number;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export type DeployConfigCloudRunTcpProbe = DeployConfigCloudRunProbeShared & {
|
|
272
|
+
/**
|
|
273
|
+
* Cloud Run makes a TCP connection to open the TCP Socket on the specified port.
|
|
274
|
+
* If Cloud Run is unable to establish a connection, it indicates a failure.
|
|
275
|
+
*/
|
|
276
|
+
type: "tcp";
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export type DeployConfigCloudRunHttp1Probe = DeployConfigCloudRunProbeShared & {
|
|
280
|
+
/**
|
|
281
|
+
* **This will NOT work with http2 enabled services**
|
|
282
|
+
*
|
|
283
|
+
* Cloud Run makes an HTTP GET request to the service health check endpoint (for example, /ready).
|
|
284
|
+
* Any response between 200 and 400 is a success, everything else indicates failure.
|
|
285
|
+
*
|
|
286
|
+
* If a startup probe does not succeed within the specified time (failureThreshold * period), which cannot exceed 240 seconds, the container is shut down.
|
|
287
|
+
*
|
|
288
|
+
* If the HTTP startup probe succeeds within the specified time, and you have enabled liveness probe, the HTTP liveness probe is started.
|
|
289
|
+
*/
|
|
290
|
+
type: "http1";
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* the route path to check for health status of the service starting with a `/`.
|
|
294
|
+
*/
|
|
295
|
+
path: string;
|
|
296
|
+
};
|
|
297
|
+
|
|
186
298
|
export type DeployConfigCloudRunNetworkConfig = {
|
|
187
299
|
/* the vpc network, see https://cloud.google.com/sdk/gcloud/reference/run/deploy#--network */
|
|
188
300
|
network?: string;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { BUILD_TYPES } from "../build";
|
|
2
2
|
import { DEPLOY_TYPES } from "../deploy";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
ComponentContext,
|
|
5
|
+
ComponentContextWithBuild,
|
|
6
|
+
} from "../types/context";
|
|
4
7
|
import type { CatladderJob } from "../types/jobs";
|
|
5
8
|
|
|
6
9
|
const injectDefaultVarsInCustomJobs = (
|
|
@@ -24,7 +27,12 @@ const getCustomJobs = (context: ComponentContext) => {
|
|
|
24
27
|
export const createJobsForComponentContext = (
|
|
25
28
|
context: ComponentContext,
|
|
26
29
|
): CatladderJob[] => {
|
|
27
|
-
const buildJobs =
|
|
30
|
+
const buildJobs =
|
|
31
|
+
context.build.type !== "disabled"
|
|
32
|
+
? BUILD_TYPES[context.build.buildType].jobs(
|
|
33
|
+
context as ComponentContextWithBuild,
|
|
34
|
+
)
|
|
35
|
+
: [];
|
|
28
36
|
const deployJobs =
|
|
29
37
|
context.componentConfig.deploy !== false
|
|
30
38
|
? DEPLOY_TYPES[context.componentConfig.deploy.type].jobs(context)
|
package/src/types/config.ts
CHANGED
package/src/types/context.ts
CHANGED
|
@@ -116,6 +116,9 @@ export type BuildContextStandalone<
|
|
|
116
116
|
buildType: C["type"];
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
+
export type BuildContextDisabled = BuildContextComponentBase & {
|
|
120
|
+
type: "disabled";
|
|
121
|
+
};
|
|
119
122
|
export type BuildContextFromWorkspace = BuildContextComponentBase & {
|
|
120
123
|
config: BuildConfigFromWorkspace;
|
|
121
124
|
workspaceName: string;
|
|
@@ -133,10 +136,14 @@ export type BuildContextWorkspace = BuildContextBase & {
|
|
|
133
136
|
config: WorkspaceBuildConfig;
|
|
134
137
|
};
|
|
135
138
|
|
|
136
|
-
export type
|
|
139
|
+
export type BuildContextWithBuild =
|
|
137
140
|
| BuildContextStandalone
|
|
138
141
|
| BuildContextFromWorkspace;
|
|
139
142
|
|
|
143
|
+
export type BuildContextComponent =
|
|
144
|
+
| BuildContextWithBuild
|
|
145
|
+
| BuildContextDisabled;
|
|
146
|
+
|
|
140
147
|
export type BuildContext = BuildContextComponent | BuildContextWorkspace;
|
|
141
148
|
|
|
142
149
|
export type DeployContext = {
|
|
@@ -172,6 +179,8 @@ export type ComponentContext<
|
|
|
172
179
|
customJobs?: CatladderJob[];
|
|
173
180
|
};
|
|
174
181
|
|
|
182
|
+
export type ComponentContextWithBuild = ComponentContext<BuildContextWithBuild>;
|
|
183
|
+
|
|
175
184
|
export type Context = ComponentContext | WorkspaceContext;
|
|
176
185
|
|
|
177
186
|
export type CatladderJobWithContext<S = BaseStage> = CatladderJob<S> & {
|