@catladder/pipeline 1.144.1 → 1.145.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bash/BashExpression.d.ts +40 -0
- package/dist/bash/BashExpression.js +124 -0
- package/dist/bash/bashExpressionPerPipelineType.d.ts +6 -0
- package/dist/bash/bashExpressionPerPipelineType.js +11 -0
- package/dist/bash/bashYaml.d.ts +10 -0
- package/dist/bash/bashYaml.js +46 -0
- package/dist/bash/getInjectVarsScript.d.ts +2 -0
- package/dist/bash/getInjectVarsScript.js +45 -0
- package/dist/bash/replaceAsync.d.ts +2 -0
- package/dist/{pipeline/commitInfo/getCommitInfo.js → bash/replaceAsync.js} +49 -21
- package/dist/build/base/__tests__/createArtifactsConfig.test.js +3 -1
- package/dist/build/base/constants.js +3 -1
- package/dist/build/base/createAppBuildJob.d.ts +2 -1
- package/dist/build/base/createAppBuildJob.js +10 -6
- package/dist/build/base/createArtifactsConfig.d.ts +1 -1
- package/dist/build/base/createArtifactsConfig.js +3 -1
- package/dist/build/base/index.js +3 -1
- package/dist/build/base/writeBuildInfo.js +4 -3
- package/dist/build/base/writeDotEnv.js +12 -3
- package/dist/build/custom/__tests__/testJob.test.js +3 -1
- package/dist/build/custom/buildJob.js +4 -12
- package/dist/build/custom/index.js +3 -1
- package/dist/build/custom/testJob.d.ts +1 -1
- package/dist/build/custom/testJob.js +18 -14
- package/dist/build/docker.d.ts +5 -31
- package/dist/build/docker.js +16 -9
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +13 -7
- package/dist/build/node/buildJob.js +4 -12
- package/dist/build/node/cache.js +6 -3
- package/dist/build/node/constants.js +3 -1
- package/dist/build/node/index.js +3 -1
- package/dist/build/node/meteor.js +5 -2
- package/dist/build/node/testJob.js +18 -14
- package/dist/build/node/yarn.d.ts +3 -2
- package/dist/build/node/yarn.js +6 -3
- package/dist/build/rails/build.js +3 -1
- package/dist/build/rails/index.js +3 -1
- package/dist/build/rails/test.js +15 -11
- package/dist/build/sbom.js +3 -1
- package/dist/build/types.d.ts +24 -18
- package/dist/build/types.js +3 -1
- package/dist/bundles/catladder-gitlab/index.js +3 -3
- package/dist/catladder-gitlab.js +10 -54
- package/dist/config/__tests__/configruedEnvs.test.js +3 -1
- package/dist/config/configruedEnvs.js +3 -1
- package/dist/config/index.js +13 -7
- package/dist/config/readConfig.js +6 -5
- package/dist/constants.js +5 -3
- package/dist/context/__tests__/resolveReferences.test.js +40 -8
- package/dist/context/getBuildInfoVariables.d.ts +7 -0
- package/dist/context/getBuildInfoVariables.js +29 -0
- package/dist/context/getEnvConfig.js +3 -1
- package/dist/context/getEnvType.js +3 -1
- package/dist/context/getEnvironment.d.ts +3 -3
- package/dist/context/getEnvironment.js +10 -14
- package/dist/context/getEnvironmentContext.d.ts +7 -3
- package/dist/context/getEnvironmentContext.js +21 -11
- package/dist/context/getEnvironmentVariables.d.ts +26 -5
- package/dist/context/getEnvironmentVariables.js +41 -25
- package/dist/context/getLabels.js +4 -2
- package/dist/context/getReviewSlug.d.ts +4 -0
- package/dist/context/getReviewSlug.js +22 -0
- package/dist/context/index.d.ts +12 -3
- package/dist/context/index.js +21 -15
- package/dist/context/resolveReferences.d.ts +3 -1
- package/dist/context/resolveReferences.js +53 -21
- package/dist/context/transformJobOnlyVars.d.ts +5 -2
- package/dist/context/transformJobOnlyVars.js +4 -2
- package/dist/context/utils/envVars.d.ts +1 -1
- package/dist/context/utils/envVars.js +5 -2
- package/dist/defaults/index.js +3 -1
- package/dist/deploy/base/deploy.d.ts +1 -1
- package/dist/deploy/base/deploy.js +12 -11
- package/dist/deploy/base/index.js +3 -1
- package/dist/deploy/base/rollback.d.ts +1 -1
- package/dist/deploy/base/rollback.js +13 -9
- package/dist/deploy/base/stop.d.ts +1 -1
- package/dist/deploy/base/stop.js +16 -11
- package/dist/deploy/base/types.d.ts +1 -1
- package/dist/deploy/base/types.js +3 -1
- package/dist/deploy/base/variables.js +3 -1
- package/dist/deploy/cloudRun/artifactsRegistry.d.ts +2 -1
- package/dist/deploy/cloudRun/artifactsRegistry.js +6 -4
- package/dist/deploy/cloudRun/cleanup.js +3 -1
- package/dist/deploy/cloudRun/cloudRunRevisions.js +3 -1
- package/dist/deploy/cloudRun/createJobs/cloudRunJobs.js +8 -5
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.d.ts +2 -2
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +6 -3
- package/dist/deploy/cloudRun/createJobs/common.d.ts +3 -3
- package/dist/deploy/cloudRun/createJobs/common.js +3 -1
- package/dist/deploy/cloudRun/createJobs/constants.d.ts +1 -0
- package/dist/deploy/cloudRun/createJobs/constants.js +7 -0
- package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +9 -2
- package/dist/deploy/cloudRun/createJobs/getCloudRunStopScripts.js +3 -1
- package/dist/deploy/cloudRun/createJobs/index.js +25 -8
- package/dist/deploy/cloudRun/createJobs/volumes.js +3 -1
- package/dist/deploy/cloudRun/index.js +5 -3
- package/dist/deploy/cloudRun/utils/createArgsString.d.ts +2 -1
- package/dist/deploy/cloudRun/utils/createArgsString.js +3 -1
- package/dist/deploy/cloudRun/utils/database.js +13 -13
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.js +3 -1
- package/dist/deploy/cloudRun/utils/getServiceName.d.ts +1 -1
- package/dist/deploy/cloudRun/utils/getServiceName.js +3 -1
- package/dist/deploy/cloudRun/utils/jobName.d.ts +2 -1
- package/dist/deploy/cloudRun/utils/jobName.js +4 -2
- package/dist/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.js +3 -1
- package/dist/deploy/cloudSql/utils.d.ts +2 -1
- package/dist/deploy/cloudSql/utils.js +7 -2
- package/dist/deploy/custom/deployJob.js +3 -1
- package/dist/deploy/custom/index.js +3 -1
- package/dist/deploy/dockerTag/deployJob.js +3 -1
- package/dist/deploy/dockerTag/index.js +3 -1
- package/dist/deploy/index.d.ts +4 -3
- package/dist/deploy/index.js +13 -7
- package/dist/deploy/kubernetes/additionalSecretKeys.js +3 -1
- package/dist/deploy/kubernetes/cloudSql/index.d.ts +3 -2
- package/dist/deploy/kubernetes/cloudSql/index.js +6 -4
- package/dist/deploy/kubernetes/deployJob.js +22 -15
- package/dist/deploy/kubernetes/index.js +51 -14
- package/dist/deploy/kubernetes/kubeEnv.d.ts +3 -2
- package/dist/deploy/kubernetes/kubeEnv.js +7 -4
- package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
- package/dist/deploy/kubernetes/kubeValues.js +3 -2
- package/dist/deploy/kubernetes/mongodb.js +3 -1
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +2 -1
- package/dist/deploy/kubernetes/processSecretsAsFiles.js +3 -1
- package/dist/deploy/sbom.js +3 -1
- package/dist/deploy/types/base.d.ts +8 -2
- package/dist/deploy/types/base.js +3 -1
- package/dist/deploy/types/custom.d.ts +1 -1
- package/dist/deploy/types/custom.js +3 -1
- package/dist/deploy/types/dockerTag.d.ts +1 -1
- package/dist/deploy/types/dockerTag.js +3 -1
- package/dist/deploy/types/googleCloudRun.d.ts +19 -18
- package/dist/deploy/types/googleCloudRun.js +3 -1
- package/dist/deploy/types/index.d.ts +6 -6
- package/dist/deploy/types/index.js +13 -7
- package/dist/deploy/types/kubernetes.d.ts +22 -22
- package/dist/deploy/types/kubernetes.js +3 -1
- package/dist/deploy/utils.js +3 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +16 -9
- package/dist/packageInfos.d.ts +2 -0
- package/dist/packageInfos.js +14 -0
- package/dist/pipeline/createAllJobs.d.ts +13 -5
- package/dist/pipeline/createAllJobs.js +21 -10
- package/dist/pipeline/createChildPipeline.d.ts +1 -1
- package/dist/pipeline/createChildPipeline.js +24 -7
- package/dist/pipeline/createJobsForComponent.d.ts +3 -3
- package/dist/pipeline/createJobsForComponent.js +19 -18
- package/dist/pipeline/createMainPipeline.d.ts +3 -0
- package/dist/pipeline/createMainPipeline.js +248 -0
- package/dist/pipeline/generatePipelineFiles.d.ts +2 -0
- package/dist/pipeline/generatePipelineFiles.js +178 -0
- package/dist/pipeline/getPipelineStages.js +3 -1
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +15 -5
- package/dist/pipeline/gitlab/createGitlabJobs.js +98 -25
- package/dist/pipeline/gitlab/createGitlabPipeline.d.ts +7 -2
- package/dist/pipeline/gitlab/createGitlabPipeline.js +34 -17
- package/dist/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.d.ts +1 -0
- package/dist/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.js +29 -0
- package/dist/pipeline/gitlab/gitlabReleaseJobs.d.ts +33 -0
- package/dist/pipeline/gitlab/gitlabReleaseJobs.js +24 -0
- package/dist/pipeline/index.d.ts +3 -1
- package/dist/pipeline/index.js +16 -8
- package/dist/pipeline/packageManager.js +4 -2
- package/dist/pipeline/yarn/yarnUtils.js +6 -4
- package/dist/rules/index.d.ts +4 -1
- package/dist/rules/index.js +25 -18
- package/dist/runner/index.d.ts +1 -1
- package/dist/runner/index.js +3 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +18 -15
- package/dist/types/config.js +5 -2
- package/dist/types/context.d.ts +37 -32
- package/dist/types/context.js +3 -1
- package/dist/types/environmentContext.d.ts +11 -7
- package/dist/types/environmentContext.js +3 -1
- package/dist/types/gitlab-ci-yml.d.ts +30 -30
- package/dist/types/gitlab-ci-yml.js +3 -2
- package/dist/types/gitlab-types.d.ts +4 -6
- package/dist/types/gitlab-types.js +3 -1
- package/dist/types/index.js +13 -7
- package/dist/types/jobs.d.ts +23 -6
- package/dist/types/jobs.js +3 -1
- package/dist/types/pipeline.d.ts +4 -3
- package/dist/types/pipeline.js +3 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/types/utils.js +3 -1
- package/dist/utils/gitlab.js +3 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/writeFiles.d.ts +7 -0
- package/dist/{pipeline/commitInfo/getBuildId.js → utils/writeFiles.js} +39 -22
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +480 -384
- package/examples/__snapshots__/cloud-run-meteor-with-worker.ts.snap +462 -366
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +480 -384
- package/examples/__snapshots__/cloud-run-no-service.ts.snap +501 -393
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +480 -384
- package/examples/__snapshots__/cloud-run-post-stop-job.ts.snap +489 -392
- package/examples/__snapshots__/cloud-run-service-gen2.ts.snap +480 -384
- package/examples/__snapshots__/cloud-run-service-with-volumes.ts.snap +501 -401
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +1155 -915
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +1116 -888
- package/examples/__snapshots__/cloud-run-with-worker.ts.snap +482 -386
- package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +452 -356
- package/examples/__snapshots__/custom-build-job.ts.snap +434 -350
- package/examples/__snapshots__/custom-deploy.ts.snap +319 -223
- package/examples/__snapshots__/custom-envs.ts.snap +123 -81
- package/examples/__snapshots__/custom-sbom-java.ts.snap +434 -350
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +846 -969
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +886 -957
- package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +894 -969
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +1626 -1728
- package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +974 -1137
- package/examples/__snapshots__/local-dot-env.ts.snap +480 -384
- package/examples/__snapshots__/meteor-kubernetes.ts.snap +906 -1069
- package/examples/__snapshots__/multiline-var.ts.snap +4500 -0
- package/examples/__snapshots__/native-app.ts.snap +706 -578
- package/examples/__snapshots__/node-build-with-custom-image.ts.snap +480 -384
- package/examples/__snapshots__/node-build-with-docker-additions.ts.snap +488 -384
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1656 -1942
- package/examples/__snapshots__/wait-for-other-deploy.ts.snap +287 -231
- package/examples/custom-deploy.ts +7 -7
- package/examples/multiline-var.ts +64 -0
- package/package.json +5 -8
- package/src/bash/BashExpression.ts +81 -0
- package/src/bash/bashExpressionPerPipelineType.ts +16 -0
- package/src/bash/bashYaml.ts +46 -0
- package/src/bash/getInjectVarsScript.ts +12 -0
- package/src/bash/replaceAsync.ts +50 -0
- package/src/build/base/createAppBuildJob.ts +6 -2
- package/src/build/base/writeBuildInfo.ts +1 -1
- package/src/build/base/writeDotEnv.ts +6 -1
- package/src/build/custom/buildJob.ts +2 -4
- package/src/build/custom/testJob.ts +3 -2
- package/src/build/docker.ts +15 -7
- package/src/build/node/buildJob.ts +1 -3
- package/src/build/node/testJob.ts +3 -2
- package/src/build/node/yarn.ts +9 -4
- package/src/build/rails/test.ts +2 -1
- package/src/build/types.ts +8 -1
- package/src/catladder-gitlab.ts +8 -55
- package/src/config/readConfig.ts +2 -3
- package/src/constants.ts +5 -2
- package/src/context/__tests__/resolveReferences.test.ts +11 -6
- package/src/context/getBuildInfoVariables.ts +40 -0
- package/src/context/getEnvironment.ts +7 -30
- package/src/context/getEnvironmentContext.ts +25 -29
- package/src/context/getEnvironmentVariables.ts +61 -36
- package/src/context/getReviewSlug.ts +27 -0
- package/src/context/index.ts +24 -23
- package/src/context/resolveReferences.ts +28 -8
- package/src/context/transformJobOnlyVars.ts +5 -2
- package/src/context/utils/envVars.ts +2 -1
- package/src/deploy/base/deploy.ts +20 -18
- package/src/deploy/base/rollback.ts +8 -10
- package/src/deploy/base/stop.ts +8 -9
- package/src/deploy/cloudRun/artifactsRegistry.ts +9 -4
- package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +12 -7
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +3 -2
- package/src/deploy/cloudRun/createJobs/constants.ts +1 -0
- package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +20 -2
- package/src/deploy/cloudRun/createJobs/index.ts +17 -8
- package/src/deploy/cloudRun/index.ts +14 -6
- package/src/deploy/cloudRun/utils/createArgsString.ts +2 -1
- package/src/deploy/cloudRun/utils/database.ts +2 -2
- package/src/deploy/cloudRun/utils/jobName.ts +7 -2
- package/src/deploy/cloudSql/utils.ts +12 -9
- package/src/deploy/index.ts +2 -1
- package/src/deploy/kubernetes/cloudSql/index.ts +3 -2
- package/src/deploy/kubernetes/deployJob.ts +24 -10
- package/src/deploy/kubernetes/index.ts +15 -8
- package/src/deploy/kubernetes/kubeEnv.ts +8 -6
- package/src/deploy/kubernetes/kubeValues.ts +0 -1
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +2 -1
- package/src/deploy/types/base.ts +6 -0
- package/src/deploy/types/googleCloudRun.ts +2 -0
- package/src/index.ts +2 -1
- package/src/packageInfos.ts +10 -0
- package/src/pipeline/createAllJobs.ts +24 -10
- package/src/pipeline/createChildPipeline.ts +19 -8
- package/src/pipeline/createJobsForComponent.ts +14 -22
- package/src/pipeline/createMainPipeline.ts +88 -0
- package/src/pipeline/generatePipelineFiles.ts +29 -0
- package/src/pipeline/gitlab/createGitlabJobs.ts +174 -51
- package/src/pipeline/gitlab/createGitlabPipeline.ts +16 -14
- package/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.ts +46 -0
- package/src/pipeline/gitlab/gitlabReleaseJobs.ts +20 -0
- package/src/pipeline/index.ts +2 -0
- package/src/rules/index.ts +15 -9
- package/src/types/config.ts +11 -2
- package/src/types/context.ts +39 -26
- package/src/types/environmentContext.ts +12 -6
- package/src/types/gitlab-ci-yml.ts +0 -1
- package/src/types/gitlab-types.ts +5 -4
- package/src/types/jobs.ts +28 -3
- package/src/types/pipeline.ts +4 -0
- package/src/utils/writeFiles.ts +40 -0
- package/dist/deploy/cloudRun/createJobs/variables.d.ts +0 -5
- package/dist/deploy/cloudRun/createJobs/variables.js +0 -19
- package/dist/pipeline/commitInfo/getBuildId.d.ts +0 -6
- package/dist/pipeline/commitInfo/getCommitInfo.d.ts +0 -2
- package/src/deploy/cloudRun/createJobs/variables.ts +0 -21
- package/src/pipeline/commitInfo/getBuildId.ts +0 -17
- package/src/pipeline/commitInfo/getCommitInfo.ts +0 -15
|
@@ -13,15 +13,15 @@ const config: Config = {
|
|
|
13
13
|
deploy: {
|
|
14
14
|
type: "custom",
|
|
15
15
|
requiresDocker: true,
|
|
16
|
+
|
|
16
17
|
jobVars: {
|
|
17
18
|
secret: ["DEPLOY_API_KEY"],
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
},
|
|
19
|
+
},
|
|
20
|
+
runnerVariables: {
|
|
21
|
+
// if your deploy job requires more memory and/or cpu, you can increase them with those variables:
|
|
22
|
+
KUBERNETES_CPU_REQUEST: "1",
|
|
23
|
+
KUBERNETES_MEMORY_REQUEST: "1024Mi",
|
|
24
|
+
KUBERNETES_MEMORY_LIMIT: "2048Mi",
|
|
25
25
|
},
|
|
26
26
|
script: ["echo 'would deploy'"],
|
|
27
27
|
stopScript: ["echo 'would stop'"],
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
|
|
4
|
+
const config: Config = {
|
|
5
|
+
appName: "test-app",
|
|
6
|
+
customerName: "pan",
|
|
7
|
+
components: {
|
|
8
|
+
api: {
|
|
9
|
+
dir: "api",
|
|
10
|
+
build: {
|
|
11
|
+
type: "node",
|
|
12
|
+
},
|
|
13
|
+
vars: {
|
|
14
|
+
public: {
|
|
15
|
+
foo: "foo-value",
|
|
16
|
+
multiline: `line1
|
|
17
|
+
line2
|
|
18
|
+
line3
|
|
19
|
+
|
|
20
|
+
single quote: '
|
|
21
|
+
doouble quote: "
|
|
22
|
+
`,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
deploy: {
|
|
26
|
+
type: "google-cloudrun",
|
|
27
|
+
projectId: "asdf",
|
|
28
|
+
region: "asia-east1",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
api2: {
|
|
32
|
+
dir: "api",
|
|
33
|
+
build: {
|
|
34
|
+
type: "node",
|
|
35
|
+
},
|
|
36
|
+
vars: {
|
|
37
|
+
public: {
|
|
38
|
+
multiline_from_api: "${api:multiline}",
|
|
39
|
+
multiline2: `yeah
|
|
40
|
+
yeah2
|
|
41
|
+
yeah3
|
|
42
|
+
|
|
43
|
+
single quote: '
|
|
44
|
+
doouble quote: "
|
|
45
|
+
`,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
deploy: {
|
|
49
|
+
type: "kubernetes",
|
|
50
|
+
cluster: {
|
|
51
|
+
name: "some-cluster-name",
|
|
52
|
+
region: "europe-west6",
|
|
53
|
+
projectId: "some-project-id",
|
|
54
|
+
type: "gcloud",
|
|
55
|
+
domainCanonical: "panter.cloud",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
it("matches snapshot", async () => {
|
|
63
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
64
|
+
});
|
package/package.json
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
}
|
|
53
53
|
],
|
|
54
54
|
"license": "MIT",
|
|
55
|
-
"version": "1.
|
|
55
|
+
"version": "1.145.0",
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build:tsc": "yarn tsc",
|
|
58
58
|
"build": "yarn build:compile && yarn build:inline-variables && yarn build:bundle",
|
|
@@ -78,22 +78,19 @@
|
|
|
78
78
|
"@jest/globals": "^29.3.1",
|
|
79
79
|
"@types/child-process-promise": "^2.2.2",
|
|
80
80
|
"@types/jest": "^27.4.0",
|
|
81
|
-
"@types/js-yaml": "^4.0.9",
|
|
82
81
|
"@types/lodash": "^4.14.185",
|
|
83
|
-
"@types/node": "^
|
|
82
|
+
"@types/node": "^20.14.2",
|
|
84
83
|
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
|
|
85
84
|
"child-process-promise": "^2.2.1",
|
|
86
|
-
"eslint": "^8.7.0",
|
|
87
|
-
"js-yaml": "^4.1.0",
|
|
88
85
|
"json-schema-to-typescript": "^13.0.2",
|
|
89
86
|
"lodash": "^4.17.21",
|
|
90
87
|
"memoizee": "^0.4.15",
|
|
91
88
|
"path-equal": "1.1.3",
|
|
92
|
-
"slugify": "^1.6.3"
|
|
89
|
+
"slugify": "^1.6.3",
|
|
90
|
+
"yaml": "^2.4.5"
|
|
93
91
|
},
|
|
94
92
|
"dependencies": {
|
|
95
|
-
"string-replace-async": "^2.0.0",
|
|
96
93
|
"ts-node": "^10.4.0",
|
|
97
|
-
"typescript": "^4.5
|
|
94
|
+
"typescript": "^5.4.5"
|
|
98
95
|
}
|
|
99
96
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* this class represents a string that can be evaluated in bash scripts.
|
|
3
|
+
*
|
|
4
|
+
* you can do basic transforms like lowercase, but that does not return you a lowercase string, but instead an experssion represeting a lowercase string
|
|
5
|
+
*/
|
|
6
|
+
export class BashExpression {
|
|
7
|
+
constructor(private value: string | BashExpression) {}
|
|
8
|
+
public toJSON(): string {
|
|
9
|
+
return this.toString();
|
|
10
|
+
}
|
|
11
|
+
public toString(): string {
|
|
12
|
+
return this.value.toString();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @returns a bash expression to lowercase the string
|
|
18
|
+
*/
|
|
19
|
+
public toLowerCase(): BashExpression {
|
|
20
|
+
return this.transformWithCommand("awk '{print tolower($0)}'");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* concats a value to this one and returns a new BashExpression
|
|
24
|
+
* @param value
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
public concat(...values: Array<string | BashExpression>): BashExpression {
|
|
28
|
+
return new BashExpression(
|
|
29
|
+
this.toString().concat(...values.map((v) => v.toString()))
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public transformWithCommand(command: string): BashExpression {
|
|
34
|
+
return new BashExpression(
|
|
35
|
+
// see https://stackoverflow.com/a/2264537
|
|
36
|
+
`$(printf %s "${this.toString()}" | ${command})`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type StringOrBashExpression = string | BashExpression;
|
|
42
|
+
|
|
43
|
+
export const getBashVariable = (name: string) => new BashExpression(`$${name}`);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* joins bash expressions together with a joiner
|
|
47
|
+
* returns a bash expression if any of the parts is a bash expression
|
|
48
|
+
* returns a string otherwise
|
|
49
|
+
*
|
|
50
|
+
* @param parts
|
|
51
|
+
* @param joiner
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
export const joinBashExpressions = (
|
|
55
|
+
parts: Array<StringOrBashExpression>,
|
|
56
|
+
joiner = ""
|
|
57
|
+
): StringOrBashExpression => {
|
|
58
|
+
const anyIsBashExpression = parts.some((p) => p instanceof BashExpression);
|
|
59
|
+
if (anyIsBashExpression) {
|
|
60
|
+
return new BashExpression(
|
|
61
|
+
parts
|
|
62
|
+
.map((p) => (p instanceof BashExpression ? p.toString() : p))
|
|
63
|
+
.join(joiner)
|
|
64
|
+
);
|
|
65
|
+
} else {
|
|
66
|
+
return parts.join(joiner);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* escapes a string or bash expression for bash
|
|
72
|
+
* it mainly escapes double quotes
|
|
73
|
+
*/
|
|
74
|
+
export const bashEscape = (value: StringOrBashExpression | any) => {
|
|
75
|
+
if (value instanceof BashExpression) {
|
|
76
|
+
return value.toString(); // no need to escape bash expressions, as we want them to evaluate
|
|
77
|
+
}
|
|
78
|
+
// we wrap it in double quotes, so we need to escape them
|
|
79
|
+
if (typeof value === "string") return value.replace(/"/g, '\\"');
|
|
80
|
+
return value;
|
|
81
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PipelineType } from "../types/pipeline";
|
|
2
|
+
import type { BashExpression } from "./BashExpression";
|
|
3
|
+
|
|
4
|
+
export type BashExpressionPerPipelineType = {
|
|
5
|
+
[type in PipelineType]?: BashExpression | string;
|
|
6
|
+
} & {
|
|
7
|
+
default: BashExpression | string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const getBashExpressionPerPipelineType = (
|
|
11
|
+
definition: BashExpressionPerPipelineType,
|
|
12
|
+
pipelineType?: PipelineType
|
|
13
|
+
) => {
|
|
14
|
+
if (!pipelineType) return definition.default;
|
|
15
|
+
return definition[pipelineType] || definition.default;
|
|
16
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ScalarTag } from "yaml";
|
|
2
|
+
import { stringify } from "yaml";
|
|
3
|
+
import { BashExpression } from "./BashExpression";
|
|
4
|
+
|
|
5
|
+
const bashExpressionType: ScalarTag = {
|
|
6
|
+
tag: "",
|
|
7
|
+
resolve: (str) => {
|
|
8
|
+
// not really needed,but let's make typescript happy
|
|
9
|
+
return new BashExpression(str);
|
|
10
|
+
},
|
|
11
|
+
stringify(node: any, ctx: any) {
|
|
12
|
+
// we create a BLOCK_LITERAL
|
|
13
|
+
// but because bash will interpret the value, it may resolve to a multiline string
|
|
14
|
+
// so we need to indent every line using sed
|
|
15
|
+
return "|-\n" + node.value.transformWithCommand(`sed 's/^/${ctx.indent}/'`);
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
identify: (v: any) => v instanceof BashExpression,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/***
|
|
22
|
+
* creates a yaml string that can be used in bash scripts
|
|
23
|
+
* it handles BashExpressions correctly so that they can be evaluated in bash
|
|
24
|
+
*/
|
|
25
|
+
export const yamlBashString = (value: any) => {
|
|
26
|
+
return stringify(value, {
|
|
27
|
+
defaultStringType: "BLOCK_LITERAL",
|
|
28
|
+
defaultKeyType: "PLAIN",
|
|
29
|
+
customTags: [bashExpressionType],
|
|
30
|
+
aliasDuplicateObjects: false,
|
|
31
|
+
lineWidth: 0,
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* creates a bash script that writes a yaml string to a file
|
|
37
|
+
* @param value the yaml value to write, it supports BashExpressions
|
|
38
|
+
*/
|
|
39
|
+
export const writeBashYamlToFileScript = (value: any, filename: string) => {
|
|
40
|
+
return [
|
|
41
|
+
`cat > ${filename} <<EOF
|
|
42
|
+
${yamlBashString(value)}
|
|
43
|
+
EOF
|
|
44
|
+
`,
|
|
45
|
+
];
|
|
46
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UnspecifiedEnvVars } from "../types";
|
|
2
|
+
import { isNil } from "lodash";
|
|
3
|
+
import { bashEscape } from "./BashExpression";
|
|
4
|
+
|
|
5
|
+
export const getInjectVarsScript = (vars?: UnspecifiedEnvVars) => {
|
|
6
|
+
if (!vars) return [];
|
|
7
|
+
// filter out null and undefined values
|
|
8
|
+
return Object.entries(vars)
|
|
9
|
+
.filter(([, value]) => !isNil(value))
|
|
10
|
+
|
|
11
|
+
.map(([key, value]) => `export ${key}="${value ? bashEscape(value) : ""}"`);
|
|
12
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BashExpression } from "./BashExpression";
|
|
2
|
+
|
|
3
|
+
// from https://github.com/dsblv/string-replace-async/blob/main/index.js
|
|
4
|
+
// and adjusted a bit
|
|
5
|
+
export default async function replaceAsync(
|
|
6
|
+
string: string | BashExpression,
|
|
7
|
+
searchValue: any,
|
|
8
|
+
replacer: (
|
|
9
|
+
substring: string,
|
|
10
|
+
...args: any[]
|
|
11
|
+
) => Promise<string | BashExpression>
|
|
12
|
+
) {
|
|
13
|
+
const wasBashExpression = string instanceof BashExpression;
|
|
14
|
+
try {
|
|
15
|
+
// 1. Run fake pass of `replace`, collect values from `replacer` calls
|
|
16
|
+
// 2. Resolve them with `Promise.all`
|
|
17
|
+
// 3. Run `replace` with resolved values
|
|
18
|
+
const values: Array<Promise<string | BashExpression>> = [];
|
|
19
|
+
String.prototype.replace.call(
|
|
20
|
+
string.toString(),
|
|
21
|
+
searchValue,
|
|
22
|
+
function (...args) {
|
|
23
|
+
// eslint-disable-next-line prefer-spread
|
|
24
|
+
const result = replacer.apply(undefined, args);
|
|
25
|
+
values.push(result);
|
|
26
|
+
return "";
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
const resolvedValues = await Promise.all(values);
|
|
30
|
+
|
|
31
|
+
const containsBashExpression = resolvedValues.some(
|
|
32
|
+
(value) => value instanceof BashExpression
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const result = String.prototype.replace.call(
|
|
36
|
+
string.toString(),
|
|
37
|
+
searchValue,
|
|
38
|
+
function () {
|
|
39
|
+
return resolvedValues.shift()?.toString() ?? "";
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
if (wasBashExpression || containsBashExpression) {
|
|
43
|
+
return new BashExpression(result);
|
|
44
|
+
} else {
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
return Promise.reject(error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -15,7 +15,7 @@ import { writeDotEnv } from "./writeDotEnv";
|
|
|
15
15
|
export type AppBuildJobDefinition = Partial<CatladderJob>;
|
|
16
16
|
export const createAppBuildJob = (
|
|
17
17
|
context: Context,
|
|
18
|
-
{ script, variables, ...def }: AppBuildJobDefinition
|
|
18
|
+
{ script, variables, runnerVariables, ...def }: AppBuildJobDefinition
|
|
19
19
|
): CatladderJob => {
|
|
20
20
|
return merge(
|
|
21
21
|
{
|
|
@@ -26,12 +26,16 @@ export const createAppBuildJob = (
|
|
|
26
26
|
needs: [],
|
|
27
27
|
cache: [],
|
|
28
28
|
variables: {
|
|
29
|
-
...RUNNER_BUILD_RESOURCE_VARIABLES,
|
|
30
29
|
...(variables ?? {}),
|
|
31
30
|
...context.environment.envVars,
|
|
32
31
|
...context.environment.jobOnlyVars.build.envVars,
|
|
33
32
|
...(context.componentConfig.build.extraVars ?? {}),
|
|
34
33
|
},
|
|
34
|
+
runnerVariables: {
|
|
35
|
+
...RUNNER_BUILD_RESOURCE_VARIABLES,
|
|
36
|
+
...(runnerVariables ?? {}),
|
|
37
|
+
...(context.componentConfig.build.runnerVariables ?? {}),
|
|
38
|
+
},
|
|
35
39
|
|
|
36
40
|
script: [
|
|
37
41
|
...(context.componentConfig.dotEnv === true // don't build when set to `local`
|
|
@@ -2,6 +2,6 @@ import type { Context } from "../../types";
|
|
|
2
2
|
|
|
3
3
|
export const writeBuildInfo = (context: Context) => {
|
|
4
4
|
return [
|
|
5
|
-
`echo '{"id":"${context.
|
|
5
|
+
`echo '{"id":"${context.environment.envVars.BUILD_INFO_BUILD_ID}","time":"${context.environment.envVars.BUILD_INFO_BUILD_TIME}"}' > ${context.componentConfig.dir}/__build_info.json`,
|
|
6
6
|
];
|
|
7
7
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNil } from "lodash";
|
|
1
2
|
import type { Context } from "../../types";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -10,7 +11,11 @@ export const writeDotEnv = (context: Context) => {
|
|
|
10
11
|
|
|
11
12
|
// make key=value and sanitize multiline
|
|
12
13
|
const keyValueString = Object.entries(envVars)
|
|
13
|
-
|
|
14
|
+
// filter out null and undefined values
|
|
15
|
+
.filter(([, value]) => !isNil(value))
|
|
16
|
+
.map(
|
|
17
|
+
([key, value]) => `${key}=${value?.toString().replaceAll("\n", "\\n")}`
|
|
18
|
+
)
|
|
14
19
|
.join("\n");
|
|
15
20
|
|
|
16
21
|
return [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
2
|
import type { Context } from "../../types/context";
|
|
3
3
|
import { ensureArray } from "../../utils";
|
|
4
|
-
import { getDockerBuildDefaultScript
|
|
4
|
+
import { getDockerBuildDefaultScript } from "../docker";
|
|
5
5
|
import { isOfBuildType } from "../types";
|
|
6
6
|
|
|
7
7
|
import type { CatladderJob } from "../../types/jobs";
|
|
@@ -25,9 +25,7 @@ export const createCustomBuildJobs = (context: Context): CatladderJob[] => {
|
|
|
25
25
|
buildConfig.buildCommand !== null
|
|
26
26
|
? {
|
|
27
27
|
image: buildConfig.jobImage,
|
|
28
|
-
|
|
29
|
-
...RUNNER_BUILD_VARIABLES,
|
|
30
|
-
},
|
|
28
|
+
runnerVariables: RUNNER_BUILD_VARIABLES,
|
|
31
29
|
cache: buildConfig.jobCache,
|
|
32
30
|
services: buildConfig.jobServices,
|
|
33
31
|
script: [...(ensureArray(buildConfig.buildCommand) ?? [])],
|
|
@@ -13,7 +13,8 @@ const RUNNER_CUSTOM_TEST_VARIABLES = {
|
|
|
13
13
|
|
|
14
14
|
export const createCustomTestJobs = (context: Context): CatladderJob[] => {
|
|
15
15
|
// don't run tests after release
|
|
16
|
-
|
|
16
|
+
// TODO: this will be replaced by using rules
|
|
17
|
+
if (context.trigger === "taggedRelease") {
|
|
17
18
|
return [];
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -26,10 +27,10 @@ export const createCustomTestJobs = (context: Context): CatladderJob[] => {
|
|
|
26
27
|
const base: Omit<CatladderJob, "script" | "name"> = {
|
|
27
28
|
variables: {
|
|
28
29
|
APP_PATH: context.componentConfig.dir,
|
|
29
|
-
...RUNNER_CUSTOM_TEST_VARIABLES,
|
|
30
30
|
...context.environment.jobOnlyVars.build.envVars,
|
|
31
31
|
...(buildConfig.extraVars ?? {}),
|
|
32
32
|
},
|
|
33
|
+
runnerVariables: RUNNER_CUSTOM_TEST_VARIABLES,
|
|
33
34
|
services: buildConfig.jobServices,
|
|
34
35
|
cache: buildConfig.jobCache,
|
|
35
36
|
stage: "test",
|
package/src/build/docker.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "../deploy/cloudRun/artifactsRegistry";
|
|
14
14
|
import { gcloudServiceAccountLoginCommands } from "../deploy/cloudRun/utils/gcloudServiceAccountLoginCommands";
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const DOCKER_BUILD_RUNNER_REQUESTS = {
|
|
17
17
|
KUBERNETES_CPU_REQUEST: "0.5",
|
|
18
18
|
KUBERNETES_MEMORY_REQUEST: "1Gi",
|
|
19
19
|
KUBERNETES_MEMORY_LIMIT: "2Gi",
|
|
@@ -52,7 +52,8 @@ export const requiresDockerBuild = ({
|
|
|
52
52
|
isOfDeployType(deploy, "kubernetes", "google-cloudrun", "dockerTag") ||
|
|
53
53
|
(isOfDeployType(deploy, "custom") && deploy.requiresDocker);
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
// those need to be runner variables
|
|
56
|
+
const getDockerBuildRunnerVariables = () => ({
|
|
56
57
|
DOCKER_HOST: "tcp://0.0.0.0:2375",
|
|
57
58
|
DOCKER_TLS_CERTDIR: "",
|
|
58
59
|
DOCKER_DRIVER: "overlay2",
|
|
@@ -61,15 +62,12 @@ const getDockerBaseVariables = () => ({
|
|
|
61
62
|
|
|
62
63
|
export const getDockerBuildVariables = (context: Context) => {
|
|
63
64
|
return {
|
|
64
|
-
...DOCKER_RUNNER_BUILD_VARIABLES,
|
|
65
65
|
DOCKERFILE_ADDITIONS:
|
|
66
66
|
context.componentConfig.build.docker?.additionsBegin?.join("\n"),
|
|
67
67
|
DOCKERFILE_ADDITIONS_END:
|
|
68
68
|
context.componentConfig.build.docker?.additionsEnd?.join("\n"),
|
|
69
69
|
APP_DIR: context.componentConfig.dir,
|
|
70
|
-
|
|
71
70
|
DOCKER_DIR: ".", // relative to componentdir
|
|
72
|
-
...getDockerBaseVariables(),
|
|
73
71
|
|
|
74
72
|
...getDockerImageVariables(context),
|
|
75
73
|
};
|
|
@@ -77,7 +75,12 @@ export const getDockerBuildVariables = (context: Context) => {
|
|
|
77
75
|
|
|
78
76
|
export const DOCKER_BUILD_JOB_NAME = "🔨 docker";
|
|
79
77
|
|
|
80
|
-
export const getDockerJobBaseProps = (
|
|
78
|
+
export const getDockerJobBaseProps = (
|
|
79
|
+
context: Context
|
|
80
|
+
): Pick<
|
|
81
|
+
CatladderJob,
|
|
82
|
+
"image" | "services" | "variables" | "runnerVariables"
|
|
83
|
+
> => {
|
|
81
84
|
return {
|
|
82
85
|
image: getRunnerImage("docker-build"),
|
|
83
86
|
services: [
|
|
@@ -86,7 +89,8 @@ export const getDockerJobBaseProps = (context: Context) => {
|
|
|
86
89
|
command: ["--tls=false"],
|
|
87
90
|
},
|
|
88
91
|
],
|
|
89
|
-
variables:
|
|
92
|
+
variables: {},
|
|
93
|
+
runnerVariables: getDockerBuildRunnerVariables(),
|
|
90
94
|
};
|
|
91
95
|
};
|
|
92
96
|
|
|
@@ -105,6 +109,10 @@ export const createDockerBuildJobBase = (
|
|
|
105
109
|
},
|
|
106
110
|
{
|
|
107
111
|
variables: getDockerBuildVariables(context),
|
|
112
|
+
runnerVariables: {
|
|
113
|
+
...DOCKER_BUILD_RUNNER_REQUESTS,
|
|
114
|
+
...getDockerBuildRunnerVariables(),
|
|
115
|
+
},
|
|
108
116
|
},
|
|
109
117
|
def
|
|
110
118
|
);
|
|
@@ -25,9 +25,7 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
|
|
|
25
25
|
buildConfig.buildCommand !== null
|
|
26
26
|
? {
|
|
27
27
|
image: buildConfig.jobImage ?? defaultImage,
|
|
28
|
-
|
|
29
|
-
...NODE_RUNNER_BUILD_VARIABLES,
|
|
30
|
-
},
|
|
28
|
+
runnerVariables: NODE_RUNNER_BUILD_VARIABLES,
|
|
31
29
|
cache: [
|
|
32
30
|
...(ensureArray(buildConfig.jobCache) ?? []),
|
|
33
31
|
...getNodeCache(context),
|
|
@@ -9,7 +9,8 @@ import { createArtifactsConfig } from "../base/createArtifactsConfig";
|
|
|
9
9
|
|
|
10
10
|
export const createNodeTestJobs = (context: Context): CatladderJob[] => {
|
|
11
11
|
// don't run tests after release
|
|
12
|
-
|
|
12
|
+
// TODO: this will be replaced by using rules
|
|
13
|
+
if (context.trigger === "taggedRelease") {
|
|
13
14
|
return [];
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -18,10 +19,10 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
|
|
|
18
19
|
const base: Omit<CatladderJob, "script" | "name"> = {
|
|
19
20
|
variables: {
|
|
20
21
|
APP_PATH: context.componentConfig.dir,
|
|
21
|
-
...NODE_RUNNER_BUILD_VARIABLES,
|
|
22
22
|
...context.environment.jobOnlyVars.build.envVars,
|
|
23
23
|
...(buildConfig.extraVars ?? {}),
|
|
24
24
|
},
|
|
25
|
+
runnerVariables: NODE_RUNNER_BUILD_VARIABLES,
|
|
25
26
|
stage: "test",
|
|
26
27
|
needs: [],
|
|
27
28
|
envMode: "none",
|
package/src/build/node/yarn.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BashExpression } from "../../bash/BashExpression";
|
|
1
2
|
import type { Context } from "../../types";
|
|
2
3
|
import { ensureArray } from "../../utils";
|
|
3
4
|
import { collapseableSection } from "../../utils/gitlab";
|
|
@@ -53,11 +54,13 @@ const DOCKER_COPY_FILES = `COPY --chown=node:node $APP_DIR .`;
|
|
|
53
54
|
|
|
54
55
|
export const getDockerAppCopyAndBuildScript = (context: Context) => {
|
|
55
56
|
if (context.packageManagerInfo?.isClassic) {
|
|
56
|
-
return
|
|
57
|
+
return new BashExpression(
|
|
58
|
+
`
|
|
57
59
|
RUN ${YARN_INSTALL_CLASSIC} --production --ignore-scripts
|
|
58
60
|
${DOCKER_COPY_FILES}
|
|
59
61
|
RUN ${YARN_INSTALL_CLASSIC} --production
|
|
60
|
-
`.trim()
|
|
62
|
+
`.trim()
|
|
63
|
+
);
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
// yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
|
|
@@ -71,10 +74,12 @@ RUN ${YARN_INSTALL_CLASSIC} --production
|
|
|
71
74
|
|
|
72
75
|
// copy first everything and then install
|
|
73
76
|
// rebuild first does not work as it will run postinstall and that might require files in the app
|
|
74
|
-
return
|
|
77
|
+
return new BashExpression(
|
|
78
|
+
`
|
|
75
79
|
${DOCKER_COPY_FILES}
|
|
76
80
|
${maybeAddWorkspaceToolsCommand}
|
|
77
81
|
RUN ${YARN_BERRY_PROD_REBUILD}
|
|
78
82
|
|
|
79
|
-
`.trim()
|
|
83
|
+
`.trim()
|
|
84
|
+
);
|
|
80
85
|
};
|
package/src/build/rails/test.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { ensureArray, notNil } from "../../utils";
|
|
|
4
4
|
|
|
5
5
|
export const createRailsTestJobs = (context: Context): CatladderJob[] => {
|
|
6
6
|
// don't run tests after release
|
|
7
|
-
|
|
7
|
+
// TODO: this will be replaced by using rules
|
|
8
|
+
if (context.trigger === "taggedRelease") {
|
|
8
9
|
return [];
|
|
9
10
|
}
|
|
10
11
|
|
package/src/build/types.ts
CHANGED
|
@@ -43,9 +43,16 @@ export type BuildConfigBase = {
|
|
|
43
43
|
/**
|
|
44
44
|
* additional env vars for the buid jobs
|
|
45
45
|
*
|
|
46
|
-
* @deprecated use jobVars
|
|
46
|
+
* @deprecated use jobVars or runnerVariables
|
|
47
47
|
*/
|
|
48
48
|
extraVars?: Record<string, string>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* additional vars only for the runner.
|
|
52
|
+
* Also if you use services: that require env vars, you need to set them here.
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
runnerVariables?: Record<string, string>;
|
|
49
56
|
/**
|
|
50
57
|
* define the build command
|
|
51
58
|
*/
|
package/src/catladder-gitlab.ts
CHANGED
|
@@ -1,59 +1,12 @@
|
|
|
1
|
-
import { writeFileSync } from "fs";
|
|
2
|
-
import { dump } from "js-yaml";
|
|
3
1
|
import { readConfigSync } from "./config";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import type { PipelineTrigger } from "./types";
|
|
2
|
+
import { generatePipelineFiles } from "./pipeline/generatePipelineFiles";
|
|
3
|
+
import type { PipelineMode } from "./types";
|
|
7
4
|
|
|
8
|
-
const
|
|
9
|
-
CI_MERGE_REQUEST_ID,
|
|
10
|
-
CI_COMMIT_TAG,
|
|
11
|
-
CI_COMMIT_BRANCH,
|
|
12
|
-
CI_DEFAULT_BRANCH,
|
|
13
|
-
} = process.env;
|
|
5
|
+
const mode = process.argv[2] || "local";
|
|
14
6
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
? /^[0-9]+\.([0-9]+|x)\.x$/.test(CI_COMMIT_BRANCH)
|
|
19
|
-
: false;
|
|
20
|
-
const isMergeRequest = Boolean(CI_MERGE_REQUEST_ID);
|
|
21
|
-
const isTaggedRelease = Boolean(CI_COMMIT_TAG);
|
|
22
|
-
|
|
23
|
-
console.info(`catladder version ${PIPELINE_IMAGE_TAG}`);
|
|
24
|
-
|
|
25
|
-
const trigger: PipelineTrigger | null =
|
|
26
|
-
isMergeRequest || isHotfixBranch
|
|
27
|
-
? "mr"
|
|
28
|
-
: isDefaultBranch
|
|
29
|
-
? "mainBranch"
|
|
30
|
-
: isTaggedRelease
|
|
31
|
-
? "taggedRelease"
|
|
32
|
-
: null;
|
|
33
|
-
if (trigger) {
|
|
34
|
-
const config = readConfigSync()?.config;
|
|
35
|
-
if (!config) {
|
|
36
|
-
throw new Error("no catladder config found");
|
|
37
|
-
}
|
|
38
|
-
createChildPipeline("gitlab", trigger, config).then(
|
|
39
|
-
({ jobs, ...mainPipeline }) => {
|
|
40
|
-
// need to spread out the jobs
|
|
41
|
-
writeFileSync(`__pipeline.yml`, dump({ ...jobs, ...mainPipeline }), {
|
|
42
|
-
encoding: "utf-8",
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
} else {
|
|
47
|
-
throw new Error(
|
|
48
|
-
"no matching trigger: " +
|
|
49
|
-
JSON.stringify(
|
|
50
|
-
{
|
|
51
|
-
isMergeRequest,
|
|
52
|
-
isDefaultBranch,
|
|
53
|
-
isTaggedRelease,
|
|
54
|
-
},
|
|
55
|
-
null,
|
|
56
|
-
2
|
|
57
|
-
)
|
|
58
|
-
);
|
|
7
|
+
const config = readConfigSync()?.config;
|
|
8
|
+
if (!config) {
|
|
9
|
+
throw new Error("no catladder config found");
|
|
59
10
|
}
|
|
11
|
+
|
|
12
|
+
generatePipelineFiles(config, "gitlab", mode as PipelineMode<"gitlab">);
|