@catladder/pipeline 0.0.0-refactor-docker-427f63d6 → 0.0.0-refactor-docker-c24f8608
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 +2 -2
- package/dist/build/base/createAppBuildJob.js +1 -1
- package/dist/build/base/index.d.ts +2 -2
- package/dist/build/base/writeBuildInfo.d.ts +2 -2
- package/dist/build/base/writeDotEnv.d.ts +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 +11 -11
- package/dist/build/docker.js +6 -6
- package/dist/build/index.d.ts +2 -2
- package/dist/build/node/buildJob.d.ts +2 -2
- package/dist/build/node/buildJob.js +6 -6
- package/dist/build/node/cache.d.ts +5 -5
- package/dist/build/node/cache.js +4 -4
- package/dist/build/node/index.d.ts +4 -4
- package/dist/build/node/meteor.d.ts +2 -2
- package/dist/build/node/meteor.js +2 -2
- package/dist/build/node/testJob.d.ts +2 -2
- package/dist/build/node/testJob.js +6 -6
- package/dist/build/node/yarn.d.ts +4 -4
- 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/rails/test.d.ts +2 -2
- package/dist/build/sbom.d.ts +2 -2
- package/dist/build/sbom.js +1 -1
- package/dist/bundles/catladder-gitlab/index.js +42 -33
- package/dist/constants.js +1 -1
- package/dist/context/getEnvironment.d.ts +2 -2
- package/dist/context/getEnvironmentContext.d.ts +2 -2
- package/dist/context/getEnvironmentVariables.d.ts +4 -4
- package/dist/context/getLabels.d.ts +2 -2
- package/dist/context/index.d.ts +7 -3
- package/dist/context/index.js +12 -3
- package/dist/deploy/base/deploy.d.ts +2 -2
- package/dist/deploy/base/index.d.ts +2 -2
- package/dist/deploy/base/rollback.d.ts +2 -2
- package/dist/deploy/base/stop.d.ts +2 -2
- package/dist/deploy/cloudRun/artifactsRegistry.d.ts +7 -7
- package/dist/deploy/cloudRun/cleanup.d.ts +2 -2
- package/dist/deploy/cloudRun/cloudRunRevisions.d.ts +2 -2
- package/dist/deploy/cloudRun/createJobs/cloudRunJobs.d.ts +6 -6
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.d.ts +3 -3
- package/dist/deploy/cloudRun/createJobs/common.d.ts +4 -4
- package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.d.ts +2 -2
- package/dist/deploy/cloudRun/createJobs/getCloudRunStopScripts.d.ts +2 -2
- package/dist/deploy/cloudRun/createJobs/index.d.ts +2 -2
- package/dist/deploy/cloudRun/utils/database.d.ts +3 -3
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.d.ts +2 -2
- package/dist/deploy/cloudRun/utils/getServiceName.d.ts +2 -2
- package/dist/deploy/custom/deployJob.d.ts +2 -2
- package/dist/deploy/custom/deployJob.js +1 -1
- package/dist/deploy/dockerTag/deployJob.d.ts +2 -2
- package/dist/deploy/index.d.ts +2 -2
- package/dist/deploy/kubernetes/cloudSql/index.d.ts +3 -3
- package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
- package/dist/deploy/kubernetes/kubeEnv.d.ts +2 -2
- package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
- package/dist/deploy/kubernetes/mongodb.d.ts +2 -2
- package/dist/deploy/sbom.d.ts +4 -4
- package/dist/deploy/utils.d.ts +2 -2
- package/dist/pipeline/createJobsForComponent.d.ts +2 -2
- package/dist/pipeline/createJobsForComponent.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +2 -2
- package/dist/types/context.d.ts +16 -2
- package/package.json +1 -1
- package/src/build/base/createAppBuildJob.ts +3 -3
- package/src/build/base/index.ts +2 -2
- package/src/build/base/writeBuildInfo.ts +2 -2
- package/src/build/base/writeDotEnv.ts +2 -2
- package/src/build/custom/__tests__/testJob.test.ts +5 -5
- package/src/build/custom/buildJob.ts +4 -2
- package/src/build/custom/index.ts +2 -2
- package/src/build/custom/testJob.ts +4 -2
- package/src/build/docker.ts +18 -18
- package/src/build/index.ts +2 -2
- package/src/build/node/buildJob.ts +13 -9
- package/src/build/node/cache.ts +9 -9
- package/src/build/node/index.ts +6 -4
- package/src/build/node/meteor.ts +10 -5
- package/src/build/node/testJob.ts +11 -8
- package/src/build/node/yarn.ts +6 -8
- package/src/build/rails/build.ts +4 -2
- package/src/build/rails/index.ts +2 -2
- package/src/build/rails/test.ts +4 -2
- package/src/build/sbom.ts +4 -4
- package/src/context/getEnvironment.ts +2 -2
- package/src/context/getEnvironmentContext.ts +2 -2
- package/src/context/getEnvironmentVariables.ts +7 -4
- package/src/context/getLabels.ts +2 -2
- package/src/context/index.ts +15 -5
- package/src/deploy/base/deploy.ts +2 -2
- package/src/deploy/base/index.ts +2 -2
- package/src/deploy/base/rollback.ts +2 -2
- package/src/deploy/base/stop.ts +2 -2
- package/src/deploy/cloudRun/artifactsRegistry.ts +12 -7
- package/src/deploy/cloudRun/cleanup.ts +2 -2
- package/src/deploy/cloudRun/cloudRunRevisions.ts +3 -3
- package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +10 -10
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +3 -3
- package/src/deploy/cloudRun/createJobs/common.ts +4 -4
- package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +5 -2
- package/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.ts +2 -2
- package/src/deploy/cloudRun/createJobs/index.ts +2 -2
- package/src/deploy/cloudRun/utils/database.ts +3 -3
- package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +4 -2
- package/src/deploy/cloudRun/utils/getServiceName.ts +2 -2
- package/src/deploy/custom/deployJob.ts +7 -3
- package/src/deploy/dockerTag/deployJob.ts +4 -2
- package/src/deploy/index.ts +2 -2
- package/src/deploy/kubernetes/cloudSql/index.ts +3 -3
- package/src/deploy/kubernetes/deployJob.ts +2 -2
- package/src/deploy/kubernetes/kubeEnv.ts +2 -2
- package/src/deploy/kubernetes/kubeValues.ts +3 -3
- package/src/deploy/kubernetes/mongodb.ts +8 -8
- package/src/deploy/sbom.ts +8 -4
- package/src/deploy/utils.ts +2 -2
- package/src/pipeline/createJobsForComponent.ts +11 -7
- package/src/pipeline/gitlab/createGitlabJobs.ts +2 -2
- package/src/types/config.ts +2 -2
- package/src/types/context.ts +18 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isNil } from "lodash";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComponentContext } from "../../types";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* writes a .env file in the components folder
|
|
6
6
|
* @param context
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
export const writeDotEnv = (context:
|
|
9
|
+
export const writeDotEnv = (context: ComponentContext) => {
|
|
10
10
|
const envVars = context.environment.envVars;
|
|
11
11
|
|
|
12
12
|
// make key=value and sanitize multiline
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../..";
|
|
2
2
|
import { createCustomTestJobs } from "../testJob";
|
|
3
3
|
|
|
4
4
|
describe("createCustomTestJobs", () => {
|
|
5
|
-
const componentConfig:
|
|
5
|
+
const componentConfig: ComponentContext["componentConfig"] = {
|
|
6
6
|
dir: ".",
|
|
7
7
|
build: { type: "custom", docker: { type: "custom" }, jobImage: "" },
|
|
8
8
|
deploy: {},
|
|
9
|
-
} as
|
|
10
|
-
const baseContext:
|
|
9
|
+
} as ComponentContext["componentConfig"];
|
|
10
|
+
const baseContext: ComponentContext = {
|
|
11
11
|
componentName: "testComponent",
|
|
12
12
|
environment: {
|
|
13
13
|
jobOnlyVars: {
|
|
@@ -15,7 +15,7 @@ describe("createCustomTestJobs", () => {
|
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
componentConfig,
|
|
18
|
-
} as
|
|
18
|
+
} as ComponentContext;
|
|
19
19
|
|
|
20
20
|
it("throws error when not build type custom", () => {
|
|
21
21
|
componentConfig.build.type = "node";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComponentContext } from "../../types/context";
|
|
3
3
|
import { ensureArray } from "../../utils";
|
|
4
4
|
import { getDockerBuildScriptWithBuiltInDockerFile } from "../docker";
|
|
5
5
|
import { isOfBuildType } from "../types";
|
|
@@ -13,7 +13,9 @@ const RUNNER_BUILD_VARIABLES = {
|
|
|
13
13
|
KUBERNETES_MEMORY_LIMIT: "4Gi",
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export const createCustomBuildJobs = (
|
|
16
|
+
export const createCustomBuildJobs = (
|
|
17
|
+
context: ComponentContext,
|
|
18
|
+
): CatladderJob[] => {
|
|
17
19
|
const buildConfig = context.componentConfig.build;
|
|
18
20
|
|
|
19
21
|
if (!isOfBuildType(buildConfig, "custom")) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../types/context";
|
|
2
2
|
import type { CatladderJob } from "../../types/jobs";
|
|
3
3
|
import { createCustomBuildJobs } from "./buildJob";
|
|
4
4
|
import { createCustomTestJobs } from "./testJob";
|
|
5
5
|
|
|
6
|
-
export const createCustomJobs = (context:
|
|
6
|
+
export const createCustomJobs = (context: ComponentContext): CatladderJob[] => {
|
|
7
7
|
return [...createCustomTestJobs(context), ...createCustomBuildJobs(context)];
|
|
8
8
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../types/context";
|
|
2
2
|
import type { CatladderJob } from "../../types/jobs";
|
|
3
3
|
import { ensureArray, notNil } from "../../utils";
|
|
4
4
|
import { isOfBuildType } from "../types";
|
|
@@ -11,7 +11,9 @@ const RUNNER_CUSTOM_TEST_VARIABLES = {
|
|
|
11
11
|
KUBERNETES_MEMORY_LIMIT: "4Gi",
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export const createCustomTestJobs = (
|
|
14
|
+
export const createCustomTestJobs = (
|
|
15
|
+
context: ComponentContext,
|
|
16
|
+
): CatladderJob[] => {
|
|
15
17
|
// don't run tests after release
|
|
16
18
|
// TODO: this will be replaced by using rules
|
|
17
19
|
if (context.trigger === "taggedRelease") {
|
package/src/build/docker.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { merge } from "lodash";
|
|
2
|
-
import { isOfDeployType } from "../deploy";
|
|
3
|
-
import { getRunnerImage } from "../runner";
|
|
4
|
-
import type { Context } from "../types";
|
|
5
|
-
import type { CatladderJob } from "../types/jobs";
|
|
6
1
|
import { existsSync } from "fs";
|
|
2
|
+
import { merge } from "lodash";
|
|
7
3
|
import path from "path";
|
|
8
|
-
import {
|
|
4
|
+
import type { BuildConfig, BuildConfigDocker } from ".";
|
|
5
|
+
import { isOfDeployType } from "../deploy";
|
|
9
6
|
import {
|
|
10
7
|
getArtifactsRegistryBuildCacheImage,
|
|
11
8
|
getArtifactsRegistryHost,
|
|
12
9
|
getArtifactsRegistryImageName,
|
|
13
10
|
} from "../deploy/cloudRun/artifactsRegistry";
|
|
14
11
|
import { gcloudServiceAccountLoginCommands } from "../deploy/cloudRun/utils/gcloudServiceAccountLoginCommands";
|
|
15
|
-
import
|
|
12
|
+
import { getRunnerImage } from "../runner";
|
|
13
|
+
import type { ComponentContext } from "../types";
|
|
14
|
+
import type { CatladderJob } from "../types/jobs";
|
|
15
|
+
import { collapseableSection } from "../utils/gitlab";
|
|
16
16
|
|
|
17
17
|
const DOCKER_BUILD_RUNNER_REQUESTS = {
|
|
18
18
|
KUBERNETES_CPU_REQUEST: "0.5",
|
|
@@ -20,7 +20,7 @@ const DOCKER_BUILD_RUNNER_REQUESTS = {
|
|
|
20
20
|
KUBERNETES_MEMORY_LIMIT: "2Gi",
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
export const getDockerImageVariables = (context:
|
|
23
|
+
export const getDockerImageVariables = (context: ComponentContext) => {
|
|
24
24
|
return {
|
|
25
25
|
...(isOfDeployType(context.componentConfig.deploy, "google-cloudrun")
|
|
26
26
|
? {
|
|
@@ -49,7 +49,7 @@ export const getDockerImageVariables = (context: Context) => {
|
|
|
49
49
|
*/
|
|
50
50
|
export const requiresDockerBuild = ({
|
|
51
51
|
componentConfig: { deploy },
|
|
52
|
-
}:
|
|
52
|
+
}: ComponentContext): boolean =>
|
|
53
53
|
isOfDeployType(deploy, "kubernetes", "google-cloudrun", "dockerTag") ||
|
|
54
54
|
(isOfDeployType(deploy, "custom") && deploy.requiresDocker);
|
|
55
55
|
|
|
@@ -76,10 +76,10 @@ const getDockerAdditions = (build: BuildConfig) => {
|
|
|
76
76
|
: undefined,
|
|
77
77
|
};
|
|
78
78
|
};
|
|
79
|
-
export const getDockerBuildVariables = (context:
|
|
79
|
+
export const getDockerBuildVariables = (context: ComponentContext) => {
|
|
80
80
|
return {
|
|
81
|
-
...getDockerAdditions(context.
|
|
82
|
-
APP_DIR: context.
|
|
81
|
+
...getDockerAdditions(context.buildContext.config),
|
|
82
|
+
APP_DIR: context.buildContext.dir,
|
|
83
83
|
DOCKER_DIR: ".", // relative to componentdir
|
|
84
84
|
|
|
85
85
|
...getDockerImageVariables(context),
|
|
@@ -89,7 +89,7 @@ export const getDockerBuildVariables = (context: Context) => {
|
|
|
89
89
|
export const DOCKER_BUILD_JOB_NAME = "🔨 docker";
|
|
90
90
|
|
|
91
91
|
export const getDockerJobBaseProps = (
|
|
92
|
-
context:
|
|
92
|
+
context: ComponentContext,
|
|
93
93
|
): Pick<
|
|
94
94
|
CatladderJob,
|
|
95
95
|
"image" | "services" | "variables" | "runnerVariables"
|
|
@@ -109,7 +109,7 @@ export const getDockerJobBaseProps = (
|
|
|
109
109
|
|
|
110
110
|
export type DockerBuildJobDefinition = Partial<CatladderJob>;
|
|
111
111
|
export const createDockerBuildJobBase = (
|
|
112
|
-
context:
|
|
112
|
+
context: ComponentContext,
|
|
113
113
|
{ script, ...def }: Partial<CatladderJob>,
|
|
114
114
|
): CatladderJob => {
|
|
115
115
|
return merge(
|
|
@@ -131,7 +131,7 @@ export const createDockerBuildJobBase = (
|
|
|
131
131
|
);
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
-
export const gitlabDockerLogin = (context:
|
|
134
|
+
export const gitlabDockerLogin = (context: ComponentContext) =>
|
|
135
135
|
isOfDeployType(context.componentConfig.deploy, "google-cloudrun")
|
|
136
136
|
? [
|
|
137
137
|
...gcloudServiceAccountLoginCommands(context),
|
|
@@ -151,7 +151,7 @@ const BUILT_IN_ENSURE_DOCKERFILE_SCRIPTS = {
|
|
|
151
151
|
};
|
|
152
152
|
|
|
153
153
|
export const getDockerBuildScriptWithBuiltInDockerFile = (
|
|
154
|
-
context:
|
|
154
|
+
context: ComponentContext,
|
|
155
155
|
defaultType?: BuildConfigDocker["type"],
|
|
156
156
|
) => {
|
|
157
157
|
const type =
|
|
@@ -166,7 +166,7 @@ export const getDockerBuildScriptWithBuiltInDockerFile = (
|
|
|
166
166
|
);
|
|
167
167
|
};
|
|
168
168
|
export const getDockerBuildDefaultScript = (
|
|
169
|
-
context:
|
|
169
|
+
context: ComponentContext,
|
|
170
170
|
ensureDockerFileScript?: string | null,
|
|
171
171
|
) =>
|
|
172
172
|
[
|
|
@@ -191,5 +191,5 @@ export const getDockerBuildDefaultScript = (
|
|
|
191
191
|
]),
|
|
192
192
|
].filter(Boolean);
|
|
193
193
|
|
|
194
|
-
export const hasDockerfile = (context:
|
|
194
|
+
export const hasDockerfile = (context: ComponentContext) =>
|
|
195
195
|
existsSync(path.join(context.componentConfig.dir, "Dockerfile"));
|
package/src/build/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../types/context";
|
|
2
2
|
import type { EnvironmentContext } from "../types/environmentContext";
|
|
3
3
|
|
|
4
4
|
import type { CatladderJob } from "../types/jobs";
|
|
@@ -12,7 +12,7 @@ export * from "./node";
|
|
|
12
12
|
|
|
13
13
|
export type BuildTypes = {
|
|
14
14
|
[type in BuildConfigType]: {
|
|
15
|
-
jobs: (context:
|
|
15
|
+
jobs: (context: ComponentContext) => CatladderJob[];
|
|
16
16
|
defaults: (
|
|
17
17
|
envContext: EnvironmentContext<BuildConfigType, any>,
|
|
18
18
|
) => Partial<Extract<BuildConfig, { type: type }>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
2
|
import { getRunnerImage } from "../../runner";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../types/context";
|
|
4
4
|
import type { CatladderJob } from "../../types/jobs";
|
|
5
5
|
import { ensureArray } from "../../utils";
|
|
6
6
|
import { createBuildJobs } from "../base";
|
|
@@ -10,7 +10,9 @@ import { getNextCache, getNodeCache, getYarnCache } from "./cache";
|
|
|
10
10
|
import { NODE_RUNNER_BUILD_VARIABLES } from "./constants";
|
|
11
11
|
import { getDockerAppCopyAndBuildScript, getYarnInstall } from "./yarn";
|
|
12
12
|
|
|
13
|
-
export const createNodeBuildJobs = (
|
|
13
|
+
export const createNodeBuildJobs = (
|
|
14
|
+
context: ComponentContext,
|
|
15
|
+
): CatladderJob[] => {
|
|
14
16
|
const buildConfig = context.componentConfig.build;
|
|
15
17
|
|
|
16
18
|
if (!isOfBuildType(buildConfig, "node", "node-static", "storybook")) {
|
|
@@ -18,7 +20,7 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
|
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
const defaultImage = getRunnerImage("jobs-default");
|
|
21
|
-
const yarnInstall = getYarnInstall(context);
|
|
23
|
+
const yarnInstall = getYarnInstall(context.buildContext);
|
|
22
24
|
|
|
23
25
|
return createBuildJobs(context, {
|
|
24
26
|
appBuild:
|
|
@@ -28,7 +30,7 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
|
|
|
28
30
|
runnerVariables: NODE_RUNNER_BUILD_VARIABLES,
|
|
29
31
|
cache: [
|
|
30
32
|
...(ensureArray(buildConfig.jobCache) ?? []),
|
|
31
|
-
...getNodeCache(context),
|
|
33
|
+
...getNodeCache(context.buildContext),
|
|
32
34
|
...getNextCache(context),
|
|
33
35
|
],
|
|
34
36
|
script: [
|
|
@@ -39,8 +41,8 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
|
|
|
39
41
|
paths: [
|
|
40
42
|
context.componentConfig.dir,
|
|
41
43
|
// also copy workspace dependencies in monorepo if packages are shared and they create build artifacts
|
|
42
|
-
...(context.packageManagerInfo
|
|
43
|
-
[]),
|
|
44
|
+
...(context.buildContext.packageManagerInfo
|
|
45
|
+
?.currentWorkspaceDependencies ?? []),
|
|
44
46
|
].flatMap((dir) => [
|
|
45
47
|
join(dir, "__build_info.json"),
|
|
46
48
|
join(dir, "dist"),
|
|
@@ -63,12 +65,14 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
|
|
|
63
65
|
? "nginx"
|
|
64
66
|
: "node",
|
|
65
67
|
),
|
|
66
|
-
cache: [...getYarnCache(context, "pull")],
|
|
68
|
+
cache: [...getYarnCache(context.buildContext, "pull")],
|
|
67
69
|
variables: {
|
|
68
70
|
// only required for non static
|
|
69
|
-
DOCKER_COPY_AND_INSTALL_APP: getDockerAppCopyAndBuildScript(
|
|
71
|
+
DOCKER_COPY_AND_INSTALL_APP: getDockerAppCopyAndBuildScript(
|
|
72
|
+
context.buildContext,
|
|
73
|
+
),
|
|
70
74
|
DOCKER_COPY_WORKSPACE_FILES:
|
|
71
|
-
context.packageManagerInfo?.pathsToCopyInDocker
|
|
75
|
+
context.buildContext.packageManagerInfo?.pathsToCopyInDocker
|
|
72
76
|
.map((dir) => `COPY --chown=node:node ${dir} /app/${dir}`)
|
|
73
77
|
?.join("\n"),
|
|
74
78
|
},
|
package/src/build/node/cache.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
2
|
import slugify from "slugify";
|
|
3
|
-
import type {
|
|
3
|
+
import type { BuildContext, ComponentContext } from "../../types/context";
|
|
4
4
|
import type { GitlabJobCache } from "../../types/gitlab-types";
|
|
5
5
|
import { uniq } from "lodash";
|
|
6
6
|
|
|
7
7
|
export const getYarnCache = (
|
|
8
|
-
context:
|
|
8
|
+
context: BuildContext,
|
|
9
9
|
policy = "pull-push",
|
|
10
10
|
): GitlabJobCache[] => {
|
|
11
11
|
const componentIsInWorkspace =
|
|
@@ -18,15 +18,15 @@ export const getYarnCache = (
|
|
|
18
18
|
paths: [".yarn"],
|
|
19
19
|
}
|
|
20
20
|
: {
|
|
21
|
-
key: slugify(context.
|
|
21
|
+
key: slugify(context.dir) + "-yarn",
|
|
22
22
|
policy,
|
|
23
|
-
paths: [join(context.
|
|
23
|
+
paths: [join(context.dir, ".yarn")],
|
|
24
24
|
},
|
|
25
25
|
];
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
export const getNodeModulesCache = (
|
|
29
|
-
context:
|
|
29
|
+
context: BuildContext,
|
|
30
30
|
policy = "pull-push",
|
|
31
31
|
): GitlabJobCache[] => {
|
|
32
32
|
const componentIsInWorkspace =
|
|
@@ -39,7 +39,7 @@ export const getNodeModulesCache = (
|
|
|
39
39
|
// if component is in a shared workspace, use workspace cache. use individual cache else
|
|
40
40
|
key: componentIsInWorkspace
|
|
41
41
|
? "node-modules-workspace"
|
|
42
|
-
: slugify(context.
|
|
42
|
+
: slugify(context.dir) + "-node-modules", // we use the dirname, not the component name, because in certain cases we have two apps in the same directory and want to share the cache, e.g. when having storybook in the same package.json
|
|
43
43
|
policy,
|
|
44
44
|
paths: [
|
|
45
45
|
...(componentIsInWorkspace
|
|
@@ -49,13 +49,13 @@ export const getNodeModulesCache = (
|
|
|
49
49
|
join(w.location, "node_modules"),
|
|
50
50
|
) ?? []),
|
|
51
51
|
])
|
|
52
|
-
: [join(context.
|
|
52
|
+
: [join(context.dir, "node_modules")]),
|
|
53
53
|
],
|
|
54
54
|
},
|
|
55
55
|
];
|
|
56
56
|
};
|
|
57
57
|
export const getNodeCache = (
|
|
58
|
-
context:
|
|
58
|
+
context: BuildContext,
|
|
59
59
|
policy = "pull-push",
|
|
60
60
|
): GitlabJobCache[] => {
|
|
61
61
|
return [
|
|
@@ -64,7 +64,7 @@ export const getNodeCache = (
|
|
|
64
64
|
];
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
export const getNextCache = (context:
|
|
67
|
+
export const getNextCache = (context: ComponentContext): GitlabJobCache[] => [
|
|
68
68
|
{
|
|
69
69
|
key: context.componentName + "-next-cache",
|
|
70
70
|
policy: "pull-push",
|
package/src/build/node/index.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../types/context";
|
|
2
2
|
import type { CatladderJob } from "../../types/jobs";
|
|
3
3
|
import { createNodeBuildJobs } from "./buildJob";
|
|
4
4
|
import { createMeteorBuildJobs } from "./meteor";
|
|
5
5
|
import { createNodeTestJobs } from "./testJob";
|
|
6
6
|
|
|
7
|
-
export const createNodeJobs = (context:
|
|
7
|
+
export const createNodeJobs = (context: ComponentContext): CatladderJob[] => {
|
|
8
8
|
return [...createNodeTestJobs(context), ...createNodeBuildJobs(context)];
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export const createStorybookJobs = (
|
|
11
|
+
export const createStorybookJobs = (
|
|
12
|
+
context: ComponentContext,
|
|
13
|
+
): CatladderJob[] => {
|
|
12
14
|
return [...createNodeBuildJobs(context)];
|
|
13
15
|
};
|
|
14
16
|
|
|
15
|
-
export const createMeteorJobs = (context:
|
|
17
|
+
export const createMeteorJobs = (context: ComponentContext): CatladderJob[] => {
|
|
16
18
|
return [...createNodeTestJobs(context), ...createMeteorBuildJobs(context)];
|
|
17
19
|
};
|
package/src/build/node/meteor.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
2
|
import { getRunnerImage } from "../../runner";
|
|
3
3
|
import type { GitlabJobCache } from "../../types";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ComponentContext } from "../../types/context";
|
|
5
5
|
|
|
6
6
|
import type { CatladderJob } from "../../types/jobs";
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ import { isOfBuildType } from "../types";
|
|
|
11
11
|
import { getNodeCache } from "./cache";
|
|
12
12
|
import { getYarnInstall } from "./yarn";
|
|
13
13
|
|
|
14
|
-
const getMeteorCache = (context:
|
|
14
|
+
const getMeteorCache = (context: ComponentContext): GitlabJobCache[] => [
|
|
15
15
|
{
|
|
16
16
|
key: context.componentName + "meteor-build-cache",
|
|
17
17
|
policy: "pull-push",
|
|
@@ -26,20 +26,25 @@ const getMeteorCache = (context: Context): GitlabJobCache[] => [
|
|
|
26
26
|
],
|
|
27
27
|
},
|
|
28
28
|
];
|
|
29
|
-
export const createMeteorBuildJobs = (
|
|
29
|
+
export const createMeteorBuildJobs = (
|
|
30
|
+
context: ComponentContext,
|
|
31
|
+
): CatladderJob[] => {
|
|
30
32
|
const buildConfig = context.componentConfig.build;
|
|
31
33
|
|
|
32
34
|
if (!isOfBuildType(buildConfig, "meteor")) {
|
|
33
35
|
throw new Error("deploy config is not meteor");
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
const yarnInstall = getYarnInstall(context);
|
|
38
|
+
const yarnInstall = getYarnInstall(context.buildContext);
|
|
37
39
|
|
|
38
40
|
return createBuildJobs(context, {
|
|
39
41
|
appBuild:
|
|
40
42
|
buildConfig.buildCommand !== null
|
|
41
43
|
? {
|
|
42
|
-
cache: [
|
|
44
|
+
cache: [
|
|
45
|
+
...getNodeCache(context.buildContext),
|
|
46
|
+
...getMeteorCache(context),
|
|
47
|
+
],
|
|
43
48
|
image: getRunnerImage("jobs-meteor"),
|
|
44
49
|
variables: {
|
|
45
50
|
METEOR_DISABLE_OPTIMISTIC_CACHING: "1", // see https://forums.meteor.com/t/veeery-long-building-time-inside-docker-container/58673/17?u=macrozone
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getRunnerImage } from "../../runner";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComponentContext } from "../../types/context";
|
|
3
3
|
import type { CatladderJob } from "../../types/jobs";
|
|
4
4
|
import { ensureArray, notNil } from "../../utils";
|
|
5
5
|
import { getNodeCache } from "./cache";
|
|
@@ -7,7 +7,9 @@ import { NODE_RUNNER_BUILD_VARIABLES } from "./constants";
|
|
|
7
7
|
import { ensureNodeVersion, getYarnInstall } from "./yarn";
|
|
8
8
|
import { createArtifactsConfig } from "../base/createArtifactsConfig";
|
|
9
9
|
|
|
10
|
-
export const createNodeTestJobs = (
|
|
10
|
+
export const createNodeTestJobs = (
|
|
11
|
+
context: ComponentContext,
|
|
12
|
+
): CatladderJob[] => {
|
|
11
13
|
// don't run tests after release
|
|
12
14
|
// TODO: this will be replaced by using rules
|
|
13
15
|
if (context.trigger === "taggedRelease") {
|
|
@@ -15,6 +17,7 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
|
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
const buildConfig = context.componentConfig.build;
|
|
20
|
+
|
|
18
21
|
const defaultImage = getRunnerImage("jobs-default");
|
|
19
22
|
const base: Omit<CatladderJob, "script" | "name"> = {
|
|
20
23
|
variables: {
|
|
@@ -27,7 +30,7 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
|
|
|
27
30
|
needs: [],
|
|
28
31
|
envMode: "none",
|
|
29
32
|
};
|
|
30
|
-
const yarnInstall = getYarnInstall(context);
|
|
33
|
+
const yarnInstall = getYarnInstall(context.buildContext);
|
|
31
34
|
const auditJob: CatladderJob | null =
|
|
32
35
|
buildConfig.audit !== false
|
|
33
36
|
? {
|
|
@@ -38,7 +41,7 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
|
|
|
38
41
|
script: [
|
|
39
42
|
`cd ${context.componentConfig.dir}`,
|
|
40
43
|
...(ensureArray(buildConfig.audit?.command) ?? [
|
|
41
|
-
context.packageManagerInfo?.isClassic
|
|
44
|
+
context.buildContext.packageManagerInfo?.isClassic
|
|
42
45
|
? "yarn audit"
|
|
43
46
|
: "yarn npm audit --environment production", // yarn 2
|
|
44
47
|
]),
|
|
@@ -58,9 +61,9 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
|
|
|
58
61
|
name: "👮 lint",
|
|
59
62
|
...base,
|
|
60
63
|
image: buildConfig.lint?.jobImage ?? defaultImage,
|
|
61
|
-
cache: getNodeCache(context),
|
|
64
|
+
cache: getNodeCache(context.buildContext),
|
|
62
65
|
script: [
|
|
63
|
-
...ensureNodeVersion(context),
|
|
66
|
+
...ensureNodeVersion(context.buildContext),
|
|
64
67
|
`cd ${context.componentConfig.dir}`,
|
|
65
68
|
...yarnInstall,
|
|
66
69
|
...(ensureArray(buildConfig.lint?.command) ?? ["yarn lint"]),
|
|
@@ -80,9 +83,9 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
|
|
|
80
83
|
...base,
|
|
81
84
|
image:
|
|
82
85
|
buildConfig.test?.jobImage ?? getRunnerImage("jobs-testing-chrome"),
|
|
83
|
-
cache: getNodeCache(context),
|
|
86
|
+
cache: getNodeCache(context.buildContext),
|
|
84
87
|
script: [
|
|
85
|
-
...ensureNodeVersion(context),
|
|
88
|
+
...ensureNodeVersion(context.buildContext),
|
|
86
89
|
`cd ${context.componentConfig.dir}`,
|
|
87
90
|
...yarnInstall,
|
|
88
91
|
...(ensureArray(buildConfig.test?.command) ?? ["yarn test"]),
|
package/src/build/node/yarn.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BashExpression } from "../../bash/BashExpression";
|
|
2
|
-
import type {
|
|
2
|
+
import type { BuildContext, ComponentContext } from "../../types";
|
|
3
3
|
import { ensureArray } from "../../utils";
|
|
4
4
|
import { collapseableSection } from "../../utils/gitlab";
|
|
5
5
|
|
|
@@ -8,7 +8,7 @@ const YARN_INSTALL_CLASSIC = `yarn install --frozen-lockfile`;
|
|
|
8
8
|
// FIXME: check why and when rebuild is needed
|
|
9
9
|
const YARN_BERRY_PROD_REBUILD = `yarn workspaces focus --production && yarn rebuild`;
|
|
10
10
|
|
|
11
|
-
const getYarnInstallCommand = (context:
|
|
11
|
+
const getYarnInstallCommand = (context: BuildContext) => {
|
|
12
12
|
if (context.packageManagerInfo?.isClassic) {
|
|
13
13
|
return YARN_INSTALL_CLASSIC;
|
|
14
14
|
}
|
|
@@ -16,7 +16,7 @@ const getYarnInstallCommand = (context: Context) => {
|
|
|
16
16
|
return `yarn install --immutable`;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export const ensureNodeVersion = (context:
|
|
19
|
+
export const ensureNodeVersion = (context: BuildContext) =>
|
|
20
20
|
collapseableSection(
|
|
21
21
|
"nodeinstall",
|
|
22
22
|
"Ensure node version",
|
|
@@ -26,15 +26,13 @@ export const ensureNodeVersion = (context: Context) =>
|
|
|
26
26
|
]);
|
|
27
27
|
|
|
28
28
|
export const getYarnInstall = (
|
|
29
|
-
context:
|
|
29
|
+
context: BuildContext,
|
|
30
30
|
options?: {
|
|
31
31
|
noCustomPostInstall: boolean;
|
|
32
32
|
},
|
|
33
33
|
) => {
|
|
34
34
|
const postInstall =
|
|
35
|
-
"postInstall" in context.
|
|
36
|
-
? context.componentConfig.build.postInstall
|
|
37
|
-
: null;
|
|
35
|
+
"postInstall" in context.config ? context.config.postInstall : null;
|
|
38
36
|
return [
|
|
39
37
|
...ensureNodeVersion(context),
|
|
40
38
|
...collapseableSection(
|
|
@@ -52,7 +50,7 @@ export const getYarnInstall = (
|
|
|
52
50
|
|
|
53
51
|
const DOCKER_COPY_FILES = `COPY --chown=node:node $APP_DIR .`;
|
|
54
52
|
|
|
55
|
-
export const getDockerAppCopyAndBuildScript = (context:
|
|
53
|
+
export const getDockerAppCopyAndBuildScript = (context: BuildContext) => {
|
|
56
54
|
if (context.packageManagerInfo?.isClassic) {
|
|
57
55
|
return new BashExpression(
|
|
58
56
|
`
|
package/src/build/rails/build.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../..";
|
|
2
2
|
import type { CatladderJob } from "../../types/jobs";
|
|
3
3
|
import { createBuildJobs } from "../base";
|
|
4
4
|
import {
|
|
@@ -8,7 +8,9 @@ import {
|
|
|
8
8
|
} from "../docker";
|
|
9
9
|
import { isOfBuildType } from "../types";
|
|
10
10
|
|
|
11
|
-
export const createRailsBuildJobs = (
|
|
11
|
+
export const createRailsBuildJobs = (
|
|
12
|
+
context: ComponentContext,
|
|
13
|
+
): CatladderJob[] => {
|
|
12
14
|
const buildConfig = context.componentConfig.build;
|
|
13
15
|
if (!isOfBuildType(buildConfig, "rails")) {
|
|
14
16
|
// should not happen
|
package/src/build/rails/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../types";
|
|
2
2
|
import type { CatladderJob } from "../../types/jobs";
|
|
3
3
|
import { createRailsBuildJobs } from "./build";
|
|
4
4
|
import { createRailsTestJobs } from "./test";
|
|
5
5
|
|
|
6
|
-
export const createRailsJobs = (context:
|
|
6
|
+
export const createRailsJobs = (context: ComponentContext): CatladderJob[] => {
|
|
7
7
|
return [...createRailsTestJobs(context), ...createRailsBuildJobs(context)];
|
|
8
8
|
};
|
package/src/build/rails/test.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../..";
|
|
2
2
|
import type { CatladderJob } from "../../types/jobs";
|
|
3
3
|
import { ensureArray, notNil } from "../../utils";
|
|
4
4
|
|
|
5
|
-
export const createRailsTestJobs = (
|
|
5
|
+
export const createRailsTestJobs = (
|
|
6
|
+
context: ComponentContext,
|
|
7
|
+
): CatladderJob[] => {
|
|
6
8
|
// don't run tests after release
|
|
7
9
|
// TODO: this will be replaced by using rules
|
|
8
10
|
if (context.trigger === "taggedRelease") {
|
package/src/build/sbom.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../types/context";
|
|
2
2
|
import type { CatladderJob } from "../types/jobs";
|
|
3
3
|
import { ensureArray } from "../utils";
|
|
4
4
|
|
|
5
5
|
export const SBOM_BUILD_JOB_NAME = "🧾 sbom";
|
|
6
6
|
export const SBOM_FILE = "__sbom.json";
|
|
7
7
|
|
|
8
|
-
export const createSbomBuildJob = (context:
|
|
8
|
+
export const createSbomBuildJob = (context: ComponentContext): CatladderJob => {
|
|
9
9
|
const buildConfig = context.componentConfig.build;
|
|
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.packageManagerInfo?.componentIsInWorkspace
|
|
14
|
+
context.buildContext.packageManagerInfo?.componentIsInWorkspace
|
|
15
15
|
? "."
|
|
16
|
-
: context.
|
|
16
|
+
: context.buildContext.dir
|
|
17
17
|
}`,
|
|
18
18
|
];
|
|
19
19
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CreateComponentContextContext } from "..";
|
|
2
2
|
|
|
3
3
|
import type { Environment } from "../types/context";
|
|
4
4
|
import { getEnvironmentContext } from "./getEnvironmentContext";
|
|
5
5
|
import { getEnvironmentVariables } from "./getEnvironmentVariables";
|
|
6
6
|
|
|
7
7
|
export const getEnvironment = async (
|
|
8
|
-
ctx:
|
|
8
|
+
ctx: CreateComponentContextContext,
|
|
9
9
|
): Promise<Environment> => {
|
|
10
10
|
const { env } = ctx;
|
|
11
11
|
const variables = await getEnvironmentVariables(ctx);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CreateComponentContextContext } from "..";
|
|
2
2
|
import type { StringOrBashExpression } from "../bash/BashExpression";
|
|
3
3
|
import { joinBashExpressions } from "../bash/BashExpression";
|
|
4
4
|
|
|
@@ -22,7 +22,7 @@ export const getEnvironmentContext = ({
|
|
|
22
22
|
componentName,
|
|
23
23
|
config,
|
|
24
24
|
pipelineType,
|
|
25
|
-
}:
|
|
25
|
+
}: CreateComponentContextContext): EnvironmentContext<any, any> => {
|
|
26
26
|
const envConfigRaw = getEnvConfig(config, componentName, env);
|
|
27
27
|
const envType = getEnvType(env, envConfigRaw);
|
|
28
28
|
const reviewSlug = getReviewSlug(envConfigRaw, env, pipelineType);
|