@catladder/pipeline 1.144.1 → 1.146.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 +40 -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 +10 -4
- 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 +4 -5
- 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/__utils__/helpers.ts +2 -2
- package/examples/custom-deploy.ts +7 -7
- package/examples/multiline-var.ts +64 -0
- package/package.json +5 -8
- package/scripts/generate-gitlab-ci-types.ts +2 -2
- 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/__tests__/createArtifactsConfig.test.ts +3 -3
- package/src/build/base/createAppBuildJob.ts +8 -4
- package/src/build/base/createArtifactsConfig.ts +2 -2
- package/src/build/base/index.ts +1 -1
- package/src/build/base/writeBuildInfo.ts +1 -1
- package/src/build/base/writeDotEnv.ts +6 -1
- package/src/build/custom/__tests__/testJob.test.ts +1 -1
- package/src/build/custom/buildJob.ts +4 -6
- package/src/build/custom/testJob.ts +6 -5
- package/src/build/docker.ts +21 -13
- package/src/build/index.ts +1 -1
- package/src/build/node/buildJob.ts +3 -5
- package/src/build/node/cache.ts +4 -4
- package/src/build/node/meteor.ts +1 -1
- package/src/build/node/testJob.ts +6 -5
- package/src/build/node/yarn.ts +14 -9
- 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/configruedEnvs.ts +6 -6
- package/src/config/readConfig.ts +4 -5
- 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/getEnvConfig.ts +1 -1
- package/src/context/getEnvType.ts +1 -1
- package/src/context/getEnvironment.ts +7 -30
- package/src/context/getEnvironmentContext.ts +25 -29
- package/src/context/getEnvironmentVariables.ts +72 -47
- package/src/context/getReviewSlug.ts +27 -0
- package/src/context/index.ts +26 -25
- package/src/context/resolveReferences.ts +40 -17
- package/src/context/transformJobOnlyVars.ts +6 -3
- package/src/context/utils/envVars.ts +5 -4
- package/src/deploy/base/deploy.ts +25 -23
- package/src/deploy/base/index.ts +1 -1
- package/src/deploy/base/rollback.ts +9 -11
- package/src/deploy/base/stop.ts +9 -10
- package/src/deploy/cloudRun/artifactsRegistry.ts +13 -8
- package/src/deploy/cloudRun/cleanup.ts +3 -3
- package/src/deploy/cloudRun/cloudRunRevisions.ts +3 -3
- package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +22 -17
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +7 -6
- package/src/deploy/cloudRun/createJobs/common.ts +1 -1
- package/src/deploy/cloudRun/createJobs/constants.ts +1 -0
- package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +25 -7
- package/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.ts +1 -1
- package/src/deploy/cloudRun/createJobs/index.ts +18 -9
- package/src/deploy/cloudRun/createJobs/volumes.ts +2 -2
- package/src/deploy/cloudRun/index.ts +22 -10
- package/src/deploy/cloudRun/utils/createArgsString.ts +3 -2
- package/src/deploy/cloudRun/utils/database.ts +7 -7
- package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +1 -1
- package/src/deploy/cloudRun/utils/jobName.ts +7 -2
- package/src/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.ts +1 -1
- package/src/deploy/cloudSql/utils.ts +13 -10
- package/src/deploy/index.ts +5 -4
- package/src/deploy/kubernetes/cloudSql/index.ts +6 -5
- package/src/deploy/kubernetes/deployJob.ts +28 -14
- package/src/deploy/kubernetes/index.ts +15 -8
- package/src/deploy/kubernetes/kubeEnv.ts +9 -7
- package/src/deploy/kubernetes/kubeValues.ts +5 -6
- package/src/deploy/kubernetes/mongodb.ts +1 -1
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +5 -4
- package/src/deploy/types/base.ts +6 -0
- package/src/deploy/types/googleCloudRun.ts +2 -0
- package/src/deploy/utils.ts +2 -2
- package/src/index.ts +2 -1
- package/src/packageInfos.ts +10 -0
- package/src/pipeline/createAllJobs.ts +28 -14
- package/src/pipeline/createChildPipeline.ts +20 -9
- package/src/pipeline/createJobsForComponent.ts +15 -23
- package/src/pipeline/createMainPipeline.ts +91 -0
- package/src/pipeline/generatePipelineFiles.ts +29 -0
- package/src/pipeline/getPipelineStages.ts +1 -1
- package/src/pipeline/gitlab/createGitlabJobs.ts +182 -59
- 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/pipeline/packageManager.ts +2 -2
- package/src/pipeline/yarn/yarnUtils.ts +7 -7
- package/src/rules/index.ts +15 -9
- package/src/types/config.ts +12 -3
- package/src/types/context.ts +39 -26
- package/src/types/environmentContext.ts +13 -7
- package/src/types/gitlab-ci-yml.ts +0 -1
- package/src/types/gitlab-types.ts +5 -4
- package/src/types/jobs.ts +29 -4
- package/src/types/pipeline.ts +4 -0
- 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 +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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RULES_MANUAL_RELEASE, RULES_RELEASE } from "../../rules";
|
|
2
|
+
import { getRunnerImage } from "../../runner";
|
|
3
|
+
|
|
4
|
+
export const getGitlabReleaseJobs = () => {
|
|
5
|
+
return {
|
|
6
|
+
["create release"]: {
|
|
7
|
+
stage: "release",
|
|
8
|
+
image: getRunnerImage("semantic-release"),
|
|
9
|
+
script: ["semanticRelease"],
|
|
10
|
+
rules: RULES_RELEASE,
|
|
11
|
+
},
|
|
12
|
+
["⚠️ force create release"]: {
|
|
13
|
+
stage: "release",
|
|
14
|
+
image: getRunnerImage("semantic-release"),
|
|
15
|
+
script: ["semanticRelease"],
|
|
16
|
+
needs: [],
|
|
17
|
+
rules: RULES_MANUAL_RELEASE,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
};
|
package/src/pipeline/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
export const getPackageManagerInfo = async (
|
|
12
12
|
config: Config,
|
|
13
|
-
componentName: string
|
|
13
|
+
componentName: string,
|
|
14
14
|
): Promise<PackageManagerInfo> => {
|
|
15
15
|
// currently only supports yarn
|
|
16
16
|
const version = await getYarnVersion();
|
|
@@ -20,7 +20,7 @@ export const getPackageManagerInfo = async (
|
|
|
20
20
|
const component = config.components[componentName];
|
|
21
21
|
const workspaces = await getWorkspaces(isClassic);
|
|
22
22
|
const currentWorkspace = workspaces.find((w) =>
|
|
23
|
-
pathEqual(component.dir, w.location)
|
|
23
|
+
pathEqual(component.dir, w.location),
|
|
24
24
|
);
|
|
25
25
|
const componentIsInWorkspace = Boolean(currentWorkspace);
|
|
26
26
|
const workspaceRoot = "."; // currently we assume the root folder, later on we might support nested workspaces
|
|
@@ -14,7 +14,7 @@ export const getYarnVersion = memoizee(
|
|
|
14
14
|
async () => {
|
|
15
15
|
return await execOrFail("yarn --version", "");
|
|
16
16
|
},
|
|
17
|
-
{ promise: true }
|
|
17
|
+
{ promise: true },
|
|
18
18
|
);
|
|
19
19
|
// export for mocking
|
|
20
20
|
export const getWorkspaces = memoizee(
|
|
@@ -23,23 +23,23 @@ export const getWorkspaces = memoizee(
|
|
|
23
23
|
? Object.values(
|
|
24
24
|
JSON.parse(
|
|
25
25
|
JSON.parse(await execOrFail("yarn workspaces --json info", "{}"))
|
|
26
|
-
?.data ?? "{}"
|
|
27
|
-
)
|
|
26
|
+
?.data ?? "{}",
|
|
27
|
+
),
|
|
28
28
|
)
|
|
29
29
|
: JSON.parse(
|
|
30
30
|
`[${(await execOrFail("yarn workspaces list --json --verbose", ""))
|
|
31
31
|
.trim()
|
|
32
32
|
.split("\n")
|
|
33
|
-
.join(",")}]
|
|
33
|
+
.join(",")}]`,
|
|
34
34
|
);
|
|
35
35
|
},
|
|
36
|
-
{ promise: true }
|
|
36
|
+
{ promise: true },
|
|
37
37
|
);
|
|
38
38
|
|
|
39
39
|
// recursivly get all workspace dependencies
|
|
40
40
|
export const getWorkspaceDependencies = (
|
|
41
41
|
ws: YarnWorkspace,
|
|
42
|
-
allWorkspaces: YarnWorkspace[]
|
|
42
|
+
allWorkspaces: YarnWorkspace[],
|
|
43
43
|
): string[] => {
|
|
44
44
|
return ws
|
|
45
45
|
? ([...ws.workspaceDependencies, ...ws.mismatchedWorkspaceDependencies]
|
|
@@ -47,7 +47,7 @@ export const getWorkspaceDependencies = (
|
|
|
47
47
|
// we have to do this recursivly
|
|
48
48
|
|
|
49
49
|
const otherWorkspace = allWorkspaces.find(
|
|
50
|
-
(w) => w.location === location
|
|
50
|
+
(w) => w.location === location,
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
if (otherWorkspace) {
|
package/src/rules/index.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { GitlabRule } from "../types";
|
|
2
|
+
export const RULE_CONDITION_MAIN_BRANCH =
|
|
3
|
+
"$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH";
|
|
2
4
|
|
|
5
|
+
export const RULE_IS_MAIN_BRANCH: GitlabRule = {
|
|
6
|
+
if: RULE_CONDITION_MAIN_BRANCH,
|
|
7
|
+
};
|
|
3
8
|
export const RULE_NEVER_ON_RELEASE_COMMIT: GitlabRule = {
|
|
4
9
|
if: "$CI_COMMIT_MESSAGE =~ /^chore\\(release\\).*/",
|
|
5
10
|
when: "never",
|
|
@@ -10,10 +15,16 @@ export const RULE_NEVER_ON_SCHEDULE: GitlabRule = {
|
|
|
10
15
|
when: "never",
|
|
11
16
|
};
|
|
12
17
|
|
|
18
|
+
export const RULE_IS_MERGE_REQUEST: GitlabRule = {
|
|
19
|
+
if: "$CI_MERGE_REQUEST_ID",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const RULE_IS_TAGGED_RELEASE: GitlabRule = {
|
|
23
|
+
if: "$CI_COMMIT_TAG",
|
|
24
|
+
};
|
|
25
|
+
|
|
13
26
|
export const RULES_ALWAYS: GitlabRule[] = [
|
|
14
|
-
|
|
15
|
-
if: "$CI_COMMIT_TAG",
|
|
16
|
-
},
|
|
27
|
+
RULE_IS_TAGGED_RELEASE,
|
|
17
28
|
RULE_NEVER_ON_RELEASE_COMMIT,
|
|
18
29
|
RULE_NEVER_ON_SCHEDULE,
|
|
19
30
|
{
|
|
@@ -22,14 +33,9 @@ export const RULES_ALWAYS: GitlabRule[] = [
|
|
|
22
33
|
{
|
|
23
34
|
if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH",
|
|
24
35
|
},
|
|
25
|
-
|
|
26
|
-
if: "$CI_MERGE_REQUEST_ID",
|
|
27
|
-
},
|
|
36
|
+
RULE_IS_MERGE_REQUEST,
|
|
28
37
|
];
|
|
29
38
|
|
|
30
|
-
export const RULE_CONDITION_MAIN_BRANCH =
|
|
31
|
-
"$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH";
|
|
32
|
-
|
|
33
39
|
export const RULE_CONDITION_HOTFIX_BRANCH =
|
|
34
40
|
"$CI_COMMIT_BRANCH =~ /^[0-9]+.([0-9]+|x).x$/";
|
|
35
41
|
|
package/src/types/config.ts
CHANGED
|
@@ -4,8 +4,14 @@ import type { DeployConfig } from "../deploy/types";
|
|
|
4
4
|
import type { CatladderJob } from "./jobs";
|
|
5
5
|
import type { Context } from "./context";
|
|
6
6
|
import type { PartialDeep } from "./utils";
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import type { PipelineType } from "..";
|
|
8
|
+
|
|
9
|
+
export const ALL_PIPELINE_TRIGGERS = [
|
|
10
|
+
"mainBranch",
|
|
11
|
+
"mr",
|
|
12
|
+
"taggedRelease",
|
|
13
|
+
] as const;
|
|
14
|
+
export type PipelineTrigger = (typeof ALL_PIPELINE_TRIGGERS)[number];
|
|
9
15
|
|
|
10
16
|
/**
|
|
11
17
|
* all env types with their trigger.
|
|
@@ -37,7 +43,7 @@ export const ENV_TYPES = {
|
|
|
37
43
|
export const getEnvTypesByTrigger = (trigger: PipelineTrigger) =>
|
|
38
44
|
Object.entries(ENV_TYPES)
|
|
39
45
|
.filter(([, e]) =>
|
|
40
|
-
(e.triggers as readonly PipelineTrigger[]).includes(trigger)
|
|
46
|
+
(e.triggers as readonly PipelineTrigger[]).includes(trigger),
|
|
41
47
|
)
|
|
42
48
|
.map(([e]) => e as EnvType);
|
|
43
49
|
|
|
@@ -61,6 +67,7 @@ export type EnvVars = {
|
|
|
61
67
|
* You can reuse vars from other components in the same project using ${componentName:variableName}
|
|
62
68
|
* EXAMPLE: A_VAR: "the other var is ${api:OTHER_VAR}"
|
|
63
69
|
*/
|
|
70
|
+
|
|
64
71
|
public?: Record<string, any>;
|
|
65
72
|
/**
|
|
66
73
|
* secret env vars. These vars can be managed with catladder/cli
|
|
@@ -175,6 +182,8 @@ export type ConfigProps = {
|
|
|
175
182
|
};
|
|
176
183
|
|
|
177
184
|
export type Config<C extends ConfigProps = never> = {
|
|
185
|
+
pipelineType?: PipelineType;
|
|
186
|
+
|
|
178
187
|
/**
|
|
179
188
|
* name of the customer or group
|
|
180
189
|
*/
|
package/src/types/context.ts
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StringOrBashExpression } from "../bash/BashExpression";
|
|
2
|
+
import type { PredefinedVariables, SecretEnvVar } from "../context";
|
|
2
3
|
import type {
|
|
3
4
|
PipelineTrigger,
|
|
4
5
|
ComponentConfig,
|
|
5
6
|
Config,
|
|
6
7
|
EnvType,
|
|
7
8
|
} from "./config";
|
|
9
|
+
import type { BaseStage, CatladderJob } from "./jobs";
|
|
10
|
+
import type { PipelineType } from "./pipeline";
|
|
8
11
|
|
|
9
|
-
export type
|
|
10
|
-
|
|
12
|
+
export type UnspecifiedEnvVars = Record<
|
|
13
|
+
string,
|
|
14
|
+
StringOrBashExpression | undefined | null
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
export type EnvironmentEnvVars<
|
|
18
|
+
V extends UnspecifiedEnvVars = UnspecifiedEnvVars,
|
|
19
|
+
> = {
|
|
20
|
+
envVars: V & UnspecifiedEnvVars;
|
|
11
21
|
secretEnvVarKeys: SecretEnvVar[];
|
|
12
22
|
};
|
|
13
23
|
export type EnvironmentEnvVarPart = {
|
|
14
|
-
host:
|
|
15
|
-
url:
|
|
24
|
+
host: StringOrBashExpression;
|
|
25
|
+
url: StringOrBashExpression;
|
|
16
26
|
|
|
17
27
|
/**
|
|
18
28
|
* vars that only are injected in certain jobs, but not elsewhere
|
|
@@ -21,35 +31,33 @@ export type EnvironmentEnvVarPart = {
|
|
|
21
31
|
deploy: EnvironmentEnvVars;
|
|
22
32
|
build: EnvironmentEnvVars;
|
|
23
33
|
};
|
|
24
|
-
} & EnvironmentEnvVars
|
|
34
|
+
} & EnvironmentEnvVars<PredefinedVariables>;
|
|
35
|
+
// FIXME: align with EnvironmentContext
|
|
25
36
|
export type Environment = {
|
|
26
|
-
host:
|
|
27
|
-
url:
|
|
37
|
+
host: StringOrBashExpression;
|
|
38
|
+
url: StringOrBashExpression;
|
|
28
39
|
/**
|
|
29
40
|
* the full name of the app. We use this as RELEASE_NAME in kubernetes and the service name in google cloud run
|
|
30
41
|
*/
|
|
31
|
-
fullName:
|
|
42
|
+
fullName: StringOrBashExpression;
|
|
32
43
|
|
|
33
|
-
gitlabEnvironment: {
|
|
34
|
-
name: string;
|
|
35
|
-
url?: string;
|
|
36
|
-
};
|
|
37
44
|
shortName: string;
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
/**
|
|
46
|
+
* the environment slug without component name.
|
|
47
|
+
*/
|
|
48
|
+
slugPrefix: StringOrBashExpression;
|
|
49
|
+
/**
|
|
50
|
+
* the review slug, if it is a review app, null otherwise
|
|
51
|
+
*/
|
|
52
|
+
reviewSlug: StringOrBashExpression | null;
|
|
53
|
+
/**
|
|
54
|
+
* the full environment slug, including the componentName
|
|
55
|
+
*/
|
|
56
|
+
slug: StringOrBashExpression;
|
|
40
57
|
|
|
41
58
|
envType: EnvType;
|
|
42
59
|
} & EnvironmentEnvVarPart;
|
|
43
60
|
|
|
44
|
-
export type CommitInfo = {
|
|
45
|
-
refName: string;
|
|
46
|
-
reviewSlug: string;
|
|
47
|
-
buildTime: string;
|
|
48
|
-
buildId: string;
|
|
49
|
-
trigger: PipelineTrigger;
|
|
50
|
-
currentVersion: string;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
61
|
export type YarnWorkspace = {
|
|
54
62
|
name: string;
|
|
55
63
|
location: string;
|
|
@@ -72,7 +80,6 @@ export type PackageManagerInfo = YarnPackageManagerInfo;
|
|
|
72
80
|
export type ContextBeforeConfig = {
|
|
73
81
|
componentName: string;
|
|
74
82
|
fullConfig: Config;
|
|
75
|
-
commitInfo?: CommitInfo;
|
|
76
83
|
packageManagerInfo?: PackageManagerInfo;
|
|
77
84
|
};
|
|
78
85
|
export type Context = {
|
|
@@ -80,6 +87,12 @@ export type Context = {
|
|
|
80
87
|
componentConfig: ComponentConfig;
|
|
81
88
|
fullConfig: Config;
|
|
82
89
|
environment: Environment;
|
|
83
|
-
|
|
90
|
+
|
|
91
|
+
trigger?: PipelineTrigger;
|
|
92
|
+
pipelineType?: PipelineType;
|
|
84
93
|
packageManagerInfo?: PackageManagerInfo;
|
|
85
94
|
};
|
|
95
|
+
|
|
96
|
+
export type CatladderJobWithContext<S = BaseStage> = CatladderJob<S> & {
|
|
97
|
+
context: Context;
|
|
98
|
+
};
|
|
@@ -1,33 +1,39 @@
|
|
|
1
|
+
import type { StringOrBashExpression } from "../bash/BashExpression";
|
|
1
2
|
import type { BuildConfigGeneric, BuildConfigType } from "../build";
|
|
2
3
|
import type { DeployConfigGeneric } from "../deploy";
|
|
3
4
|
import type { DeployConfigType } from "../deploy";
|
|
4
5
|
import type { Config, EnvConfigWithComponent, EnvType } from "./config";
|
|
5
|
-
import type {
|
|
6
|
+
import type { PipelineType } from "./pipeline";
|
|
6
7
|
|
|
7
8
|
export type EnvironmentContext<
|
|
8
9
|
B extends BuildConfigType,
|
|
9
|
-
D extends DeployConfigType
|
|
10
|
+
D extends DeployConfigType,
|
|
10
11
|
> = {
|
|
11
12
|
envConfigRaw: EnvConfigWithComponent;
|
|
12
13
|
buildConfigRaw: false | BuildConfigGeneric<B>;
|
|
13
14
|
deployConfigRaw: false | DeployConfigGeneric<D>;
|
|
14
|
-
|
|
15
|
+
|
|
15
16
|
env: string;
|
|
16
17
|
envType: EnvType;
|
|
17
18
|
componentName: string;
|
|
18
|
-
fullName:
|
|
19
|
+
fullName: StringOrBashExpression;
|
|
19
20
|
/**
|
|
20
21
|
* the environment slug without component name.
|
|
21
22
|
*/
|
|
22
|
-
environmentSlugPrefix:
|
|
23
|
+
environmentSlugPrefix: StringOrBashExpression;
|
|
24
|
+
/**
|
|
25
|
+
* the review slug, if it is a review app, null otherwise
|
|
26
|
+
*/
|
|
27
|
+
reviewSlug: StringOrBashExpression | null;
|
|
23
28
|
/**
|
|
24
29
|
* the full environment slug, including the componentName
|
|
25
30
|
*/
|
|
26
|
-
environmentSlug:
|
|
27
|
-
gitlabEnvironmentName: string;
|
|
31
|
+
environmentSlug: StringOrBashExpression;
|
|
28
32
|
|
|
29
33
|
/**
|
|
30
34
|
* the full catladder config
|
|
31
35
|
*/
|
|
32
36
|
fullConfig: Config;
|
|
37
|
+
|
|
38
|
+
pipelineType?: PipelineType;
|
|
33
39
|
};
|
|
@@ -8,11 +8,12 @@ import type {
|
|
|
8
8
|
export { Retry, Image as GitlabJobImage } from "./gitlab-ci-yml";
|
|
9
9
|
|
|
10
10
|
// Reports won't show up on MRs until https://gitlab.com/groups/gitlab-org/-/epics/8205
|
|
11
|
-
export
|
|
12
|
-
paths: string[];
|
|
13
|
-
}
|
|
11
|
+
export type Artifacts = GitlabCiArtifacts;
|
|
14
12
|
export type GitlabJobCache = Cache;
|
|
15
|
-
export type GitlabRule = Exclude<
|
|
13
|
+
export type GitlabRule = Exclude<
|
|
14
|
+
Exclude<Rules, null>[number],
|
|
15
|
+
string | string[] // we only use the object version
|
|
16
|
+
>;
|
|
16
17
|
export type GitlabEnvironment = Omit<
|
|
17
18
|
Exclude<JobTemplate["environment"], undefined | string>,
|
|
18
19
|
"deployment_tier"
|
package/src/types/jobs.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import type { UnspecifiedEnvVars } from "..";
|
|
2
|
+
import type {
|
|
3
|
+
BashExpression,
|
|
4
|
+
StringOrBashExpression,
|
|
5
|
+
} from "../bash/BashExpression";
|
|
1
6
|
import type {
|
|
2
7
|
Artifacts,
|
|
3
|
-
GitlabEnvironment,
|
|
4
8
|
GitlabJobCache,
|
|
5
9
|
GitlabRule,
|
|
6
10
|
GitlabJobImage,
|
|
7
11
|
GitlabJobDef,
|
|
12
|
+
GitlabEnvironment,
|
|
8
13
|
} from "./gitlab-types";
|
|
9
14
|
|
|
10
15
|
export const BASE_STAGES = [
|
|
@@ -16,11 +21,17 @@ export const BASE_STAGES = [
|
|
|
16
21
|
"rollback",
|
|
17
22
|
"stop",
|
|
18
23
|
] as const;
|
|
19
|
-
export type BaseStage = typeof BASE_STAGES[number];
|
|
24
|
+
export type BaseStage = (typeof BASE_STAGES)[number];
|
|
20
25
|
|
|
21
26
|
export type CatladderJobNeed =
|
|
22
27
|
| string
|
|
23
28
|
| { job: string; artifacts: boolean; componentName?: string };
|
|
29
|
+
|
|
30
|
+
export type CatladderJobEnvironmentConfig = {
|
|
31
|
+
action?: GitlabEnvironment["action"];
|
|
32
|
+
on_stop?: GitlabEnvironment["on_stop"];
|
|
33
|
+
auto_stop_in?: string;
|
|
34
|
+
};
|
|
24
35
|
export type CatladderJob<S = BaseStage> = {
|
|
25
36
|
/**
|
|
26
37
|
* the name of the job (without any env or app prefix and suffix)
|
|
@@ -91,14 +102,28 @@ export type CatladderJob<S = BaseStage> = {
|
|
|
91
102
|
/**
|
|
92
103
|
* variables to pass
|
|
93
104
|
*/
|
|
94
|
-
variables:
|
|
105
|
+
variables: UnspecifiedEnvVars | undefined;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* additional vars only for the runner.
|
|
109
|
+
* Also if you use services: that require env vars, you need to set them here.
|
|
110
|
+
*
|
|
111
|
+
*/
|
|
112
|
+
runnerVariables?: Record<string, string>;
|
|
95
113
|
|
|
96
114
|
/**
|
|
97
115
|
* whether failures are allowed
|
|
98
116
|
*/
|
|
99
117
|
allow_failure?: boolean;
|
|
100
118
|
|
|
101
|
-
|
|
119
|
+
/**
|
|
120
|
+
* gitlab environment config, subject to change
|
|
121
|
+
*/
|
|
122
|
+
environment?: CatladderJobEnvironmentConfig;
|
|
123
|
+
|
|
124
|
+
/** */
|
|
125
|
+
|
|
126
|
+
when?: GitlabRule["when"];
|
|
102
127
|
|
|
103
128
|
rules?: GitlabRule[];
|
|
104
129
|
|
package/src/types/pipeline.ts
CHANGED
|
@@ -2,6 +2,10 @@ import type { GitlabJobDef, GitlabPipeline } from "./gitlab-types";
|
|
|
2
2
|
|
|
3
3
|
export type PipelineType = "gitlab";
|
|
4
4
|
|
|
5
|
+
export type PipelineMode<T extends PipelineType> = T extends "gitlab"
|
|
6
|
+
? "childpipeline" | "local"
|
|
7
|
+
: "local";
|
|
8
|
+
|
|
5
9
|
export type PipelineJob<T extends PipelineType> = T extends "gitlab"
|
|
6
10
|
? GitlabJobDef
|
|
7
11
|
: never;
|
package/src/types/utils.ts
CHANGED
package/src/utils/gitlab.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isNil, mergeWith } from "lodash";
|
|
2
2
|
|
|
3
3
|
export function notNil<TValue>(
|
|
4
|
-
value: TValue | null | undefined
|
|
4
|
+
value: TValue | null | undefined,
|
|
5
5
|
): value is TValue {
|
|
6
6
|
return value !== null && value !== undefined;
|
|
7
7
|
}
|
|
@@ -14,6 +14,6 @@ export const mergeWithMergingArrays = <A, B>(obj1: A, obj2: B): A & B => {
|
|
|
14
14
|
return mergeWith({}, obj1, obj2, (prop1, prop2) =>
|
|
15
15
|
Array.isArray(prop1) && Array.isArray(prop2)
|
|
16
16
|
? [...prop1, ...prop2]
|
|
17
|
-
: undefined
|
|
17
|
+
: undefined,
|
|
18
18
|
);
|
|
19
19
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { writeFile } from "fs/promises";
|
|
2
|
+
import { stringify } from "yaml";
|
|
3
|
+
import packageInfos from "../packageInfos";
|
|
4
|
+
|
|
5
|
+
export const getAutoGeneratedHeader = (commentChar: string) => {
|
|
6
|
+
return [
|
|
7
|
+
"-------------------------------------------------",
|
|
8
|
+
`🐱 🔨 This file is generated by catladder v${packageInfos.version}`,
|
|
9
|
+
`🚨 Do not edit this file manually 🚨`,
|
|
10
|
+
"-------------------------------------------------",
|
|
11
|
+
]
|
|
12
|
+
.map((line) => `${commentChar} ${line}`)
|
|
13
|
+
.join("\n")
|
|
14
|
+
.concat("\n");
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const writeGeneratedFile = async (
|
|
18
|
+
path: string,
|
|
19
|
+
content: string,
|
|
20
|
+
{
|
|
21
|
+
commentChar,
|
|
22
|
+
}: {
|
|
23
|
+
commentChar: string;
|
|
24
|
+
},
|
|
25
|
+
) => {
|
|
26
|
+
await writeFile(
|
|
27
|
+
path,
|
|
28
|
+
// need to spread out the jobs, forgot why
|
|
29
|
+
[getAutoGeneratedHeader(commentChar), content].join("\n"),
|
|
30
|
+
{
|
|
31
|
+
encoding: "utf-8",
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const writeYamlfile = async (path: string, data: any) => {
|
|
37
|
+
await writeGeneratedFile(path, stringify(data), {
|
|
38
|
+
commentChar: "#",
|
|
39
|
+
});
|
|
40
|
+
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.getDeployJobVariables = void 0;
|
|
5
|
-
var js_yaml_1 = require("js-yaml");
|
|
6
|
-
var lodash_1 = require("lodash");
|
|
7
|
-
var __1 = require("../../..");
|
|
8
|
-
function getDeployJobVariables(context) {
|
|
9
|
-
var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, __1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
|
|
10
|
-
return {
|
|
11
|
-
CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
|
|
12
|
-
ENV_VARS: (0, js_yaml_1.dump)(allEnvVars, {
|
|
13
|
-
lineWidth: -1,
|
|
14
|
-
quotingType: "'",
|
|
15
|
-
forceQuotes: true
|
|
16
|
-
})
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
exports.getDeployJobVariables = getDeployJobVariables;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { dump } from "js-yaml";
|
|
2
|
-
import { omit } from "lodash";
|
|
3
|
-
|
|
4
|
-
import type { Context } from "../../../types/context";
|
|
5
|
-
|
|
6
|
-
import { GCLOUD_DEPLOY_CREDENTIALS_KEY } from "../../..";
|
|
7
|
-
|
|
8
|
-
export function getDeployJobVariables(context: Context) {
|
|
9
|
-
const allEnvVars = omit(
|
|
10
|
-
context.environment.envVars,
|
|
11
|
-
GCLOUD_DEPLOY_CREDENTIALS_KEY
|
|
12
|
-
);
|
|
13
|
-
return {
|
|
14
|
-
CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
|
|
15
|
-
ENV_VARS: dump(allEnvVars, {
|
|
16
|
-
lineWidth: -1,
|
|
17
|
-
quotingType: "'",
|
|
18
|
-
forceQuotes: true,
|
|
19
|
-
}),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { exec } from "child-process-promise";
|
|
2
|
-
|
|
3
|
-
export const getBuildId = async () =>
|
|
4
|
-
await exec("git describe --tags || git rev-parse HEAD").then((s) =>
|
|
5
|
-
s.stdout.trim()
|
|
6
|
-
);
|
|
7
|
-
|
|
8
|
-
// thx chat gpt
|
|
9
|
-
/**
|
|
10
|
-
* returns the last tagged version string Major.minor.patch
|
|
11
|
-
* returns 0.0.0 if there is no tag
|
|
12
|
-
*/
|
|
13
|
-
export const getCurrentVersionString = async () => {
|
|
14
|
-
return await exec(
|
|
15
|
-
'latest_tag=$(git describe --tags --abbrev=0 2>/dev/null); if [ -z "$latest_tag" ]; then echo "0.0.0"; else echo "${latest_tag#v}"; fi | cut -d "." -f 1-3'
|
|
16
|
-
).then((s) => s.stdout.trim());
|
|
17
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { CommitInfo } from "../../types";
|
|
2
|
-
import { getBuildId, getCurrentVersionString } from "./getBuildId";
|
|
3
|
-
export const getBaseCommitInfo = async (): Promise<
|
|
4
|
-
Omit<CommitInfo, "trigger">
|
|
5
|
-
> => ({
|
|
6
|
-
refName: process.env.CI_COMMIT_REF_NAME ?? "unknown",
|
|
7
|
-
reviewSlug: process.env.CI_MERGE_REQUEST_IID
|
|
8
|
-
? `mr${process.env.CI_MERGE_REQUEST_IID}`
|
|
9
|
-
: process.env.CI_COMMIT_REF_SLUG
|
|
10
|
-
? `hf${process.env.CI_COMMIT_REF_SLUG}`
|
|
11
|
-
: "unknown",
|
|
12
|
-
buildTime: new Date().toISOString(),
|
|
13
|
-
buildId: await getBuildId(),
|
|
14
|
-
currentVersion: await getCurrentVersionString(),
|
|
15
|
-
});
|