@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.
- package/dist/build/base/createAppBuildJob.d.ts +8 -0
- package/dist/build/base/{createBuildJob.js → createAppBuildJob.js} +3 -3
- package/dist/build/base/index.d.ts +8 -0
- package/dist/build/base/index.js +57 -0
- package/dist/build/custom/buildJob.js +19 -22
- package/dist/build/docker.d.ts +2 -4
- package/dist/build/docker.js +4 -39
- package/dist/build/node/buildJob.js +30 -32
- package/dist/build/node/meteor.js +19 -21
- package/dist/build/rails/build.js +12 -19
- package/dist/build/types.d.ts +4 -3
- package/dist/bundles/catladder-gitlab/index.js +1 -1
- package/dist/constants.js +1 -1
- package/dist/deploy/base/deploy.d.ts +3 -2
- package/dist/deploy/base/deploy.js +9 -4
- package/dist/deploy/base/index.d.ts +10 -3
- package/dist/deploy/base/index.js +37 -16
- package/dist/deploy/base/rollback.d.ts +3 -2
- package/dist/deploy/base/rollback.js +8 -6
- package/dist/deploy/base/stop.d.ts +3 -2
- package/dist/deploy/base/stop.js +8 -6
- package/dist/deploy/cloudRun/deployJob.js +28 -26
- package/dist/deploy/custom/deployJob.js +14 -11
- package/dist/deploy/dockerTag/deployJob.js +15 -5
- package/dist/deploy/kubernetes/deployJob.js +14 -26
- package/dist/deploy/kubernetes/mongodb.d.ts +1 -1
- package/dist/deploy/kubernetes/mongodb.js +8 -7
- package/dist/deploy/types/index.d.ts +1 -1
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +1 -0
- package/dist/pipeline/gitlab/createGitlabJobs.js +4 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/gitlab-ci-yml.d.ts +769 -0
- package/dist/types/gitlab-ci-yml.js +9 -0
- package/dist/types/gitlab-types.d.ts +12 -85
- package/dist/types/jobs.d.ts +3 -3
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +0 -36
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +0 -36
- package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +0 -36
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +0 -72
- package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +0 -36
- package/examples/__snapshots__/meteor-kubernetes.ts.snap +0 -36
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +0 -36
- package/package.json +4 -2
- package/scripts/generate-gitlab-ci-types.ts +51 -0
- package/src/build/base/{createBuildJob.ts → createAppBuildJob.ts} +3 -2
- package/src/build/base/index.ts +35 -0
- package/src/build/custom/buildJob.ts +32 -45
- package/src/build/docker.ts +14 -17
- package/src/build/node/buildJob.ts +50 -61
- package/src/build/node/meteor.ts +31 -36
- package/src/build/rails/build.ts +8 -10
- package/src/build/types.ts +4 -8
- package/src/deploy/base/deploy.ts +16 -2
- package/src/deploy/base/index.ts +22 -3
- package/src/deploy/base/rollback.ts +13 -2
- package/src/deploy/base/stop.ts +13 -4
- package/src/deploy/cloudRun/deployJob.ts +13 -15
- package/src/deploy/custom/deployJob.ts +17 -20
- package/src/deploy/dockerTag/deployJob.ts +6 -7
- package/src/deploy/kubernetes/deployJob.ts +17 -34
- package/src/deploy/kubernetes/mongodb.ts +3 -2
- package/src/pipeline/gitlab/createGitlabJobs.ts +3 -0
- package/src/types/gitlab-ci-yml.ts +892 -0
- package/src/types/gitlab-types.ts +49 -86
- package/src/types/jobs.ts +3 -4
- package/dist/build/base/createBuildJob.d.ts +0 -7
|
@@ -6,7 +6,12 @@ import { getLabels } from "../../context/getLabels";
|
|
|
6
6
|
import { getRunnerImage } from "../../runner";
|
|
7
7
|
import type { Context } from "../../types/context";
|
|
8
8
|
import type { CatladderJob } from "../../types/jobs";
|
|
9
|
-
import {
|
|
9
|
+
import { allowFailureInScripts } from "../../utils/gitlab";
|
|
10
|
+
import { createDeployementJobs } from "../base";
|
|
11
|
+
import {
|
|
12
|
+
getDependencyTrackDeleteScript,
|
|
13
|
+
getDependencyTrackUploadScript,
|
|
14
|
+
} from "../sbom";
|
|
10
15
|
import type {
|
|
11
16
|
DeployConfigCloudRun,
|
|
12
17
|
DeployConfigCloudRunJob,
|
|
@@ -14,18 +19,13 @@ import type {
|
|
|
14
19
|
DeployConfigCloudRunService,
|
|
15
20
|
} from "../types";
|
|
16
21
|
import { isOfDeployType } from "../types";
|
|
17
|
-
import {
|
|
22
|
+
import { createArgsString } from "./utils/createArgsString";
|
|
18
23
|
import {
|
|
19
24
|
getDatabaseCreateScript,
|
|
20
25
|
getDatabaseDeleteScript,
|
|
21
26
|
} from "./utils/database";
|
|
22
|
-
import {
|
|
27
|
+
import { gcloudServiceAccountLoginCommands } from "./utils/gcloudServiceAccountLoginCommands";
|
|
23
28
|
import { getCloudRunJobName } from "./utils/jobName";
|
|
24
|
-
import { createArgsString } from "./utils/createArgsString";
|
|
25
|
-
import {
|
|
26
|
-
getDependencyTrackDeleteScript,
|
|
27
|
-
getDependencyTrackUploadScript,
|
|
28
|
-
} from "../sbom";
|
|
29
29
|
|
|
30
30
|
const setExtraVarsScripts = (deployConfig: DeployConfigCloudRun) => [
|
|
31
31
|
`export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe ${deployConfig.projectId} --format="value(projectNumber)")`,
|
|
@@ -43,7 +43,6 @@ export const createGoogleCloudRunDeployJobs = (
|
|
|
43
43
|
// should not happen
|
|
44
44
|
throw new Error("deploy config is wrong");
|
|
45
45
|
}
|
|
46
|
-
const baseDeploymentJob = getBaseDeploymentJob(context);
|
|
47
46
|
|
|
48
47
|
const fullAppName = `${context.fullConfig.customerName}-${context.fullConfig.appName}`;
|
|
49
48
|
const dockerUrl = `${deployConfig.region}-docker.pkg.dev/${deployConfig.projectId}/catladder-deploy/${fullAppName}`;
|
|
@@ -257,8 +256,8 @@ export const createGoogleCloudRunDeployJobs = (
|
|
|
257
256
|
: []),
|
|
258
257
|
...getDependencyTrackDeleteScript(context),
|
|
259
258
|
];
|
|
260
|
-
return
|
|
261
|
-
merge(
|
|
259
|
+
return createDeployementJobs(context, {
|
|
260
|
+
deploy: merge(getDockerJobBaseProps(context), {
|
|
262
261
|
artifacts: { paths: ["____envvars.yaml"] },
|
|
263
262
|
variables: {
|
|
264
263
|
CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
|
|
@@ -271,13 +270,12 @@ export const createGoogleCloudRunDeployJobs = (
|
|
|
271
270
|
image: getRunnerImage("gcloud"),
|
|
272
271
|
script: deployScripts,
|
|
273
272
|
}),
|
|
274
|
-
|
|
275
|
-
merge({}, getBaseDeploymentStopJob(context), {
|
|
273
|
+
stop: {
|
|
276
274
|
image: getRunnerImage("gcloud"),
|
|
277
275
|
variables: {
|
|
278
276
|
CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
|
|
279
277
|
},
|
|
280
278
|
script: allowFailureInScripts(stopScripts),
|
|
281
|
-
}
|
|
282
|
-
|
|
279
|
+
},
|
|
280
|
+
});
|
|
283
281
|
};
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { merge } from "lodash";
|
|
2
|
-
|
|
3
1
|
import { getYarnInstall } from "../../build/node/yarn";
|
|
4
2
|
import { getRunnerImage } from "../../runner";
|
|
5
3
|
import type { Context } from "../../types/context";
|
|
6
4
|
import type { CatladderJob } from "../../types/jobs";
|
|
7
|
-
import {
|
|
8
|
-
import { isOfDeployType } from "../types";
|
|
5
|
+
import { createDeployementJobs } from "../base";
|
|
9
6
|
import {
|
|
10
7
|
getDependencyTrackDeleteScript,
|
|
11
8
|
getDependencyTrackUploadScript,
|
|
12
9
|
} from "../sbom";
|
|
10
|
+
import { isOfDeployType } from "../types";
|
|
13
11
|
|
|
14
12
|
export const createCustomDeployJobs = (context: Context): CatladderJob[] => {
|
|
15
13
|
const deployConfig = context.componentConfig.deploy;
|
|
@@ -20,11 +18,10 @@ export const createCustomDeployJobs = (context: Context): CatladderJob[] => {
|
|
|
20
18
|
// should not happen
|
|
21
19
|
throw new Error("deploy config is not custom");
|
|
22
20
|
}
|
|
23
|
-
const baseDeploymentJob = getBaseDeploymentJob(context);
|
|
24
21
|
// FIXME: custom deploy currently assumes yarn-based project
|
|
25
22
|
const yarnInstall = getYarnInstall(context, { noCustomPostInstall: true });
|
|
26
|
-
return
|
|
27
|
-
|
|
23
|
+
return createDeployementJobs(context, {
|
|
24
|
+
deploy: {
|
|
28
25
|
image: deployConfig.jobImage ?? getRunnerImage("jobs-default"),
|
|
29
26
|
cache: deployConfig.jobCache ?? [],
|
|
30
27
|
script: [
|
|
@@ -33,17 +30,17 @@ export const createCustomDeployJobs = (context: Context): CatladderJob[] => {
|
|
|
33
30
|
...deployConfig.script,
|
|
34
31
|
...getDependencyTrackUploadScript(context),
|
|
35
32
|
],
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
:
|
|
48
|
-
|
|
33
|
+
variables: {},
|
|
34
|
+
},
|
|
35
|
+
stop: deployConfig.stopScript
|
|
36
|
+
? {
|
|
37
|
+
image: deployConfig.jobImage ?? getRunnerImage("jobs-default"),
|
|
38
|
+
script: [
|
|
39
|
+
...deployConfig.stopScript,
|
|
40
|
+
...getDependencyTrackDeleteScript(context),
|
|
41
|
+
],
|
|
42
|
+
variables: {},
|
|
43
|
+
}
|
|
44
|
+
: undefined,
|
|
45
|
+
});
|
|
49
46
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { merge } from "lodash";
|
|
2
1
|
import { getDockerJobBaseProps, gitlabDockerLogin } from "../../build/docker";
|
|
3
2
|
|
|
4
3
|
import type { Context } from "../../types/context";
|
|
5
4
|
import type { CatladderJob } from "../../types/jobs";
|
|
6
|
-
import {
|
|
5
|
+
import { createDeployementJobs } from "../base";
|
|
7
6
|
import { isOfDeployType } from "../types";
|
|
8
7
|
|
|
9
8
|
export const createDockerTagDeployJobs = (context: Context): CatladderJob[] => {
|
|
@@ -15,10 +14,10 @@ export const createDockerTagDeployJobs = (context: Context): CatladderJob[] => {
|
|
|
15
14
|
// should not happen
|
|
16
15
|
throw new Error("deploy config is not dockerTag");
|
|
17
16
|
}
|
|
18
|
-
const baseDeploymentJob = getBaseDeploymentJob(context);
|
|
19
17
|
const tag = deployConfig.tag;
|
|
20
|
-
return
|
|
21
|
-
|
|
18
|
+
return createDeployementJobs(context, {
|
|
19
|
+
deploy: {
|
|
20
|
+
...getDockerJobBaseProps(context),
|
|
22
21
|
script: [
|
|
23
22
|
gitlabDockerLogin,
|
|
24
23
|
`docker pull $DOCKER_IMAGE:$DOCKER_IMAGE_TAG`,
|
|
@@ -26,6 +25,6 @@ export const createDockerTagDeployJobs = (context: Context): CatladderJob[] => {
|
|
|
26
25
|
`docker push $DOCKER_IMAGE:${tag}`,
|
|
27
26
|
`echo "pushed as $DOCKER_IMAGE:${tag}"`,
|
|
28
27
|
],
|
|
29
|
-
}
|
|
30
|
-
|
|
28
|
+
},
|
|
29
|
+
});
|
|
31
30
|
};
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import { dump } from "js-yaml";
|
|
2
|
-
import { merge } from "lodash";
|
|
3
|
-
import { getSecretVarNameForContext } from "../..";
|
|
4
2
|
import { getRunnerImage } from "../../runner";
|
|
5
3
|
import type { Context } from "../../types/context";
|
|
6
4
|
import type { CatladderJob } from "../../types/jobs";
|
|
7
|
-
import {
|
|
8
|
-
getBaseDeploymentJob,
|
|
9
|
-
getBaseDeploymentStopJob,
|
|
10
|
-
getBaseRollbackJob,
|
|
11
|
-
} from "../base";
|
|
12
|
-
import { isOfDeployType } from "../types";
|
|
13
|
-
import { createKubeValues } from "./kubeValues";
|
|
5
|
+
import { createDeployementJobs } from "../base";
|
|
14
6
|
import {
|
|
15
7
|
getDependencyTrackDeleteScript,
|
|
16
8
|
getDependencyTrackUploadScript,
|
|
17
9
|
} from "../sbom";
|
|
10
|
+
import { isOfDeployType } from "../types";
|
|
11
|
+
import { createKubeValues } from "./kubeValues";
|
|
12
|
+
import { getSecretVarNameForContext } from "../../context/getEnvironmentVariables";
|
|
18
13
|
|
|
19
14
|
export const createKubernetesDeployJobs = (
|
|
20
15
|
context: Context
|
|
@@ -29,10 +24,7 @@ export const createKubernetesDeployJobs = (
|
|
|
29
24
|
}
|
|
30
25
|
|
|
31
26
|
const kubeValues = createKubeValues(context);
|
|
32
|
-
const
|
|
33
|
-
namespace: context.environment.envVars.KUBE_NAMESPACE,
|
|
34
|
-
};
|
|
35
|
-
const shared = {
|
|
27
|
+
const shared: Pick<CatladderJob, "image" | "variables"> = {
|
|
36
28
|
image: getRunnerImage("kubernetes"),
|
|
37
29
|
variables: {
|
|
38
30
|
...context.environment.envVars,
|
|
@@ -55,9 +47,6 @@ export const createKubernetesDeployJobs = (
|
|
|
55
47
|
},
|
|
56
48
|
};
|
|
57
49
|
|
|
58
|
-
const baseDeploymentJob = getBaseDeploymentJob(context);
|
|
59
|
-
const baseStopJob = getBaseDeploymentStopJob(context);
|
|
60
|
-
const baseRollbackJob = getBaseRollbackJob(context);
|
|
61
50
|
const clusterName = `kube-${context.environment.fullName}`;
|
|
62
51
|
const connectContext = [
|
|
63
52
|
`kubectl config set-cluster "${clusterName}" --server="$${getSecretVarNameForContext(
|
|
@@ -74,8 +63,10 @@ export const createKubernetesDeployJobs = (
|
|
|
74
63
|
`kubectl config set-context "${clusterName}" --cluster="${clusterName}" --user="${clusterName}" --namespace="${context.environment.envVars.KUBE_NAMESPACE}"`,
|
|
75
64
|
`kubectl config use-context "${clusterName}"`,
|
|
76
65
|
];
|
|
77
|
-
|
|
78
|
-
|
|
66
|
+
|
|
67
|
+
return createDeployementJobs(context, {
|
|
68
|
+
deploy: {
|
|
69
|
+
...shared,
|
|
79
70
|
script: [
|
|
80
71
|
...connectContext,
|
|
81
72
|
"kubernetesCreateSecret",
|
|
@@ -83,26 +74,18 @@ export const createKubernetesDeployJobs = (
|
|
|
83
74
|
...getDependencyTrackUploadScript(context),
|
|
84
75
|
"echo deployment successful 😻",
|
|
85
76
|
],
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}),
|
|
90
|
-
merge({}, baseStopJob, shared, {
|
|
77
|
+
},
|
|
78
|
+
stop: {
|
|
79
|
+
...shared,
|
|
91
80
|
script: [
|
|
92
81
|
...connectContext,
|
|
93
82
|
"kubernetesDelete",
|
|
94
83
|
...getDependencyTrackDeleteScript(context),
|
|
95
84
|
],
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}),
|
|
100
|
-
|
|
101
|
-
merge({}, baseRollbackJob, shared, {
|
|
85
|
+
},
|
|
86
|
+
rollback: {
|
|
87
|
+
...shared,
|
|
102
88
|
script: [...connectContext, "kubernetesRollback"],
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
},
|
|
106
|
-
}),
|
|
107
|
-
];
|
|
89
|
+
},
|
|
90
|
+
});
|
|
108
91
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { range } from "lodash";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import { getSecretVarNameForContext } from "../../context/getEnvironmentVariables";
|
|
3
|
+
import type { Context } from "../../types/context";
|
|
4
|
+
import { isOfDeployType } from "../types";
|
|
4
5
|
|
|
5
6
|
const getCredentialString = (context: Context) =>
|
|
6
7
|
`root:$${getSecretVarNameForContext(context, "MONGODB_ROOT_PASSWORD")}@`;
|
|
@@ -3,6 +3,7 @@ import { BASE_RETRY } from "../../defaults";
|
|
|
3
3
|
import type { GitlabJobDef } from "../../types";
|
|
4
4
|
import type { CatladderJob, CatladderJobNeed } from "../../types/jobs";
|
|
5
5
|
import type { AllCatladderJobs } from "../createAllJobs";
|
|
6
|
+
import { notNil } from "../../utils";
|
|
6
7
|
|
|
7
8
|
type AllGitlabJobs = Record<string, GitlabJobDef>;
|
|
8
9
|
|
|
@@ -52,6 +53,7 @@ export const makeGitlabJob = (
|
|
|
52
53
|
name,
|
|
53
54
|
needs,
|
|
54
55
|
jobTags,
|
|
56
|
+
script,
|
|
55
57
|
...job
|
|
56
58
|
}: CatladderJob<string>,
|
|
57
59
|
allJobs: AllCatladderJobs
|
|
@@ -106,6 +108,7 @@ export const makeGitlabJob = (
|
|
|
106
108
|
|
|
107
109
|
const gitlabJob: GitlabJobDef = removeUndefined({
|
|
108
110
|
...job,
|
|
111
|
+
script: script?.filter(notNil),
|
|
109
112
|
tags: jobTags,
|
|
110
113
|
stage,
|
|
111
114
|
environment: job.environment?.on_stop
|