@catladder/pipeline 1.154.2 → 1.155.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/build/base/writeDotEnv.js +8 -0
- package/dist/build/node/buildJob.js +1 -1
- package/dist/build/node/cache.d.ts +3 -2
- package/dist/build/node/cache.js +11 -2
- package/dist/bundles/catladder-gitlab/index.js +2 -2
- package/dist/constants.js +1 -1
- package/dist/context/getBuildInfoVariables.d.ts +2 -3
- package/dist/context/getBuildInfoVariables.js +43 -17
- package/dist/context/getEnvironmentVariables.d.ts +0 -3
- package/dist/pipeline/yarn/yarnUtils.js +12 -11
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/jsonParse.d.ts +1 -0
- package/dist/utils/jsonParse.js +14 -0
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +28 -24
- package/examples/__snapshots__/native-app.ts.snap +0 -12
- package/package.json +1 -1
- package/src/build/base/writeDotEnv.ts +4 -0
- package/src/build/node/buildJob.ts +9 -1
- package/src/build/node/cache.ts +14 -1
- package/src/context/getBuildInfoVariables.ts +25 -30
- package/src/pipeline/yarn/yarnUtils.ts +8 -5
- package/src/utils/jsonParse.ts +7 -0
|
@@ -96,6 +96,13 @@ exports[`matches snapshot 1`] = `
|
|
|
96
96
|
],
|
|
97
97
|
"policy": "pull-push",
|
|
98
98
|
},
|
|
99
|
+
{
|
|
100
|
+
"key": "myWorkspace-turbo",
|
|
101
|
+
"paths": [
|
|
102
|
+
".turbo",
|
|
103
|
+
],
|
|
104
|
+
"policy": "pull-push",
|
|
105
|
+
},
|
|
99
106
|
],
|
|
100
107
|
"image": "path/to/docker/jobs-default:the-version",
|
|
101
108
|
"interruptible": true,
|
|
@@ -115,9 +122,6 @@ exports[`matches snapshot 1`] = `
|
|
|
115
122
|
ENV_SHORT=dev
|
|
116
123
|
APP_DIR=api
|
|
117
124
|
ENV_TYPE=dev
|
|
118
|
-
BUILD_INFO_BUILD_ID=$(git describe --tags 2>/dev/null || git rev-parse HEAD)
|
|
119
|
-
BUILD_INFO_BUILD_TIME=$CI_JOB_STARTED_AT
|
|
120
|
-
BUILD_INFO_CURRENT_VERSION=$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")
|
|
121
125
|
HOST=$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
122
126
|
ROOT_URL=https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
123
127
|
HOST_INTERNAL=$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
@@ -143,9 +147,6 @@ EOF",
|
|
|
143
147
|
ENV_SHORT=dev
|
|
144
148
|
APP_DIR=www
|
|
145
149
|
ENV_TYPE=dev
|
|
146
|
-
BUILD_INFO_BUILD_ID=$(git describe --tags 2>/dev/null || git rev-parse HEAD)
|
|
147
|
-
BUILD_INFO_BUILD_TIME=$CI_JOB_STARTED_AT
|
|
148
|
-
BUILD_INFO_CURRENT_VERSION=$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")
|
|
149
150
|
HOST=$(printf %s "pan-test-app-dev-www-$CL_dev_www_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
150
151
|
ROOT_URL=https://$(printf %s "pan-test-app-dev-www-$CL_dev_www_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
151
152
|
HOST_INTERNAL=$(printf %s "pan-test-app-dev-www-$CL_dev_www_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
@@ -1038,6 +1039,13 @@ EOF
|
|
|
1038
1039
|
],
|
|
1039
1040
|
"policy": "pull-push",
|
|
1040
1041
|
},
|
|
1042
|
+
{
|
|
1043
|
+
"key": "myWorkspace-turbo",
|
|
1044
|
+
"paths": [
|
|
1045
|
+
".turbo",
|
|
1046
|
+
],
|
|
1047
|
+
"policy": "pull-push",
|
|
1048
|
+
},
|
|
1041
1049
|
],
|
|
1042
1050
|
"image": "path/to/docker/jobs-default:the-version",
|
|
1043
1051
|
"interruptible": true,
|
|
@@ -1057,9 +1065,6 @@ EOF
|
|
|
1057
1065
|
ENV_SHORT=review
|
|
1058
1066
|
APP_DIR=api
|
|
1059
1067
|
ENV_TYPE=review
|
|
1060
|
-
BUILD_INFO_BUILD_ID=$(git describe --tags 2>/dev/null || git rev-parse HEAD)
|
|
1061
|
-
BUILD_INFO_BUILD_TIME=$CI_JOB_STARTED_AT
|
|
1062
|
-
BUILD_INFO_CURRENT_VERSION=$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")
|
|
1063
1068
|
HOST=$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
1064
1069
|
ROOT_URL=https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
1065
1070
|
HOST_INTERNAL=$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
@@ -1085,9 +1090,6 @@ EOF",
|
|
|
1085
1090
|
ENV_SHORT=review
|
|
1086
1091
|
APP_DIR=www
|
|
1087
1092
|
ENV_TYPE=review
|
|
1088
|
-
BUILD_INFO_BUILD_ID=$(git describe --tags 2>/dev/null || git rev-parse HEAD)
|
|
1089
|
-
BUILD_INFO_BUILD_TIME=$CI_JOB_STARTED_AT
|
|
1090
|
-
BUILD_INFO_CURRENT_VERSION=$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")
|
|
1091
1093
|
HOST=$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-www-$CL_review_www_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
1092
1094
|
ROOT_URL=https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-www-$CL_review_www_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
1093
1095
|
HOST_INTERNAL=$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-www-$CL_review_www_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
@@ -1949,6 +1951,13 @@ EOF
|
|
|
1949
1951
|
],
|
|
1950
1952
|
"policy": "pull-push",
|
|
1951
1953
|
},
|
|
1954
|
+
{
|
|
1955
|
+
"key": "myWorkspace-turbo",
|
|
1956
|
+
"paths": [
|
|
1957
|
+
".turbo",
|
|
1958
|
+
],
|
|
1959
|
+
"policy": "pull-push",
|
|
1960
|
+
},
|
|
1952
1961
|
],
|
|
1953
1962
|
"image": "path/to/docker/jobs-default:the-version",
|
|
1954
1963
|
"interruptible": true,
|
|
@@ -1968,9 +1977,6 @@ EOF
|
|
|
1968
1977
|
ENV_SHORT=prod
|
|
1969
1978
|
APP_DIR=api
|
|
1970
1979
|
ENV_TYPE=prod
|
|
1971
|
-
BUILD_INFO_BUILD_ID=$(git describe --tags 2>/dev/null || git rev-parse HEAD)
|
|
1972
|
-
BUILD_INFO_BUILD_TIME=$CI_JOB_STARTED_AT
|
|
1973
|
-
BUILD_INFO_CURRENT_VERSION=$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")
|
|
1974
1980
|
HOST=$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
1975
1981
|
ROOT_URL=https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
1976
1982
|
HOST_INTERNAL=$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
@@ -1996,9 +2002,6 @@ EOF",
|
|
|
1996
2002
|
ENV_SHORT=prod
|
|
1997
2003
|
APP_DIR=www
|
|
1998
2004
|
ENV_TYPE=prod
|
|
1999
|
-
BUILD_INFO_BUILD_ID=$(git describe --tags 2>/dev/null || git rev-parse HEAD)
|
|
2000
|
-
BUILD_INFO_BUILD_TIME=$CI_JOB_STARTED_AT
|
|
2001
|
-
BUILD_INFO_CURRENT_VERSION=$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")
|
|
2002
2005
|
HOST=$(printf %s "pan-test-app-prod-www-$CL_prod_www_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
2003
2006
|
ROOT_URL=https://$(printf %s "pan-test-app-prod-www-$CL_prod_www_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
2004
2007
|
HOST_INTERNAL=$(printf %s "pan-test-app-prod-www-$CL_prod_www_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
@@ -2072,6 +2075,13 @@ EOF",
|
|
|
2072
2075
|
],
|
|
2073
2076
|
"policy": "pull-push",
|
|
2074
2077
|
},
|
|
2078
|
+
{
|
|
2079
|
+
"key": "myWorkspace-turbo",
|
|
2080
|
+
"paths": [
|
|
2081
|
+
".turbo",
|
|
2082
|
+
],
|
|
2083
|
+
"policy": "pull-push",
|
|
2084
|
+
},
|
|
2075
2085
|
],
|
|
2076
2086
|
"image": "path/to/docker/jobs-default:the-version",
|
|
2077
2087
|
"interruptible": true,
|
|
@@ -2091,9 +2101,6 @@ EOF",
|
|
|
2091
2101
|
ENV_SHORT=stage
|
|
2092
2102
|
APP_DIR=api
|
|
2093
2103
|
ENV_TYPE=stage
|
|
2094
|
-
BUILD_INFO_BUILD_ID=$(git describe --tags 2>/dev/null || git rev-parse HEAD)
|
|
2095
|
-
BUILD_INFO_BUILD_TIME=$CI_JOB_STARTED_AT
|
|
2096
|
-
BUILD_INFO_CURRENT_VERSION=$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")
|
|
2097
2104
|
HOST=$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
2098
2105
|
ROOT_URL=https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
2099
2106
|
HOST_INTERNAL=$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
@@ -2119,9 +2126,6 @@ EOF",
|
|
|
2119
2126
|
ENV_SHORT=stage
|
|
2120
2127
|
APP_DIR=www
|
|
2121
2128
|
ENV_TYPE=stage
|
|
2122
|
-
BUILD_INFO_BUILD_ID=$(git describe --tags 2>/dev/null || git rev-parse HEAD)
|
|
2123
|
-
BUILD_INFO_BUILD_TIME=$CI_JOB_STARTED_AT
|
|
2124
|
-
BUILD_INFO_CURRENT_VERSION=$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")
|
|
2125
2129
|
HOST=$(printf %s "pan-test-app-stage-www-$CL_stage_www_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
2126
2130
|
ROOT_URL=https://$(printf %s "pan-test-app-stage-www-$CL_stage_www_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
2127
2131
|
HOST_INTERNAL=$(printf %s "pan-test-app-stage-www-$CL_stage_www_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')
|
|
@@ -647,9 +647,6 @@ EOF
|
|
|
647
647
|
ENV_SHORT=dev
|
|
648
648
|
APP_DIR=app
|
|
649
649
|
ENV_TYPE=dev
|
|
650
|
-
BUILD_INFO_BUILD_ID=$(git describe --tags 2>/dev/null || git rev-parse HEAD)
|
|
651
|
-
BUILD_INFO_BUILD_TIME=$CI_JOB_STARTED_AT
|
|
652
|
-
BUILD_INFO_CURRENT_VERSION=$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")
|
|
653
650
|
HOST=unknown-host.example.com
|
|
654
651
|
ROOT_URL=https://unknown-host.example.com
|
|
655
652
|
HOST_INTERNAL=unknown-host.example.com
|
|
@@ -1605,9 +1602,6 @@ EOF
|
|
|
1605
1602
|
ENV_SHORT=review
|
|
1606
1603
|
APP_DIR=app
|
|
1607
1604
|
ENV_TYPE=review
|
|
1608
|
-
BUILD_INFO_BUILD_ID=$(git describe --tags 2>/dev/null || git rev-parse HEAD)
|
|
1609
|
-
BUILD_INFO_BUILD_TIME=$CI_JOB_STARTED_AT
|
|
1610
|
-
BUILD_INFO_CURRENT_VERSION=$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")
|
|
1611
1605
|
HOST=unknown-host.example.com
|
|
1612
1606
|
ROOT_URL=https://unknown-host.example.com
|
|
1613
1607
|
HOST_INTERNAL=unknown-host.example.com
|
|
@@ -2722,9 +2716,6 @@ EOF
|
|
|
2722
2716
|
ENV_SHORT=prod
|
|
2723
2717
|
APP_DIR=app
|
|
2724
2718
|
ENV_TYPE=prod
|
|
2725
|
-
BUILD_INFO_BUILD_ID=$(git describe --tags 2>/dev/null || git rev-parse HEAD)
|
|
2726
|
-
BUILD_INFO_BUILD_TIME=$CI_JOB_STARTED_AT
|
|
2727
|
-
BUILD_INFO_CURRENT_VERSION=$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")
|
|
2728
2719
|
HOST=unknown-host.example.com
|
|
2729
2720
|
ROOT_URL=https://unknown-host.example.com
|
|
2730
2721
|
HOST_INTERNAL=unknown-host.example.com
|
|
@@ -2851,9 +2842,6 @@ EOF",
|
|
|
2851
2842
|
ENV_SHORT=stage
|
|
2852
2843
|
APP_DIR=app
|
|
2853
2844
|
ENV_TYPE=stage
|
|
2854
|
-
BUILD_INFO_BUILD_ID=$(git describe --tags 2>/dev/null || git rev-parse HEAD)
|
|
2855
|
-
BUILD_INFO_BUILD_TIME=$CI_JOB_STARTED_AT
|
|
2856
|
-
BUILD_INFO_CURRENT_VERSION=$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")
|
|
2857
2845
|
HOST=unknown-host.example.com
|
|
2858
2846
|
ROOT_URL=https://unknown-host.example.com
|
|
2859
2847
|
HOST_INTERNAL=unknown-host.example.com
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isNil } from "lodash";
|
|
2
2
|
import type { ComponentContext } from "../../types";
|
|
3
3
|
import { collapseableSection } from "../../utils/gitlab";
|
|
4
|
+
import { ALL_BUILD_VARIABLES } from "../../context/getBuildInfoVariables";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* writes a .env file in the components folder
|
|
@@ -14,6 +15,9 @@ export const writeDotEnv = (context: ComponentContext) => {
|
|
|
14
15
|
const keyValueString = Object.entries(envVars)
|
|
15
16
|
// filter out null and undefined values
|
|
16
17
|
.filter(([, value]) => !isNil(value))
|
|
18
|
+
// filter out build variables, since they may interfer with caching like turbo
|
|
19
|
+
// build variables are rarely used anyway and we may treat them differently in the future
|
|
20
|
+
.filter(([key]) => !ALL_BUILD_VARIABLES.includes(key))
|
|
17
21
|
.map(
|
|
18
22
|
([key, value]) => `${key}=${value?.toString().replaceAll("\n", "\\n")}`,
|
|
19
23
|
)
|
|
@@ -15,7 +15,12 @@ import type { DockerBuildJobDefinition } from "../docker";
|
|
|
15
15
|
import { getDockerBuildScriptWithBuiltInDockerFile } from "../docker";
|
|
16
16
|
import type { BuildConfigDocker } from "../types";
|
|
17
17
|
import { isOfBuildType } from "../types";
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
getNextCache,
|
|
20
|
+
getNodeCache,
|
|
21
|
+
getWorkspaceDefaultCaches,
|
|
22
|
+
getYarnCache,
|
|
23
|
+
} from "./cache";
|
|
19
24
|
import { NODE_RUNNER_BUILD_VARIABLES } from "./constants";
|
|
20
25
|
import { getDockerAppCopyAndBuildScript, getYarnInstall } from "./yarn";
|
|
21
26
|
|
|
@@ -57,6 +62,9 @@ export const createNodeBuildJobDefinition = (
|
|
|
57
62
|
...(ensureArray(buildConfig.jobCache) ?? []),
|
|
58
63
|
...getNodeCache(context),
|
|
59
64
|
...getNextCache(context),
|
|
65
|
+
...(context.type === "workspace"
|
|
66
|
+
? getWorkspaceDefaultCaches(context)
|
|
67
|
+
: []),
|
|
60
68
|
],
|
|
61
69
|
script: [...yarnInstall, ...(ensureArray(buildConfig.buildCommand) ?? [])],
|
|
62
70
|
jobTags: buildConfig.jobTags,
|
package/src/build/node/cache.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { uniq } from "lodash";
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import slugify from "slugify";
|
|
4
|
-
import type { Context } from "../../types/context";
|
|
4
|
+
import type { Context, WorkspaceContext } from "../../types/context";
|
|
5
5
|
import type { GitlabJobCache } from "../../types/gitlab-types";
|
|
6
6
|
|
|
7
7
|
export const getYarnCache = (
|
|
@@ -80,3 +80,16 @@ export const getNextCache = (context: Context): GitlabJobCache[] => {
|
|
|
80
80
|
},
|
|
81
81
|
];
|
|
82
82
|
};
|
|
83
|
+
|
|
84
|
+
export const getWorkspaceDefaultCaches = (
|
|
85
|
+
context: WorkspaceContext,
|
|
86
|
+
): GitlabJobCache[] => {
|
|
87
|
+
return [
|
|
88
|
+
{
|
|
89
|
+
// turbo repo
|
|
90
|
+
key: context.name + "-turbo",
|
|
91
|
+
policy: "pull-push",
|
|
92
|
+
paths: [join(context.build.dir, ".turbo")],
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
};
|
|
@@ -1,41 +1,36 @@
|
|
|
1
1
|
import { BashExpression } from "../bash/BashExpression";
|
|
2
2
|
import type { BashExpressionPerPipelineType } from "../bash/bashExpressionPerPipelineType";
|
|
3
3
|
import { getBashExpressionPerPipelineType } from "../bash/bashExpressionPerPipelineType";
|
|
4
|
-
import type { BuildConfig } from "../build";
|
|
5
4
|
import type { EnvironmentContext } from "../types/environmentContext";
|
|
6
5
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
const BUILD_VARIABLES = {
|
|
7
|
+
BUILD_INFO_BUILD_ID: {
|
|
8
|
+
default: new BashExpression(
|
|
9
|
+
`$(git describe --tags 2>/dev/null || git rev-parse HEAD)`,
|
|
10
|
+
),
|
|
11
|
+
},
|
|
12
|
+
BUILD_INFO_BUILD_TIME: {
|
|
13
|
+
default: "unknown-build-time",
|
|
14
|
+
gitlab: new BashExpression(`$CI_JOB_STARTED_AT`),
|
|
15
|
+
},
|
|
16
|
+
BUILD_INFO_CURRENT_VERSION: {
|
|
17
|
+
default: new BashExpression(
|
|
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\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")`,
|
|
20
|
+
),
|
|
21
|
+
},
|
|
22
|
+
} satisfies {
|
|
23
|
+
[key: string]: BashExpressionPerPipelineType;
|
|
22
24
|
};
|
|
23
25
|
|
|
26
|
+
export const ALL_BUILD_VARIABLES = Object.keys(BUILD_VARIABLES);
|
|
24
27
|
export const getBuildInfoVariables = (ctx: EnvironmentContext) => {
|
|
25
28
|
const { pipelineType } = ctx;
|
|
26
29
|
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
pipelineType,
|
|
31
|
-
),
|
|
32
|
-
|
|
33
|
-
BUILD_TIME,
|
|
34
|
-
pipelineType,
|
|
35
|
-
),
|
|
36
|
-
BUILD_INFO_CURRENT_VERSION: getBashExpressionPerPipelineType(
|
|
37
|
-
CURRENT_VERSION,
|
|
38
|
-
pipelineType,
|
|
39
|
-
),
|
|
40
|
-
};
|
|
30
|
+
return Object.fromEntries(
|
|
31
|
+
Object.entries(BUILD_VARIABLES).map(([key, value]) => [
|
|
32
|
+
key,
|
|
33
|
+
getBashExpressionPerPipelineType(value, pipelineType),
|
|
34
|
+
]),
|
|
35
|
+
);
|
|
41
36
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { exec } from "child-process-promise";
|
|
2
2
|
import memoizee from "memoizee";
|
|
3
|
-
import type {
|
|
3
|
+
import type { YarnWorkspace } from "../../types";
|
|
4
|
+
import { jsonParseOrThrow } from "../../utils/jsonParse";
|
|
4
5
|
|
|
5
6
|
const execOrFail = async (cmd: string, onFail: string): Promise<string> => {
|
|
6
7
|
try {
|
|
@@ -16,17 +17,19 @@ export const getYarnVersion = memoizee(
|
|
|
16
17
|
},
|
|
17
18
|
{ promise: true },
|
|
18
19
|
);
|
|
20
|
+
|
|
19
21
|
// export for mocking
|
|
20
22
|
export const getWorkspaces = memoizee(
|
|
21
23
|
async (isClassic: boolean): Promise<Array<YarnWorkspace>> => {
|
|
22
24
|
return isClassic
|
|
23
25
|
? Object.values(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
jsonParseOrThrow(
|
|
27
|
+
jsonParseOrThrow(
|
|
28
|
+
await execOrFail("yarn workspaces --json info", "{}"),
|
|
29
|
+
)?.data ?? "{}",
|
|
27
30
|
),
|
|
28
31
|
)
|
|
29
|
-
:
|
|
32
|
+
: jsonParseOrThrow(
|
|
30
33
|
`[${(await execOrFail("yarn workspaces list --json --verbose", ""))
|
|
31
34
|
.trim()
|
|
32
35
|
.split("\n")
|