@catladder/pipeline 0.0.0-refactor-docker-c24f8608 → 0.0.0-refactor-docker-45f6e733
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.js +6 -6
- package/dist/build/base/writeBuildInfo.js +1 -1
- package/dist/build/base/writeDotEnv.js +1 -1
- package/dist/build/custom/__tests__/testJob.test.js +11 -14
- package/dist/build/custom/buildJob.js +3 -3
- package/dist/build/custom/testJob.js +5 -5
- package/dist/build/docker.d.ts +2 -6
- package/dist/build/docker.js +13 -10
- package/dist/build/node/buildJob.js +7 -7
- package/dist/build/node/cache.js +1 -1
- package/dist/build/node/meteor.js +5 -5
- package/dist/build/node/testJob.js +11 -11
- package/dist/build/rails/build.js +3 -3
- package/dist/build/rails/test.js +4 -4
- package/dist/build/sbom.js +2 -2
- package/dist/bundles/catladder-gitlab/index.js +181 -162
- package/dist/constants.js +1 -1
- package/dist/context/getLabels.js +1 -1
- package/dist/context/index.js +34 -12
- package/dist/deploy/base/deploy.js +9 -8
- package/dist/deploy/cloudRun/artifactsRegistry.d.ts +1 -5
- package/dist/deploy/cloudRun/artifactsRegistry.js +8 -9
- package/dist/deploy/cloudRun/cloudRunRevisions.js +4 -5
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +1 -1
- package/dist/deploy/cloudRun/createJobs/common.d.ts +4 -4
- package/dist/deploy/cloudRun/createJobs/common.js +2 -1
- package/dist/deploy/cloudRun/createJobs/index.js +2 -4
- package/dist/deploy/custom/deployJob.js +7 -10
- package/dist/deploy/dockerTag/deployJob.js +3 -5
- package/dist/deploy/kubernetes/cloudSql/index.js +11 -9
- package/dist/deploy/kubernetes/deployJob.js +4 -7
- package/dist/deploy/kubernetes/kubeEnv.js +2 -1
- package/dist/deploy/kubernetes/kubeValues.js +10 -10
- package/dist/deploy/kubernetes/mongodb.js +11 -11
- package/dist/deploy/sbom.js +1 -1
- package/dist/deploy/types/index.d.ts +1 -1
- package/dist/deploy/types/index.js +1 -1
- package/dist/deploy/utils.js +2 -1
- package/dist/pipeline/createJobsForComponent.js +5 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/context.d.ts +13 -1
- package/package.json +1 -1
- package/src/build/base/createAppBuildJob.ts +7 -7
- package/src/build/base/writeBuildInfo.ts +1 -1
- package/src/build/base/writeDotEnv.ts +1 -1
- package/src/build/custom/__tests__/testJob.test.ts +5 -8
- package/src/build/custom/buildJob.ts +4 -4
- package/src/build/custom/testJob.ts +5 -5
- package/src/build/docker.ts +21 -14
- package/src/build/node/buildJob.ts +8 -8
- package/src/build/node/cache.ts +1 -1
- package/src/build/node/meteor.ts +9 -15
- package/src/build/node/testJob.ts +14 -14
- package/src/build/rails/build.ts +3 -3
- package/src/build/rails/test.ts +4 -4
- package/src/build/sbom.ts +3 -3
- package/src/context/getLabels.ts +1 -1
- package/src/context/index.ts +21 -5
- package/src/deploy/base/deploy.ts +8 -14
- package/src/deploy/cloudRun/artifactsRegistry.ts +5 -10
- package/src/deploy/cloudRun/cloudRunRevisions.ts +3 -5
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +1 -1
- package/src/deploy/cloudRun/createJobs/common.ts +5 -5
- package/src/deploy/cloudRun/createJobs/index.ts +1 -4
- package/src/deploy/custom/deployJob.ts +4 -6
- package/src/deploy/dockerTag/deployJob.ts +2 -5
- package/src/deploy/kubernetes/cloudSql/index.ts +7 -4
- package/src/deploy/kubernetes/deployJob.ts +1 -4
- package/src/deploy/kubernetes/kubeEnv.ts +1 -1
- package/src/deploy/kubernetes/kubeValues.ts +3 -3
- package/src/deploy/kubernetes/mongodb.ts +6 -6
- package/src/deploy/sbom.ts +1 -2
- package/src/deploy/types/index.ts +2 -2
- package/src/deploy/utils.ts +1 -1
- package/src/pipeline/createJobsForComponent.ts +6 -10
- package/src/types/config.ts +3 -1
- package/src/types/context.ts +16 -1
|
@@ -20,7 +20,7 @@ export const createCustomTestJobs = (
|
|
|
20
20
|
return [];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const buildConfig = context.
|
|
23
|
+
const buildConfig = context.build.config;
|
|
24
24
|
|
|
25
25
|
if (!isOfBuildType(buildConfig, "custom")) {
|
|
26
26
|
throw new Error("deploy config is not custom");
|
|
@@ -28,7 +28,7 @@ export const createCustomTestJobs = (
|
|
|
28
28
|
|
|
29
29
|
const base: Omit<CatladderJob, "script" | "name"> = {
|
|
30
30
|
variables: {
|
|
31
|
-
APP_PATH: context.
|
|
31
|
+
APP_PATH: context.build.dir,
|
|
32
32
|
...context.environment.jobOnlyVars.build.envVars,
|
|
33
33
|
...(buildConfig.extraVars ?? {}),
|
|
34
34
|
},
|
|
@@ -48,7 +48,7 @@ export const createCustomTestJobs = (
|
|
|
48
48
|
script: [...(ensureArray(buildConfig.audit?.command) ?? [])],
|
|
49
49
|
allow_failure: true,
|
|
50
50
|
...createArtifactsConfig(
|
|
51
|
-
context.
|
|
51
|
+
context.build.dir,
|
|
52
52
|
buildConfig.audit?.artifactsReports,
|
|
53
53
|
buildConfig.audit?.artifacts,
|
|
54
54
|
),
|
|
@@ -63,7 +63,7 @@ export const createCustomTestJobs = (
|
|
|
63
63
|
image: buildConfig.lint?.jobImage ?? buildConfig.jobImage,
|
|
64
64
|
script: [...(ensureArray(buildConfig.lint?.command) ?? [])],
|
|
65
65
|
...createArtifactsConfig(
|
|
66
|
-
context.
|
|
66
|
+
context.build.dir,
|
|
67
67
|
buildConfig.lint?.artifactsReports,
|
|
68
68
|
buildConfig.lint?.artifacts,
|
|
69
69
|
),
|
|
@@ -77,7 +77,7 @@ export const createCustomTestJobs = (
|
|
|
77
77
|
image: buildConfig.test?.jobImage ?? buildConfig.jobImage,
|
|
78
78
|
script: [...(ensureArray(buildConfig.test?.command) ?? [])],
|
|
79
79
|
...createArtifactsConfig(
|
|
80
|
-
context.
|
|
80
|
+
context.build.dir,
|
|
81
81
|
buildConfig.test?.artifactsReports,
|
|
82
82
|
buildConfig.test?.artifacts,
|
|
83
83
|
),
|
package/src/build/docker.ts
CHANGED
|
@@ -21,8 +21,9 @@ const DOCKER_BUILD_RUNNER_REQUESTS = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export const getDockerImageVariables = (context: ComponentContext) => {
|
|
24
|
+
const deployConfig = context.deploy?.config;
|
|
24
25
|
return {
|
|
25
|
-
...(isOfDeployType(
|
|
26
|
+
...(isOfDeployType(deployConfig, "google-cloudrun")
|
|
26
27
|
? {
|
|
27
28
|
DOCKER_REGISTRY: getArtifactsRegistryHost(context),
|
|
28
29
|
DOCKER_IMAGE: getArtifactsRegistryImageName(context),
|
|
@@ -47,11 +48,19 @@ export const getDockerImageVariables = (context: ComponentContext) => {
|
|
|
47
48
|
/**
|
|
48
49
|
* Weather the context requires a docker build
|
|
49
50
|
*/
|
|
50
|
-
export const requiresDockerBuild = ({
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
export const requiresDockerBuild = (context: ComponentContext): boolean => {
|
|
52
|
+
const deployConfig = context.deploy?.config;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
isOfDeployType(
|
|
56
|
+
deployConfig,
|
|
57
|
+
"kubernetes",
|
|
58
|
+
"google-cloudrun",
|
|
59
|
+
"dockerTag",
|
|
60
|
+
) ||
|
|
61
|
+
(isOfDeployType(deployConfig, "custom") && deployConfig.requiresDocker)
|
|
62
|
+
);
|
|
63
|
+
};
|
|
55
64
|
|
|
56
65
|
// those need to be runner variables
|
|
57
66
|
const getDockerBuildRunnerVariables = () => ({
|
|
@@ -78,8 +87,8 @@ const getDockerAdditions = (build: BuildConfig) => {
|
|
|
78
87
|
};
|
|
79
88
|
export const getDockerBuildVariables = (context: ComponentContext) => {
|
|
80
89
|
return {
|
|
81
|
-
...getDockerAdditions(context.
|
|
82
|
-
APP_DIR: context.
|
|
90
|
+
...getDockerAdditions(context.build.config),
|
|
91
|
+
APP_DIR: context.build.dir,
|
|
83
92
|
DOCKER_DIR: ".", // relative to componentdir
|
|
84
93
|
|
|
85
94
|
...getDockerImageVariables(context),
|
|
@@ -88,9 +97,7 @@ export const getDockerBuildVariables = (context: ComponentContext) => {
|
|
|
88
97
|
|
|
89
98
|
export const DOCKER_BUILD_JOB_NAME = "🔨 docker";
|
|
90
99
|
|
|
91
|
-
export const getDockerJobBaseProps = (
|
|
92
|
-
context: ComponentContext,
|
|
93
|
-
): Pick<
|
|
100
|
+
export const getDockerJobBaseProps = (): Pick<
|
|
94
101
|
CatladderJob,
|
|
95
102
|
"image" | "services" | "variables" | "runnerVariables"
|
|
96
103
|
> => {
|
|
@@ -117,7 +124,7 @@ export const createDockerBuildJobBase = (
|
|
|
117
124
|
name: DOCKER_BUILD_JOB_NAME,
|
|
118
125
|
envMode: "jobPerEnv",
|
|
119
126
|
stage: "build",
|
|
120
|
-
...getDockerJobBaseProps(
|
|
127
|
+
...getDockerJobBaseProps(),
|
|
121
128
|
script: script || [],
|
|
122
129
|
},
|
|
123
130
|
{
|
|
@@ -132,7 +139,7 @@ export const createDockerBuildJobBase = (
|
|
|
132
139
|
};
|
|
133
140
|
|
|
134
141
|
export const gitlabDockerLogin = (context: ComponentContext) =>
|
|
135
|
-
isOfDeployType(context.
|
|
142
|
+
context.deploy && isOfDeployType(context.deploy.config, "google-cloudrun")
|
|
136
143
|
? [
|
|
137
144
|
...gcloudServiceAccountLoginCommands(context),
|
|
138
145
|
`gcloud auth configure-docker ${getArtifactsRegistryHost(context)}`,
|
|
@@ -192,4 +199,4 @@ export const getDockerBuildDefaultScript = (
|
|
|
192
199
|
].filter(Boolean);
|
|
193
200
|
|
|
194
201
|
export const hasDockerfile = (context: ComponentContext) =>
|
|
195
|
-
existsSync(path.join(context.
|
|
202
|
+
existsSync(path.join(context.build.dir, "Dockerfile"));
|
|
@@ -13,14 +13,14 @@ import { getDockerAppCopyAndBuildScript, getYarnInstall } from "./yarn";
|
|
|
13
13
|
export const createNodeBuildJobs = (
|
|
14
14
|
context: ComponentContext,
|
|
15
15
|
): CatladderJob[] => {
|
|
16
|
-
const buildConfig = context.
|
|
16
|
+
const buildConfig = context.build.config;
|
|
17
17
|
|
|
18
18
|
if (!isOfBuildType(buildConfig, "node", "node-static", "storybook")) {
|
|
19
19
|
throw new Error("deploy config is not node, node-static or storybook");
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const defaultImage = getRunnerImage("jobs-default");
|
|
23
|
-
const yarnInstall = getYarnInstall(context.
|
|
23
|
+
const yarnInstall = getYarnInstall(context.build);
|
|
24
24
|
|
|
25
25
|
return createBuildJobs(context, {
|
|
26
26
|
appBuild:
|
|
@@ -30,7 +30,7 @@ export const createNodeBuildJobs = (
|
|
|
30
30
|
runnerVariables: NODE_RUNNER_BUILD_VARIABLES,
|
|
31
31
|
cache: [
|
|
32
32
|
...(ensureArray(buildConfig.jobCache) ?? []),
|
|
33
|
-
...getNodeCache(context.
|
|
33
|
+
...getNodeCache(context.build),
|
|
34
34
|
...getNextCache(context),
|
|
35
35
|
],
|
|
36
36
|
script: [
|
|
@@ -39,9 +39,9 @@ export const createNodeBuildJobs = (
|
|
|
39
39
|
],
|
|
40
40
|
artifacts: {
|
|
41
41
|
paths: [
|
|
42
|
-
context.
|
|
42
|
+
context.build.dir,
|
|
43
43
|
// also copy workspace dependencies in monorepo if packages are shared and they create build artifacts
|
|
44
|
-
...(context.
|
|
44
|
+
...(context.build.packageManagerInfo
|
|
45
45
|
?.currentWorkspaceDependencies ?? []),
|
|
46
46
|
].flatMap((dir) => [
|
|
47
47
|
join(dir, "__build_info.json"),
|
|
@@ -65,14 +65,14 @@ export const createNodeBuildJobs = (
|
|
|
65
65
|
? "nginx"
|
|
66
66
|
: "node",
|
|
67
67
|
),
|
|
68
|
-
cache: [...getYarnCache(context.
|
|
68
|
+
cache: [...getYarnCache(context.build, "pull")],
|
|
69
69
|
variables: {
|
|
70
70
|
// only required for non static
|
|
71
71
|
DOCKER_COPY_AND_INSTALL_APP: getDockerAppCopyAndBuildScript(
|
|
72
|
-
context.
|
|
72
|
+
context.build,
|
|
73
73
|
),
|
|
74
74
|
DOCKER_COPY_WORKSPACE_FILES:
|
|
75
|
-
context.
|
|
75
|
+
context.build.packageManagerInfo?.pathsToCopyInDocker
|
|
76
76
|
.map((dir) => `COPY --chown=node:node ${dir} /app/${dir}`)
|
|
77
77
|
?.join("\n"),
|
|
78
78
|
},
|
package/src/build/node/cache.ts
CHANGED
|
@@ -68,6 +68,6 @@ export const getNextCache = (context: ComponentContext): GitlabJobCache[] => [
|
|
|
68
68
|
{
|
|
69
69
|
key: context.componentName + "-next-cache",
|
|
70
70
|
policy: "pull-push",
|
|
71
|
-
paths: [context.
|
|
71
|
+
paths: [context.build.dir + "/.next/cache/"],
|
|
72
72
|
},
|
|
73
73
|
];
|
package/src/build/node/meteor.ts
CHANGED
|
@@ -16,35 +16,29 @@ const getMeteorCache = (context: ComponentContext): GitlabJobCache[] => [
|
|
|
16
16
|
key: context.componentName + "meteor-build-cache",
|
|
17
17
|
policy: "pull-push",
|
|
18
18
|
paths: [
|
|
19
|
-
join(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
),
|
|
23
|
-
join(context.componentConfig.dir, ".meteor/local/plugin-cache"),
|
|
24
|
-
join(context.componentConfig.dir, ".meteor/local/isopacks"),
|
|
25
|
-
join(context.componentConfig.dir, ".meteor/local/bundler-cache/scanner"),
|
|
19
|
+
join(context.build.dir, ".meteor/local/resolver-result-cache.json"),
|
|
20
|
+
join(context.build.dir, ".meteor/local/plugin-cache"),
|
|
21
|
+
join(context.build.dir, ".meteor/local/isopacks"),
|
|
22
|
+
join(context.build.dir, ".meteor/local/bundler-cache/scanner"),
|
|
26
23
|
],
|
|
27
24
|
},
|
|
28
25
|
];
|
|
29
26
|
export const createMeteorBuildJobs = (
|
|
30
27
|
context: ComponentContext,
|
|
31
28
|
): CatladderJob[] => {
|
|
32
|
-
const buildConfig = context.
|
|
29
|
+
const buildConfig = context.build.config;
|
|
33
30
|
|
|
34
31
|
if (!isOfBuildType(buildConfig, "meteor")) {
|
|
35
32
|
throw new Error("deploy config is not meteor");
|
|
36
33
|
}
|
|
37
34
|
|
|
38
|
-
const yarnInstall = getYarnInstall(context.
|
|
35
|
+
const yarnInstall = getYarnInstall(context.build);
|
|
39
36
|
|
|
40
37
|
return createBuildJobs(context, {
|
|
41
38
|
appBuild:
|
|
42
39
|
buildConfig.buildCommand !== null
|
|
43
40
|
? {
|
|
44
|
-
cache: [
|
|
45
|
-
...getNodeCache(context.buildContext),
|
|
46
|
-
...getMeteorCache(context),
|
|
47
|
-
],
|
|
41
|
+
cache: [...getNodeCache(context.build), ...getMeteorCache(context)],
|
|
48
42
|
image: getRunnerImage("jobs-meteor"),
|
|
49
43
|
variables: {
|
|
50
44
|
METEOR_DISABLE_OPTIMISTIC_CACHING: "1", // see https://forums.meteor.com/t/veeery-long-building-time-inside-docker-container/58673/17?u=macrozone
|
|
@@ -62,8 +56,8 @@ export const createMeteorBuildJobs = (
|
|
|
62
56
|
],
|
|
63
57
|
artifacts: {
|
|
64
58
|
paths: [
|
|
65
|
-
context.
|
|
66
|
-
context.
|
|
59
|
+
context.build.dir + "/__build_info.json",
|
|
60
|
+
context.build.dir + "/dist",
|
|
67
61
|
],
|
|
68
62
|
},
|
|
69
63
|
}
|
|
@@ -16,12 +16,12 @@ export const createNodeTestJobs = (
|
|
|
16
16
|
return [];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const buildConfig = context.
|
|
19
|
+
const buildConfig = context.build.config;
|
|
20
20
|
|
|
21
21
|
const defaultImage = getRunnerImage("jobs-default");
|
|
22
22
|
const base: Omit<CatladderJob, "script" | "name"> = {
|
|
23
23
|
variables: {
|
|
24
|
-
APP_PATH: context.
|
|
24
|
+
APP_PATH: context.build.dir,
|
|
25
25
|
...context.environment.jobOnlyVars.build.envVars,
|
|
26
26
|
...(buildConfig.extraVars ?? {}),
|
|
27
27
|
},
|
|
@@ -30,7 +30,7 @@ export const createNodeTestJobs = (
|
|
|
30
30
|
needs: [],
|
|
31
31
|
envMode: "none",
|
|
32
32
|
};
|
|
33
|
-
const yarnInstall = getYarnInstall(context.
|
|
33
|
+
const yarnInstall = getYarnInstall(context.build);
|
|
34
34
|
const auditJob: CatladderJob | null =
|
|
35
35
|
buildConfig.audit !== false
|
|
36
36
|
? {
|
|
@@ -39,16 +39,16 @@ export const createNodeTestJobs = (
|
|
|
39
39
|
image: buildConfig.audit?.jobImage ?? defaultImage,
|
|
40
40
|
cache: undefined, // audit does not need yarn install and no cache
|
|
41
41
|
script: [
|
|
42
|
-
`cd ${context.
|
|
42
|
+
`cd ${context.build.dir}`,
|
|
43
43
|
...(ensureArray(buildConfig.audit?.command) ?? [
|
|
44
|
-
context.
|
|
44
|
+
context.build.packageManagerInfo?.isClassic
|
|
45
45
|
? "yarn audit"
|
|
46
46
|
: "yarn npm audit --environment production", // yarn 2
|
|
47
47
|
]),
|
|
48
48
|
],
|
|
49
49
|
allow_failure: true,
|
|
50
50
|
...createArtifactsConfig(
|
|
51
|
-
context.
|
|
51
|
+
context.build.dir,
|
|
52
52
|
buildConfig.audit?.artifactsReports,
|
|
53
53
|
buildConfig.audit?.artifacts,
|
|
54
54
|
),
|
|
@@ -61,15 +61,15 @@ export const createNodeTestJobs = (
|
|
|
61
61
|
name: "👮 lint",
|
|
62
62
|
...base,
|
|
63
63
|
image: buildConfig.lint?.jobImage ?? defaultImage,
|
|
64
|
-
cache: getNodeCache(context.
|
|
64
|
+
cache: getNodeCache(context.build),
|
|
65
65
|
script: [
|
|
66
|
-
...ensureNodeVersion(context.
|
|
67
|
-
`cd ${context.
|
|
66
|
+
...ensureNodeVersion(context.build),
|
|
67
|
+
`cd ${context.build.dir}`,
|
|
68
68
|
...yarnInstall,
|
|
69
69
|
...(ensureArray(buildConfig.lint?.command) ?? ["yarn lint"]),
|
|
70
70
|
],
|
|
71
71
|
...createArtifactsConfig(
|
|
72
|
-
context.
|
|
72
|
+
context.build.dir,
|
|
73
73
|
buildConfig.lint?.artifactsReports,
|
|
74
74
|
buildConfig.lint?.artifacts,
|
|
75
75
|
),
|
|
@@ -83,15 +83,15 @@ export const createNodeTestJobs = (
|
|
|
83
83
|
...base,
|
|
84
84
|
image:
|
|
85
85
|
buildConfig.test?.jobImage ?? getRunnerImage("jobs-testing-chrome"),
|
|
86
|
-
cache: getNodeCache(context.
|
|
86
|
+
cache: getNodeCache(context.build),
|
|
87
87
|
script: [
|
|
88
|
-
...ensureNodeVersion(context.
|
|
89
|
-
`cd ${context.
|
|
88
|
+
...ensureNodeVersion(context.build),
|
|
89
|
+
`cd ${context.build.dir}`,
|
|
90
90
|
...yarnInstall,
|
|
91
91
|
...(ensureArray(buildConfig.test?.command) ?? ["yarn test"]),
|
|
92
92
|
],
|
|
93
93
|
...createArtifactsConfig(
|
|
94
|
-
context.
|
|
94
|
+
context.build.dir,
|
|
95
95
|
buildConfig.test?.artifactsReports,
|
|
96
96
|
buildConfig.test?.artifacts,
|
|
97
97
|
),
|
package/src/build/rails/build.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { isOfBuildType } from "../types";
|
|
|
11
11
|
export const createRailsBuildJobs = (
|
|
12
12
|
context: ComponentContext,
|
|
13
13
|
): CatladderJob[] => {
|
|
14
|
-
const buildConfig = context.
|
|
14
|
+
const buildConfig = context.build.config;
|
|
15
15
|
if (!isOfBuildType(buildConfig, "rails")) {
|
|
16
16
|
// should not happen
|
|
17
17
|
throw new Error("build type is not rails");
|
|
@@ -37,12 +37,12 @@ export const createRailsBuildJobs = (
|
|
|
37
37
|
dockerBuild: {
|
|
38
38
|
variables: {
|
|
39
39
|
...context.environment.jobOnlyVars.build.envVars,
|
|
40
|
-
...context.
|
|
40
|
+
...context.build.config.extraVars,
|
|
41
41
|
},
|
|
42
42
|
// custom script
|
|
43
43
|
script: [
|
|
44
44
|
...gitlabDockerLogin(context),
|
|
45
|
-
`cd ${context.
|
|
45
|
+
`cd ${context.build.dir}`,
|
|
46
46
|
`docker pull $DOCKER_CACHE_IMAGE || true`,
|
|
47
47
|
`wget --output-document=- https://github.com/buildpacks/pack/releases/download/v${cnbConf?.packVersion}/pack-v${cnbConf?.packVersion}-linux.tgz | tar -zx --directory /usr/local/bin pack`,
|
|
48
48
|
`chmod +x /usr/local/bin/pack`,
|
package/src/build/rails/test.ts
CHANGED
|
@@ -11,7 +11,7 @@ export const createRailsTestJobs = (
|
|
|
11
11
|
return [];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const buildConfig = context.
|
|
14
|
+
const buildConfig = context.build.config;
|
|
15
15
|
|
|
16
16
|
const base: Omit<CatladderJob, "script" | "name"> = {
|
|
17
17
|
variables: {
|
|
@@ -45,7 +45,7 @@ export const createRailsTestJobs = (
|
|
|
45
45
|
image:
|
|
46
46
|
buildConfig.audit?.jobImage ?? buildConfig.jobImage ?? defaultImage,
|
|
47
47
|
script: [
|
|
48
|
-
`cd ${context.
|
|
48
|
+
`cd ${context.build.dir}`,
|
|
49
49
|
...(ensureArray(buildConfig.audit?.command) ?? [
|
|
50
50
|
"gem install bundler-audit",
|
|
51
51
|
"bundle audit check",
|
|
@@ -65,7 +65,7 @@ export const createRailsTestJobs = (
|
|
|
65
65
|
image:
|
|
66
66
|
buildConfig.lint?.jobImage ?? buildConfig.jobImage ?? defaultImage,
|
|
67
67
|
script: [
|
|
68
|
-
`cd ${context.
|
|
68
|
+
`cd ${context.build.dir}`,
|
|
69
69
|
...bundlerInstall,
|
|
70
70
|
...(ensureArray(buildConfig.lint?.command) ?? [
|
|
71
71
|
"bundle exec rubocop",
|
|
@@ -83,7 +83,7 @@ export const createRailsTestJobs = (
|
|
|
83
83
|
image:
|
|
84
84
|
buildConfig.test?.jobImage ?? buildConfig.jobImage ?? defaultImage,
|
|
85
85
|
script: [
|
|
86
|
-
`cd ${context.
|
|
86
|
+
`cd ${context.build.dir}`,
|
|
87
87
|
...bundlerInstall,
|
|
88
88
|
...(ensureArray(buildConfig.test?.command) ?? [
|
|
89
89
|
"bundle exec rspec",
|
package/src/build/sbom.ts
CHANGED
|
@@ -6,14 +6,14 @@ export const SBOM_BUILD_JOB_NAME = "🧾 sbom";
|
|
|
6
6
|
export const SBOM_FILE = "__sbom.json";
|
|
7
7
|
|
|
8
8
|
export const createSbomBuildJob = (context: ComponentContext): CatladderJob => {
|
|
9
|
-
const buildConfig = context.
|
|
9
|
+
const buildConfig = context.build.config;
|
|
10
10
|
|
|
11
11
|
const defaultImage = "aquasec/trivy:0.38.3";
|
|
12
12
|
const defaultScript = [
|
|
13
13
|
`trivy fs --quiet --format cyclonedx --output "${SBOM_FILE}" ${
|
|
14
|
-
context.
|
|
14
|
+
context.build.packageManagerInfo?.componentIsInWorkspace
|
|
15
15
|
? "."
|
|
16
|
-
: context.
|
|
16
|
+
: context.build.dir
|
|
17
17
|
}`,
|
|
18
18
|
];
|
|
19
19
|
|
package/src/context/getLabels.ts
CHANGED
|
@@ -14,7 +14,7 @@ export const getLabels = (context: ComponentContext) => {
|
|
|
14
14
|
"app-name": sanitize(context.fullConfig.appName),
|
|
15
15
|
"env-type": sanitize(context.environment.envType),
|
|
16
16
|
"env-name": sanitize(context.environment.shortName),
|
|
17
|
-
"build-type": sanitize(context.
|
|
17
|
+
"build-type": sanitize(context.build.config?.type),
|
|
18
18
|
...(context.fullConfig.meta?.labels ?? {}),
|
|
19
19
|
};
|
|
20
20
|
return labels;
|
package/src/context/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isFunction } from "lodash";
|
|
1
2
|
import { BUILD_TYPES } from "../build";
|
|
2
3
|
import type { BuildConfig, BuildConfigType } from "../build/types";
|
|
3
4
|
import { DEPLOY_TYPES } from "../deploy";
|
|
@@ -56,20 +57,35 @@ export const createComponentContext = async (
|
|
|
56
57
|
componentConfigWithoutDefaults,
|
|
57
58
|
);
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
const environment = await getEnvironment(ctx);
|
|
61
|
+
const { deploy, build, customJobs, dir } = componentConfig;
|
|
62
|
+
const context: Omit<ComponentContext, "customJobs"> = {
|
|
60
63
|
fullConfig: ctx.config,
|
|
61
64
|
componentConfig,
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
|
|
66
|
+
build: {
|
|
67
|
+
dir: dir,
|
|
64
68
|
packageManagerInfo: ctx.packageManagerInfo,
|
|
65
|
-
config:
|
|
69
|
+
config: build,
|
|
66
70
|
},
|
|
71
|
+
deploy: deploy
|
|
72
|
+
? {
|
|
73
|
+
config: deploy,
|
|
74
|
+
}
|
|
75
|
+
: null,
|
|
67
76
|
componentName: ctx.componentName,
|
|
68
|
-
environment
|
|
77
|
+
environment,
|
|
69
78
|
packageManagerInfo: ctx.packageManagerInfo,
|
|
70
79
|
pipelineType: ctx.pipelineType,
|
|
71
80
|
trigger: ctx.trigger,
|
|
72
81
|
};
|
|
82
|
+
const resolvedCustomJobs = isFunction(customJobs)
|
|
83
|
+
? customJobs(context)
|
|
84
|
+
: customJobs;
|
|
85
|
+
return {
|
|
86
|
+
...context,
|
|
87
|
+
customJobs: resolvedCustomJobs,
|
|
88
|
+
};
|
|
73
89
|
};
|
|
74
90
|
|
|
75
91
|
/**
|
|
@@ -37,11 +37,11 @@ export const createDeployJob = (
|
|
|
37
37
|
? "4 weeks"
|
|
38
38
|
: undefined;
|
|
39
39
|
|
|
40
|
+
const deployConfig = context.deploy?.config;
|
|
41
|
+
|
|
40
42
|
// if auto or manual is configured explicitly, use that
|
|
41
43
|
const whenDeployDefined =
|
|
42
|
-
|
|
43
|
-
? context.componentConfig.deploy.when
|
|
44
|
-
: undefined;
|
|
44
|
+
deployConfig && deployConfig.when ? deployConfig.when : undefined;
|
|
45
45
|
// otherwise auto deploy if env is not prod. If its prod, deploy automatically if stage is disabled
|
|
46
46
|
const whenDeployDefault =
|
|
47
47
|
context.environment.envType !== "prod"
|
|
@@ -64,8 +64,8 @@ export const createDeployJob = (
|
|
|
64
64
|
...(sbomDeactivated(context)
|
|
65
65
|
? []
|
|
66
66
|
: [{ job: SBOM_BUILD_JOB_NAME, artifacts: true }]),
|
|
67
|
-
...(
|
|
68
|
-
?
|
|
67
|
+
...(deployConfig
|
|
68
|
+
? deployConfig.waitFor?.map((c) => ({
|
|
69
69
|
componentName: c,
|
|
70
70
|
job: DEPLOY_JOB_NAME,
|
|
71
71
|
artifacts: false,
|
|
@@ -91,17 +91,13 @@ export const createDeployJob = (
|
|
|
91
91
|
...context.environment.envVars,
|
|
92
92
|
...(hasDocker ? getDockerImageVariables(context) : {}),
|
|
93
93
|
...context.environment.jobOnlyVars.deploy.envVars,
|
|
94
|
-
...(
|
|
95
|
-
? context.componentConfig.deploy.extraVars ?? {}
|
|
96
|
-
: {}),
|
|
94
|
+
...(deployConfig ? deployConfig.extraVars ?? {} : {}),
|
|
97
95
|
...jobDefinition.variables,
|
|
98
96
|
},
|
|
99
97
|
runnerVariables: {
|
|
100
98
|
...DEPLOY_RUNNER_VARIABLES,
|
|
101
99
|
...(jobDefinition.runnerVariables ?? {}),
|
|
102
|
-
...(
|
|
103
|
-
? context.componentConfig.deploy.runnerVariables ?? {}
|
|
104
|
-
: {}),
|
|
100
|
+
...(deployConfig ? deployConfig.runnerVariables ?? {} : {}),
|
|
105
101
|
},
|
|
106
102
|
environment: isStoppable
|
|
107
103
|
? {
|
|
@@ -109,8 +105,6 @@ export const createDeployJob = (
|
|
|
109
105
|
auto_stop_in: autoStop,
|
|
110
106
|
}
|
|
111
107
|
: undefined,
|
|
112
|
-
jobTags:
|
|
113
|
-
? context.componentConfig.deploy.jobTags
|
|
114
|
-
: undefined,
|
|
108
|
+
jobTags: deployConfig ? deployConfig.jobTags : undefined,
|
|
115
109
|
};
|
|
116
110
|
};
|
|
@@ -5,18 +5,16 @@ import { allowFailureInScripts } from "../../utils/gitlab";
|
|
|
5
5
|
import { isOfDeployType } from "../types";
|
|
6
6
|
import { removeFirstLinesFromCommandOutput } from "./utils/removeFirstLinesFromCommandOutput";
|
|
7
7
|
|
|
8
|
-
export const getArtifactsRegistryHost = ({
|
|
9
|
-
|
|
10
|
-
}: ComponentContext) => {
|
|
11
|
-
if (!isOfDeployType(deploy, "google-cloudrun")) {
|
|
8
|
+
export const getArtifactsRegistryHost = (context: ComponentContext) => {
|
|
9
|
+
if (!isOfDeployType(context.deploy?.config, "google-cloudrun")) {
|
|
12
10
|
// should not happen
|
|
13
11
|
throw new Error("deploy config is wrong");
|
|
14
12
|
}
|
|
15
|
-
return `${deploy.region}-docker.pkg.dev`;
|
|
13
|
+
return `${context.deploy.config.region}-docker.pkg.dev`;
|
|
16
14
|
};
|
|
17
15
|
|
|
18
16
|
export const getArtifactsRegistryDockerUrl = (context: ComponentContext) => {
|
|
19
|
-
const deployConfig = context.
|
|
17
|
+
const deployConfig = context.deploy?.config;
|
|
20
18
|
|
|
21
19
|
if (!isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
22
20
|
// should not happen
|
|
@@ -102,10 +100,7 @@ export const getDeleteUnusedImagesCommands = (
|
|
|
102
100
|
context: ComponentContext,
|
|
103
101
|
keep = 0,
|
|
104
102
|
) => {
|
|
105
|
-
const deployConfig = context.
|
|
106
|
-
if (deployConfig === false) {
|
|
107
|
-
return [];
|
|
108
|
-
}
|
|
103
|
+
const deployConfig = context.deploy?.config;
|
|
109
104
|
if (!isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
110
105
|
// should not happen
|
|
111
106
|
throw new Error("deploy config is wrong");
|
|
@@ -12,7 +12,8 @@ const getListRevisionsCommand = (
|
|
|
12
12
|
},
|
|
13
13
|
) => {
|
|
14
14
|
const serviceName = getServiceName(context);
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
const deployConfig = context.deploy?.config;
|
|
16
17
|
|
|
17
18
|
if (!deployConfig || !isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
18
19
|
// should not happen
|
|
@@ -37,10 +38,7 @@ export const getDeleteUnusedRevisionsCommands = (
|
|
|
37
38
|
context: ComponentContext,
|
|
38
39
|
keep: number,
|
|
39
40
|
) => {
|
|
40
|
-
const deployConfig = context.
|
|
41
|
-
if (deployConfig === false) {
|
|
42
|
-
return [];
|
|
43
|
-
}
|
|
41
|
+
const deployConfig = context.deploy?.config;
|
|
44
42
|
if (!isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
45
43
|
// should not happen
|
|
46
44
|
throw new Error("deploy config is wrong");
|
|
@@ -25,7 +25,7 @@ export const getServiceDeployScript = (
|
|
|
25
25
|
const customConfig = service !== true ? service : undefined;
|
|
26
26
|
const command =
|
|
27
27
|
service !== true
|
|
28
|
-
? service?.command ?? context.
|
|
28
|
+
? service?.command ?? context.build.config.startCommand
|
|
29
29
|
: undefined;
|
|
30
30
|
|
|
31
31
|
const commandArray = command
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Context } from "../../../types/context";
|
|
2
2
|
|
|
3
3
|
import { isOfDeployType } from "../../types";
|
|
4
4
|
import type { DeployConfigCloudRun } from "../../types/googleCloudRun";
|
|
@@ -29,8 +29,8 @@ export const makeLabelString = (obj: Record<string, unknown>) =>
|
|
|
29
29
|
.map(([key, value]) => `${key}=${value}`)
|
|
30
30
|
.join(",");
|
|
31
31
|
|
|
32
|
-
export const getCloudRunDeployConfig = (context:
|
|
33
|
-
const deployConfig = context.
|
|
32
|
+
export const getCloudRunDeployConfig = (context: Context) => {
|
|
33
|
+
const deployConfig = context.deploy?.config;
|
|
34
34
|
if (!isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
35
35
|
// should not happen
|
|
36
36
|
throw new Error("deploy config is wrong");
|
|
@@ -38,7 +38,7 @@ export const getCloudRunDeployConfig = (context: ComponentContext) => {
|
|
|
38
38
|
return deployConfig;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
export function getCommonCloudRunArgs(context:
|
|
41
|
+
export function getCommonCloudRunArgs(context: Context) {
|
|
42
42
|
const deployConfig = getCloudRunDeployConfig(context);
|
|
43
43
|
return {
|
|
44
44
|
project: deployConfig.projectId,
|
|
@@ -46,7 +46,7 @@ export function getCommonCloudRunArgs(context: ComponentContext) {
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export function getCommonDeployArgs(context:
|
|
49
|
+
export function getCommonDeployArgs(context: Context) {
|
|
50
50
|
const commonArgs = getCommonCloudRunArgs(context);
|
|
51
51
|
const deployConfig = getCloudRunDeployConfig(context);
|
|
52
52
|
return {
|
|
@@ -12,10 +12,7 @@ import { getCloudRunStopScripts } from "./getCloudRunStopScripts";
|
|
|
12
12
|
export const createGoogleCloudRunDeployJobs = (
|
|
13
13
|
context: ComponentContext,
|
|
14
14
|
): CatladderJob[] => {
|
|
15
|
-
const deployConfig = context.
|
|
16
|
-
if (deployConfig === false) {
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
15
|
+
const deployConfig = context.deploy?.config;
|
|
19
16
|
if (!isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
20
17
|
// should not happen
|
|
21
18
|
throw new Error("deploy config is wrong");
|
|
@@ -12,16 +12,14 @@ import { isOfDeployType } from "../types";
|
|
|
12
12
|
export const createCustomDeployJobs = (
|
|
13
13
|
context: ComponentContext,
|
|
14
14
|
): CatladderJob[] => {
|
|
15
|
-
const deployConfig = context.
|
|
16
|
-
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
15
|
+
const deployConfig = context.deploy?.config;
|
|
16
|
+
|
|
19
17
|
if (!isOfDeployType(deployConfig, "custom")) {
|
|
20
18
|
// should not happen
|
|
21
19
|
throw new Error("deploy config is not custom");
|
|
22
20
|
}
|
|
23
21
|
// FIXME: custom deploy currently assumes yarn-based project
|
|
24
|
-
const yarnInstall = getYarnInstall(context.
|
|
22
|
+
const yarnInstall = getYarnInstall(context.build, {
|
|
25
23
|
noCustomPostInstall: true,
|
|
26
24
|
});
|
|
27
25
|
return createDeployementJobs(context, {
|
|
@@ -29,7 +27,7 @@ export const createCustomDeployJobs = (
|
|
|
29
27
|
image: deployConfig.jobImage ?? getRunnerImage("jobs-default"),
|
|
30
28
|
cache: deployConfig.jobCache ?? [],
|
|
31
29
|
script: [
|
|
32
|
-
`cd ${context.
|
|
30
|
+
`cd ${context.build.dir}`,
|
|
33
31
|
...(deployConfig.requiresYarnInstall ? yarnInstall : []),
|
|
34
32
|
...deployConfig.script,
|
|
35
33
|
...getDependencyTrackUploadScript(context),
|