@catladder/pipeline 0.0.0-refactor-docker-9fda97e9 → 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 +7 -7
- 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 +61 -46
- 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/getEnvironmentVariables.js +1 -2
- 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/getCloudRunDeployScripts.js +1 -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/kubeValues.js +1 -3
- 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/pipeline/generatePipelineFiles.js +15 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +3 -3
- package/dist/types/context.d.ts +16 -2
- package/dist/types/jobs.d.ts +1 -1
- package/examples/__snapshots__/cloud-run-storybook.ts.snap +1687 -0
- package/examples/__utils__/helpers.ts +2 -2
- package/examples/cloud-run-storybook.ts +24 -0
- package/package.json +1 -1
- package/scripts/generate-gitlab-ci-types.ts +2 -2
- package/src/bash/BashExpression.ts +4 -4
- package/src/bash/bashExpressionPerPipelineType.ts +1 -1
- package/src/bash/replaceAsync.ts +4 -4
- package/src/build/base/__tests__/createArtifactsConfig.test.ts +3 -3
- package/src/build/base/createAppBuildJob.ts +3 -3
- package/src/build/base/createArtifactsConfig.ts +2 -2
- package/src/build/base/index.ts +2 -2
- package/src/build/base/writeBuildInfo.ts +2 -2
- package/src/build/base/writeDotEnv.ts +3 -3
- package/src/build/custom/__tests__/testJob.test.ts +6 -6
- package/src/build/custom/buildJob.ts +4 -2
- package/src/build/custom/index.ts +2 -2
- package/src/build/custom/testJob.ts +7 -5
- package/src/build/docker.ts +18 -18
- package/src/build/index.ts +3 -3
- package/src/build/node/buildJob.ts +16 -10
- package/src/build/node/cache.ts +13 -13
- package/src/build/node/index.ts +6 -4
- package/src/build/node/meteor.ts +10 -5
- package/src/build/node/testJob.ts +14 -11
- package/src/build/node/yarn.ts +13 -15
- 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/config/configruedEnvs.ts +6 -6
- package/src/config/readConfig.ts +2 -2
- package/src/context/__tests__/resolveReferences.test.ts +1 -1
- package/src/context/getBuildInfoVariables.ts +5 -5
- package/src/context/getEnvConfig.ts +1 -1
- package/src/context/getEnvType.ts +1 -1
- package/src/context/getEnvironment.ts +2 -2
- package/src/context/getEnvironmentContext.ts +4 -4
- package/src/context/getEnvironmentVariables.ts +19 -16
- package/src/context/getLabels.ts +2 -2
- package/src/context/getReviewSlug.ts +2 -2
- package/src/context/index.ts +17 -7
- package/src/context/resolveReferences.ts +12 -9
- package/src/context/transformJobOnlyVars.ts +1 -1
- package/src/context/utils/envVars.ts +3 -3
- package/src/deploy/base/deploy.ts +7 -7
- package/src/deploy/base/index.ts +3 -3
- package/src/deploy/base/rollback.ts +3 -3
- package/src/deploy/base/stop.ts +3 -3
- package/src/deploy/cloudRun/artifactsRegistry.ts +17 -12
- package/src/deploy/cloudRun/cleanup.ts +5 -5
- package/src/deploy/cloudRun/cloudRunRevisions.ts +6 -6
- package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +20 -20
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +7 -7
- package/src/deploy/cloudRun/createJobs/common.ts +5 -5
- package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +12 -9
- package/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.ts +3 -3
- package/src/deploy/cloudRun/createJobs/index.ts +2 -2
- package/src/deploy/cloudRun/createJobs/volumes.ts +2 -2
- package/src/deploy/cloudRun/index.ts +10 -6
- package/src/deploy/cloudRun/utils/createArgsString.ts +1 -1
- package/src/deploy/cloudRun/utils/database.ts +8 -8
- package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +5 -3
- package/src/deploy/cloudRun/utils/getServiceName.ts +2 -2
- package/src/deploy/cloudRun/utils/jobName.ts +1 -1
- package/src/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.ts +1 -1
- package/src/deploy/cloudSql/utils.ts +2 -2
- package/src/deploy/custom/deployJob.ts +7 -3
- package/src/deploy/dockerTag/deployJob.ts +4 -2
- package/src/deploy/index.ts +5 -5
- package/src/deploy/kubernetes/cloudSql/index.ts +5 -5
- package/src/deploy/kubernetes/deployJob.ts +7 -7
- package/src/deploy/kubernetes/index.ts +1 -1
- package/src/deploy/kubernetes/kubeEnv.ts +3 -3
- package/src/deploy/kubernetes/kubeValues.ts +8 -8
- package/src/deploy/kubernetes/mongodb.ts +9 -9
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +3 -3
- package/src/deploy/sbom.ts +8 -4
- package/src/deploy/utils.ts +4 -4
- package/src/pipeline/createAllJobs.ts +4 -4
- package/src/pipeline/createChildPipeline.ts +2 -2
- package/src/pipeline/createJobsForComponent.ts +13 -9
- package/src/pipeline/createMainPipeline.ts +20 -17
- package/src/pipeline/generatePipelineFiles.ts +21 -12
- package/src/pipeline/getPipelineStages.ts +1 -1
- package/src/pipeline/gitlab/createGitlabJobs.ts +26 -26
- package/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.ts +6 -6
- package/src/pipeline/packageManager.ts +2 -2
- package/src/pipeline/yarn/yarnUtils.ts +7 -7
- package/src/types/config.ts +4 -4
- package/src/types/context.ts +19 -3
- package/src/types/environmentContext.ts +1 -1
- package/src/types/jobs.ts +1 -1
- package/src/types/utils.ts +4 -4
- package/src/utils/gitlab.ts +1 -1
- package/src/utils/index.ts +2 -2
- package/src/utils/writeFiles.ts +2 -2
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
|
]),
|
|
@@ -47,7 +50,7 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
|
|
|
47
50
|
...createArtifactsConfig(
|
|
48
51
|
context.componentConfig.dir,
|
|
49
52
|
buildConfig.audit?.artifactsReports,
|
|
50
|
-
buildConfig.audit?.artifacts
|
|
53
|
+
buildConfig.audit?.artifacts,
|
|
51
54
|
),
|
|
52
55
|
}
|
|
53
56
|
: null;
|
|
@@ -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"]),
|
|
@@ -68,7 +71,7 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
|
|
|
68
71
|
...createArtifactsConfig(
|
|
69
72
|
context.componentConfig.dir,
|
|
70
73
|
buildConfig.lint?.artifactsReports,
|
|
71
|
-
buildConfig.lint?.artifacts
|
|
74
|
+
buildConfig.lint?.artifacts,
|
|
72
75
|
),
|
|
73
76
|
}
|
|
74
77
|
: null;
|
|
@@ -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"]),
|
|
@@ -90,7 +93,7 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
|
|
|
90
93
|
...createArtifactsConfig(
|
|
91
94
|
context.componentConfig.dir,
|
|
92
95
|
buildConfig.test?.artifactsReports,
|
|
93
|
-
buildConfig.test?.artifacts
|
|
96
|
+
buildConfig.test?.artifacts,
|
|
94
97
|
),
|
|
95
98
|
}
|
|
96
99
|
: null;
|
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,35 +16,33 @@ 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
|
-
"Ensure node version"
|
|
22
|
+
"Ensure node version",
|
|
23
23
|
)([
|
|
24
24
|
"if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi",
|
|
25
25
|
"if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi",
|
|
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(
|
|
41
39
|
"yarninstall",
|
|
42
|
-
"Yarn install"
|
|
40
|
+
"Yarn install",
|
|
43
41
|
)([getYarnInstallCommand(context)]),
|
|
44
42
|
...(postInstall && !options?.noCustomPostInstall
|
|
45
43
|
? collapseableSection(
|
|
46
44
|
"postinstall",
|
|
47
|
-
"Custom post install"
|
|
45
|
+
"Custom post install",
|
|
48
46
|
)(ensureArray(postInstall) ?? [])
|
|
49
47
|
: []),
|
|
50
48
|
];
|
|
@@ -52,21 +50,21 @@ 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
|
`
|
|
59
57
|
RUN ${YARN_INSTALL_CLASSIC} --production --ignore-scripts
|
|
60
58
|
${DOCKER_COPY_FILES}
|
|
61
59
|
RUN ${YARN_INSTALL_CLASSIC} --production
|
|
62
|
-
`.trim()
|
|
60
|
+
`.trim(),
|
|
63
61
|
);
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
// yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
|
|
67
65
|
// trying to import those fail on this version
|
|
68
66
|
const doesNotShipWithBuiltInPlugins = ["2", "3"].some((v) =>
|
|
69
|
-
context.packageManagerInfo?.version.startsWith(v)
|
|
67
|
+
context.packageManagerInfo?.version.startsWith(v),
|
|
70
68
|
);
|
|
71
69
|
const maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins
|
|
72
70
|
? "RUN yarn plugin import workspace-tools"
|
|
@@ -80,6 +78,6 @@ ${DOCKER_COPY_FILES}
|
|
|
80
78
|
${maybeAddWorkspaceToolsCommand}
|
|
81
79
|
RUN ${YARN_BERRY_PROD_REBUILD}
|
|
82
80
|
|
|
83
|
-
`.trim()
|
|
81
|
+
`.trim(),
|
|
84
82
|
);
|
|
85
83
|
};
|
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
|
|
|
@@ -4,25 +4,25 @@ import { DEFAULT_ENV_TYPES, getEnvTypesByTrigger } from "../types";
|
|
|
4
4
|
const getConfiguredAndDefaultEnvs = (
|
|
5
5
|
config: Config,
|
|
6
6
|
componentName: string,
|
|
7
|
-
envTypes: EnvType[]
|
|
7
|
+
envTypes: EnvType[],
|
|
8
8
|
) => {
|
|
9
9
|
const configuredEnvs = config.components[componentName].env ?? {};
|
|
10
10
|
// the default envs have the same name as the env types
|
|
11
11
|
// these can be disabled with settimg them to `false`
|
|
12
12
|
// this is the list of all not disabled envs. These are always returned
|
|
13
13
|
const enabledDefaultEnvs = envTypes.filter(
|
|
14
|
-
(e) => configuredEnvs[e] !== false
|
|
14
|
+
(e) => configuredEnvs[e] !== false,
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
const configuredCustomEnvs = Object.entries(
|
|
18
|
-
config.components[componentName].env ?? {}
|
|
18
|
+
config.components[componentName].env ?? {},
|
|
19
19
|
)
|
|
20
20
|
.filter(
|
|
21
21
|
([, config]) =>
|
|
22
22
|
config &&
|
|
23
23
|
"type" in config &&
|
|
24
24
|
config.type &&
|
|
25
|
-
envTypes.includes(config.type)
|
|
25
|
+
envTypes.includes(config.type),
|
|
26
26
|
)
|
|
27
27
|
.map(([envName]) => envName);
|
|
28
28
|
|
|
@@ -36,7 +36,7 @@ export const getAllEnvs = (config: Config, componentName: string) => {
|
|
|
36
36
|
export const getAllEnvsInAllComponents = (config: Config) => {
|
|
37
37
|
return [
|
|
38
38
|
...new Set(
|
|
39
|
-
Object.keys(config.components).flatMap((c) => getAllEnvs(config, c))
|
|
39
|
+
Object.keys(config.components).flatMap((c) => getAllEnvs(config, c)),
|
|
40
40
|
),
|
|
41
41
|
];
|
|
42
42
|
};
|
|
@@ -44,7 +44,7 @@ export const getAllEnvsInAllComponents = (config: Config) => {
|
|
|
44
44
|
export const getAllEnvsByTrigger = (
|
|
45
45
|
config: Config,
|
|
46
46
|
componentName: string,
|
|
47
|
-
trigger: PipelineTrigger
|
|
47
|
+
trigger: PipelineTrigger,
|
|
48
48
|
) => {
|
|
49
49
|
const envTypesByTrigger = getEnvTypesByTrigger(trigger);
|
|
50
50
|
return getConfiguredAndDefaultEnvs(config, componentName, envTypesByTrigger);
|
package/src/config/readConfig.ts
CHANGED
|
@@ -14,7 +14,7 @@ function requireUncached(module: string) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export const readConfigSync = (
|
|
17
|
-
directory: string = process.cwd()
|
|
17
|
+
directory: string = process.cwd(),
|
|
18
18
|
): { config: Config; path: string; ext: string } | null => {
|
|
19
19
|
register({
|
|
20
20
|
cwd: directory,
|
|
@@ -25,7 +25,7 @@ export const readConfigSync = (
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
const found = ["ts", "js", "yml", "yaml"].find((extension) =>
|
|
28
|
-
existsSync(fullPath(directory, extension))
|
|
28
|
+
existsSync(fullPath(directory, extension)),
|
|
29
29
|
);
|
|
30
30
|
if (found) {
|
|
31
31
|
const filePath = fullPath(directory, found);
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
|
|
7
7
|
const unpackBashExpressions = (obj: Record<string, string | BashExpression>) =>
|
|
8
8
|
Object.fromEntries(
|
|
9
|
-
Object.entries(obj).map(([key, value]) => [key, value.toString()])
|
|
9
|
+
Object.entries(obj).map(([key, value]) => [key, value.toString()]),
|
|
10
10
|
);
|
|
11
11
|
describe("resolveReferences", () => {
|
|
12
12
|
it("replaces occurences of ${componentName:VARIABLE_NAME}", async () => {
|
|
@@ -10,13 +10,13 @@ const BUILD_TIME: BashExpressionPerPipelineType = {
|
|
|
10
10
|
|
|
11
11
|
const BUILD_ID: BashExpressionPerPipelineType = {
|
|
12
12
|
default: new BashExpression(
|
|
13
|
-
`$(git describe --tags 2>/dev/null || git rev-parse HEAD)
|
|
13
|
+
`$(git describe --tags 2>/dev/null || git rev-parse HEAD)`,
|
|
14
14
|
),
|
|
15
15
|
};
|
|
16
16
|
const CURRENT_VERSION: BashExpressionPerPipelineType = {
|
|
17
17
|
default: new BashExpression(
|
|
18
18
|
// because we do shallow fetch, we need to ask the origin
|
|
19
|
-
`$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\///'); [ -z "$tag" ] && echo "v0.0.0" || echo "$tag")
|
|
19
|
+
`$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\///'); [ -z "$tag" ] && echo "v0.0.0" || echo "$tag")`,
|
|
20
20
|
),
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -26,15 +26,15 @@ export const getBuildInfoVariables = (ctx: EnvironmentContext<any, any>) => {
|
|
|
26
26
|
return {
|
|
27
27
|
BUILD_INFO_BUILD_ID: getBashExpressionPerPipelineType(
|
|
28
28
|
BUILD_ID,
|
|
29
|
-
pipelineType
|
|
29
|
+
pipelineType,
|
|
30
30
|
),
|
|
31
31
|
BUILD_INFO_BUILD_TIME: getBashExpressionPerPipelineType(
|
|
32
32
|
BUILD_TIME,
|
|
33
|
-
pipelineType
|
|
33
|
+
pipelineType,
|
|
34
34
|
),
|
|
35
35
|
BUILD_INFO_CURRENT_VERSION: getBashExpressionPerPipelineType(
|
|
36
36
|
CURRENT_VERSION,
|
|
37
|
-
pipelineType
|
|
37
|
+
pipelineType,
|
|
38
38
|
),
|
|
39
39
|
};
|
|
40
40
|
};
|
|
@@ -5,7 +5,7 @@ import { mergeWithMergingArrays } from "../utils";
|
|
|
5
5
|
export const getEnvConfig = (
|
|
6
6
|
config: Config,
|
|
7
7
|
componentName: string,
|
|
8
|
-
env: string
|
|
8
|
+
env: string,
|
|
9
9
|
): EnvConfigWithComponent => {
|
|
10
10
|
const defaultConfig = config.components[componentName];
|
|
11
11
|
if (!defaultConfig) {
|
|
@@ -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
|
|
|
@@ -9,7 +9,7 @@ import { getReviewSlug } from "./getReviewSlug";
|
|
|
9
9
|
|
|
10
10
|
const getEnvironmentSlugPrefix = (
|
|
11
11
|
env: string,
|
|
12
|
-
reviewSlug: StringOrBashExpression | null
|
|
12
|
+
reviewSlug: StringOrBashExpression | null,
|
|
13
13
|
): StringOrBashExpression => {
|
|
14
14
|
if (reviewSlug) {
|
|
15
15
|
return joinBashExpressions([env, reviewSlug], "-");
|
|
@@ -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);
|
|
@@ -33,7 +33,7 @@ export const getEnvironmentContext = ({
|
|
|
33
33
|
|
|
34
34
|
const fullName = joinBashExpressions(
|
|
35
35
|
[config.customerName, config.appName, environmentSlug],
|
|
36
|
-
"-"
|
|
36
|
+
"-",
|
|
37
37
|
);
|
|
38
38
|
|
|
39
39
|
return {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { merge } from "lodash";
|
|
2
2
|
import { DEPLOY_TYPES } from "../deploy";
|
|
3
3
|
import type {
|
|
4
|
-
|
|
4
|
+
ComponentContext,
|
|
5
5
|
EnvironmentEnvVarPart as EnvironmentVariables,
|
|
6
6
|
} from "../types";
|
|
7
7
|
import type { DevLocalEnvConfig } from "../types/config";
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { CreateComponentContextContext, UnspecifiedEnvVars } from "..";
|
|
10
10
|
import type { StringOrBashExpression } from "../bash/BashExpression";
|
|
11
11
|
import { getBashVariable, joinBashExpressions } from "../bash/BashExpression";
|
|
12
12
|
import type { EnvironmentContext } from "../types/environmentContext";
|
|
@@ -52,8 +52,8 @@ export type PredefinedVariables = BasePredefinedVariables & {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
export const getEnvironmentVariables = async (
|
|
55
|
-
ctx:
|
|
56
|
-
alreadyVisited: Record<string, Record<string, boolean>> = {} // to prevent endless loop
|
|
55
|
+
ctx: CreateComponentContextContext,
|
|
56
|
+
alreadyVisited: Record<string, Record<string, boolean>> = {}, // to prevent endless loop
|
|
57
57
|
): Promise<EnvironmentVariables> => {
|
|
58
58
|
const environmentContext = getEnvironmentContext(ctx);
|
|
59
59
|
|
|
@@ -88,7 +88,7 @@ export const getEnvironmentVariables = async (
|
|
|
88
88
|
} else {
|
|
89
89
|
const additionalEnvVars = deployConfigRaw
|
|
90
90
|
? DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(
|
|
91
|
-
environmentContext as never
|
|
91
|
+
environmentContext as never,
|
|
92
92
|
)
|
|
93
93
|
: {};
|
|
94
94
|
|
|
@@ -116,7 +116,7 @@ export const getEnvironmentVariables = async (
|
|
|
116
116
|
|
|
117
117
|
const additionalSecretKeys = deployConfigRaw
|
|
118
118
|
? DEPLOY_TYPES[deployConfigRaw.type].additionalSecretKeys(
|
|
119
|
-
environmentContext as never
|
|
119
|
+
environmentContext as never,
|
|
120
120
|
)
|
|
121
121
|
: [];
|
|
122
122
|
|
|
@@ -127,18 +127,18 @@ export const getEnvironmentVariables = async (
|
|
|
127
127
|
const secretEnvVars = makeSecretEnvVarMapping(
|
|
128
128
|
env,
|
|
129
129
|
componentName,
|
|
130
|
-
secretEnvVarKeys
|
|
130
|
+
secretEnvVarKeys,
|
|
131
131
|
);
|
|
132
132
|
// this is deprecated, we now support: $componentname:FOO
|
|
133
133
|
const legacyFromComponents = envConfigRaw.vars?.fromComponents ?? {};
|
|
134
134
|
const publicEnvVarsRawWithLegacyFromComponents = merge(
|
|
135
135
|
{},
|
|
136
136
|
translateLegacyFromComponents(legacyFromComponents),
|
|
137
|
-
publicEnvVarsRaw
|
|
137
|
+
publicEnvVarsRaw,
|
|
138
138
|
);
|
|
139
139
|
|
|
140
140
|
const publicEnvVarsRawSanitized = stringifyValues(
|
|
141
|
-
publicEnvVarsRawWithLegacyFromComponents
|
|
141
|
+
publicEnvVarsRawWithLegacyFromComponents,
|
|
142
142
|
);
|
|
143
143
|
|
|
144
144
|
const envVarsRaw = addIndexVar({
|
|
@@ -155,11 +155,11 @@ export const getEnvironmentVariables = async (
|
|
|
155
155
|
...ctx,
|
|
156
156
|
componentName: otherComponentName,
|
|
157
157
|
},
|
|
158
|
-
alreadyVisited
|
|
158
|
+
alreadyVisited,
|
|
159
159
|
);
|
|
160
160
|
return otherEnvVars;
|
|
161
161
|
},
|
|
162
|
-
alreadyVisited
|
|
162
|
+
alreadyVisited,
|
|
163
163
|
)) as typeof envVarsRaw;
|
|
164
164
|
|
|
165
165
|
return {
|
|
@@ -169,12 +169,12 @@ export const getEnvironmentVariables = async (
|
|
|
169
169
|
build: await transformJobOnlyVars(
|
|
170
170
|
env,
|
|
171
171
|
componentName,
|
|
172
|
-
(buildConfigRaw && buildConfigRaw.jobVars) || null
|
|
172
|
+
(buildConfigRaw && buildConfigRaw.jobVars) || null,
|
|
173
173
|
),
|
|
174
174
|
deploy: await transformJobOnlyVars(
|
|
175
175
|
env,
|
|
176
176
|
componentName,
|
|
177
|
-
(deployConfigRaw && deployConfigRaw.jobVars) || null
|
|
177
|
+
(deployConfigRaw && deployConfigRaw.jobVars) || null,
|
|
178
178
|
),
|
|
179
179
|
},
|
|
180
180
|
|
|
@@ -188,15 +188,18 @@ const sanitizeForEnVar = (s: string) => s.replace(/-/g, "_");
|
|
|
188
188
|
export const getSecretVarName = (
|
|
189
189
|
env: string,
|
|
190
190
|
componentName: string,
|
|
191
|
-
key: string
|
|
191
|
+
key: string,
|
|
192
192
|
) => `CL_${sanitizeForEnVar(env)}_${sanitizeForEnVar(componentName)}_${key}`; // remove dash from component name
|
|
193
193
|
|
|
194
194
|
const addIndexVar = <V extends Record<string, unknown>>(
|
|
195
|
-
vars: V
|
|
195
|
+
vars: V,
|
|
196
196
|
): V & { _ALL_ENV_VAR_KEYS: string } => ({
|
|
197
197
|
...vars,
|
|
198
198
|
_ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars)),
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
-
export const getSecretVarNameForContext = (
|
|
201
|
+
export const getSecretVarNameForContext = (
|
|
202
|
+
context: ComponentContext,
|
|
203
|
+
key: string,
|
|
204
|
+
) =>
|
|
202
205
|
getSecretVarName(context.environment.shortName, context.componentName, key);
|
package/src/context/getLabels.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import slugify from "slugify";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComponentContext } from "../types";
|
|
3
3
|
|
|
4
4
|
const sanitize = (value?: string) => {
|
|
5
5
|
if (!value) return value;
|
|
@@ -7,7 +7,7 @@ const sanitize = (value?: string) => {
|
|
|
7
7
|
// slugify should do the job
|
|
8
8
|
return slugify(value).toLowerCase();
|
|
9
9
|
};
|
|
10
|
-
export const getLabels = (context:
|
|
10
|
+
export const getLabels = (context: ComponentContext) => {
|
|
11
11
|
const labels = {
|
|
12
12
|
"customer-name": sanitize(context.fullConfig.customerName),
|
|
13
13
|
"component-name": sanitize(context.componentName),
|
|
@@ -10,14 +10,14 @@ import { getEnvType } from "./getEnvType";
|
|
|
10
10
|
const REVIEW_SLUG: BashExpressionPerPipelineType = {
|
|
11
11
|
default: "unknown-review-slug",
|
|
12
12
|
gitlab: new BashExpression(
|
|
13
|
-
`$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })
|
|
13
|
+
`$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })`,
|
|
14
14
|
),
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export const getReviewSlug = (
|
|
18
18
|
envConfig: EnvConfigWithComponent,
|
|
19
19
|
env: string,
|
|
20
|
-
pipelineType?: PipelineType
|
|
20
|
+
pipelineType?: PipelineType,
|
|
21
21
|
): StringOrBashExpression | null => {
|
|
22
22
|
const envType = getEnvType(env, envConfig);
|
|
23
23
|
if (envType === "review") {
|