@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.
Files changed (335) hide show
  1. package/dist/bash/BashExpression.d.ts +40 -0
  2. package/dist/bash/BashExpression.js +124 -0
  3. package/dist/bash/bashExpressionPerPipelineType.d.ts +6 -0
  4. package/dist/bash/bashExpressionPerPipelineType.js +11 -0
  5. package/dist/bash/bashYaml.d.ts +10 -0
  6. package/dist/bash/bashYaml.js +46 -0
  7. package/dist/bash/getInjectVarsScript.d.ts +2 -0
  8. package/dist/bash/getInjectVarsScript.js +45 -0
  9. package/dist/bash/replaceAsync.d.ts +2 -0
  10. package/dist/{pipeline/commitInfo/getCommitInfo.js → bash/replaceAsync.js} +49 -21
  11. package/dist/build/base/__tests__/createArtifactsConfig.test.js +3 -1
  12. package/dist/build/base/constants.js +3 -1
  13. package/dist/build/base/createAppBuildJob.d.ts +2 -1
  14. package/dist/build/base/createAppBuildJob.js +10 -6
  15. package/dist/build/base/createArtifactsConfig.d.ts +1 -1
  16. package/dist/build/base/createArtifactsConfig.js +3 -1
  17. package/dist/build/base/index.js +3 -1
  18. package/dist/build/base/writeBuildInfo.js +4 -3
  19. package/dist/build/base/writeDotEnv.js +12 -3
  20. package/dist/build/custom/__tests__/testJob.test.js +3 -1
  21. package/dist/build/custom/buildJob.js +4 -12
  22. package/dist/build/custom/index.js +3 -1
  23. package/dist/build/custom/testJob.d.ts +1 -1
  24. package/dist/build/custom/testJob.js +18 -14
  25. package/dist/build/docker.d.ts +5 -31
  26. package/dist/build/docker.js +16 -9
  27. package/dist/build/index.d.ts +1 -1
  28. package/dist/build/index.js +13 -7
  29. package/dist/build/node/buildJob.js +4 -12
  30. package/dist/build/node/cache.js +6 -3
  31. package/dist/build/node/constants.js +3 -1
  32. package/dist/build/node/index.js +3 -1
  33. package/dist/build/node/meteor.js +5 -2
  34. package/dist/build/node/testJob.js +18 -14
  35. package/dist/build/node/yarn.d.ts +3 -2
  36. package/dist/build/node/yarn.js +6 -3
  37. package/dist/build/rails/build.js +3 -1
  38. package/dist/build/rails/index.js +3 -1
  39. package/dist/build/rails/test.js +15 -11
  40. package/dist/build/sbom.js +3 -1
  41. package/dist/build/types.d.ts +24 -18
  42. package/dist/build/types.js +3 -1
  43. package/dist/bundles/catladder-gitlab/index.js +3 -3
  44. package/dist/catladder-gitlab.js +10 -54
  45. package/dist/config/__tests__/configruedEnvs.test.js +3 -1
  46. package/dist/config/configruedEnvs.js +3 -1
  47. package/dist/config/index.js +13 -7
  48. package/dist/config/readConfig.js +6 -5
  49. package/dist/constants.js +5 -3
  50. package/dist/context/__tests__/resolveReferences.test.js +40 -8
  51. package/dist/context/getBuildInfoVariables.d.ts +7 -0
  52. package/dist/context/getBuildInfoVariables.js +29 -0
  53. package/dist/context/getEnvConfig.js +3 -1
  54. package/dist/context/getEnvType.js +3 -1
  55. package/dist/context/getEnvironment.d.ts +3 -3
  56. package/dist/context/getEnvironment.js +10 -14
  57. package/dist/context/getEnvironmentContext.d.ts +7 -3
  58. package/dist/context/getEnvironmentContext.js +21 -11
  59. package/dist/context/getEnvironmentVariables.d.ts +26 -5
  60. package/dist/context/getEnvironmentVariables.js +40 -25
  61. package/dist/context/getLabels.js +4 -2
  62. package/dist/context/getReviewSlug.d.ts +4 -0
  63. package/dist/context/getReviewSlug.js +22 -0
  64. package/dist/context/index.d.ts +12 -3
  65. package/dist/context/index.js +21 -15
  66. package/dist/context/resolveReferences.d.ts +3 -1
  67. package/dist/context/resolveReferences.js +53 -21
  68. package/dist/context/transformJobOnlyVars.d.ts +5 -2
  69. package/dist/context/transformJobOnlyVars.js +4 -2
  70. package/dist/context/utils/envVars.d.ts +1 -1
  71. package/dist/context/utils/envVars.js +5 -2
  72. package/dist/defaults/index.js +3 -1
  73. package/dist/deploy/base/deploy.d.ts +1 -1
  74. package/dist/deploy/base/deploy.js +12 -11
  75. package/dist/deploy/base/index.js +3 -1
  76. package/dist/deploy/base/rollback.d.ts +1 -1
  77. package/dist/deploy/base/rollback.js +13 -9
  78. package/dist/deploy/base/stop.d.ts +1 -1
  79. package/dist/deploy/base/stop.js +16 -11
  80. package/dist/deploy/base/types.d.ts +1 -1
  81. package/dist/deploy/base/types.js +3 -1
  82. package/dist/deploy/base/variables.js +3 -1
  83. package/dist/deploy/cloudRun/artifactsRegistry.d.ts +2 -1
  84. package/dist/deploy/cloudRun/artifactsRegistry.js +6 -4
  85. package/dist/deploy/cloudRun/cleanup.js +3 -1
  86. package/dist/deploy/cloudRun/cloudRunRevisions.js +3 -1
  87. package/dist/deploy/cloudRun/createJobs/cloudRunJobs.js +8 -5
  88. package/dist/deploy/cloudRun/createJobs/cloudRunServices.d.ts +2 -2
  89. package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +6 -3
  90. package/dist/deploy/cloudRun/createJobs/common.d.ts +3 -3
  91. package/dist/deploy/cloudRun/createJobs/common.js +3 -1
  92. package/dist/deploy/cloudRun/createJobs/constants.d.ts +1 -0
  93. package/dist/deploy/cloudRun/createJobs/constants.js +7 -0
  94. package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +10 -4
  95. package/dist/deploy/cloudRun/createJobs/getCloudRunStopScripts.js +3 -1
  96. package/dist/deploy/cloudRun/createJobs/index.js +25 -8
  97. package/dist/deploy/cloudRun/createJobs/volumes.js +3 -1
  98. package/dist/deploy/cloudRun/index.js +5 -3
  99. package/dist/deploy/cloudRun/utils/createArgsString.d.ts +2 -1
  100. package/dist/deploy/cloudRun/utils/createArgsString.js +3 -1
  101. package/dist/deploy/cloudRun/utils/database.js +13 -13
  102. package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.js +3 -1
  103. package/dist/deploy/cloudRun/utils/getServiceName.d.ts +1 -1
  104. package/dist/deploy/cloudRun/utils/getServiceName.js +3 -1
  105. package/dist/deploy/cloudRun/utils/jobName.d.ts +2 -1
  106. package/dist/deploy/cloudRun/utils/jobName.js +4 -2
  107. package/dist/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.js +3 -1
  108. package/dist/deploy/cloudSql/utils.d.ts +2 -1
  109. package/dist/deploy/cloudSql/utils.js +7 -2
  110. package/dist/deploy/custom/deployJob.js +3 -1
  111. package/dist/deploy/custom/index.js +3 -1
  112. package/dist/deploy/dockerTag/deployJob.js +3 -1
  113. package/dist/deploy/dockerTag/index.js +3 -1
  114. package/dist/deploy/index.d.ts +4 -3
  115. package/dist/deploy/index.js +13 -7
  116. package/dist/deploy/kubernetes/additionalSecretKeys.js +3 -1
  117. package/dist/deploy/kubernetes/cloudSql/index.d.ts +3 -2
  118. package/dist/deploy/kubernetes/cloudSql/index.js +6 -4
  119. package/dist/deploy/kubernetes/deployJob.js +22 -15
  120. package/dist/deploy/kubernetes/index.js +51 -14
  121. package/dist/deploy/kubernetes/kubeEnv.d.ts +3 -2
  122. package/dist/deploy/kubernetes/kubeEnv.js +7 -4
  123. package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
  124. package/dist/deploy/kubernetes/kubeValues.js +4 -5
  125. package/dist/deploy/kubernetes/mongodb.js +3 -1
  126. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +2 -1
  127. package/dist/deploy/kubernetes/processSecretsAsFiles.js +3 -1
  128. package/dist/deploy/sbom.js +3 -1
  129. package/dist/deploy/types/base.d.ts +8 -2
  130. package/dist/deploy/types/base.js +3 -1
  131. package/dist/deploy/types/custom.d.ts +1 -1
  132. package/dist/deploy/types/custom.js +3 -1
  133. package/dist/deploy/types/dockerTag.d.ts +1 -1
  134. package/dist/deploy/types/dockerTag.js +3 -1
  135. package/dist/deploy/types/googleCloudRun.d.ts +19 -18
  136. package/dist/deploy/types/googleCloudRun.js +3 -1
  137. package/dist/deploy/types/index.d.ts +6 -6
  138. package/dist/deploy/types/index.js +13 -7
  139. package/dist/deploy/types/kubernetes.d.ts +22 -22
  140. package/dist/deploy/types/kubernetes.js +3 -1
  141. package/dist/deploy/utils.js +3 -1
  142. package/dist/index.d.ts +3 -2
  143. package/dist/index.js +16 -9
  144. package/dist/packageInfos.d.ts +2 -0
  145. package/dist/packageInfos.js +14 -0
  146. package/dist/pipeline/createAllJobs.d.ts +13 -5
  147. package/dist/pipeline/createAllJobs.js +21 -10
  148. package/dist/pipeline/createChildPipeline.d.ts +1 -1
  149. package/dist/pipeline/createChildPipeline.js +24 -7
  150. package/dist/pipeline/createJobsForComponent.d.ts +3 -3
  151. package/dist/pipeline/createJobsForComponent.js +19 -18
  152. package/dist/pipeline/createMainPipeline.d.ts +3 -0
  153. package/dist/pipeline/createMainPipeline.js +248 -0
  154. package/dist/pipeline/generatePipelineFiles.d.ts +2 -0
  155. package/dist/pipeline/generatePipelineFiles.js +178 -0
  156. package/dist/pipeline/getPipelineStages.js +3 -1
  157. package/dist/pipeline/gitlab/createGitlabJobs.d.ts +15 -5
  158. package/dist/pipeline/gitlab/createGitlabJobs.js +98 -25
  159. package/dist/pipeline/gitlab/createGitlabPipeline.d.ts +7 -2
  160. package/dist/pipeline/gitlab/createGitlabPipeline.js +34 -17
  161. package/dist/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.d.ts +1 -0
  162. package/dist/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.js +29 -0
  163. package/dist/pipeline/gitlab/gitlabReleaseJobs.d.ts +33 -0
  164. package/dist/pipeline/gitlab/gitlabReleaseJobs.js +24 -0
  165. package/dist/pipeline/index.d.ts +3 -1
  166. package/dist/pipeline/index.js +16 -8
  167. package/dist/pipeline/packageManager.js +4 -2
  168. package/dist/pipeline/yarn/yarnUtils.js +6 -4
  169. package/dist/rules/index.d.ts +4 -1
  170. package/dist/rules/index.js +25 -18
  171. package/dist/runner/index.d.ts +1 -1
  172. package/dist/runner/index.js +3 -1
  173. package/dist/tsconfig.tsbuildinfo +1 -1
  174. package/dist/types/config.d.ts +18 -15
  175. package/dist/types/config.js +5 -2
  176. package/dist/types/context.d.ts +37 -32
  177. package/dist/types/context.js +3 -1
  178. package/dist/types/environmentContext.d.ts +11 -7
  179. package/dist/types/environmentContext.js +3 -1
  180. package/dist/types/gitlab-ci-yml.d.ts +30 -30
  181. package/dist/types/gitlab-ci-yml.js +3 -2
  182. package/dist/types/gitlab-types.d.ts +4 -6
  183. package/dist/types/gitlab-types.js +3 -1
  184. package/dist/types/index.js +13 -7
  185. package/dist/types/jobs.d.ts +23 -6
  186. package/dist/types/jobs.js +3 -1
  187. package/dist/types/pipeline.d.ts +4 -3
  188. package/dist/types/pipeline.js +3 -1
  189. package/dist/types/utils.d.ts +1 -1
  190. package/dist/types/utils.js +3 -1
  191. package/dist/utils/gitlab.js +3 -1
  192. package/dist/utils/index.d.ts +1 -1
  193. package/dist/utils/index.js +3 -1
  194. package/dist/utils/writeFiles.d.ts +7 -0
  195. package/dist/{pipeline/commitInfo/getBuildId.js → utils/writeFiles.js} +39 -22
  196. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +480 -384
  197. package/examples/__snapshots__/cloud-run-meteor-with-worker.ts.snap +462 -366
  198. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +480 -384
  199. package/examples/__snapshots__/cloud-run-no-service.ts.snap +501 -393
  200. package/examples/__snapshots__/cloud-run-non-public.ts.snap +480 -384
  201. package/examples/__snapshots__/cloud-run-post-stop-job.ts.snap +489 -392
  202. package/examples/__snapshots__/cloud-run-service-gen2.ts.snap +480 -384
  203. package/examples/__snapshots__/cloud-run-service-with-volumes.ts.snap +501 -401
  204. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +1155 -915
  205. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +1116 -888
  206. package/examples/__snapshots__/cloud-run-with-worker.ts.snap +482 -386
  207. package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +452 -356
  208. package/examples/__snapshots__/custom-build-job.ts.snap +434 -350
  209. package/examples/__snapshots__/custom-deploy.ts.snap +319 -223
  210. package/examples/__snapshots__/custom-envs.ts.snap +123 -81
  211. package/examples/__snapshots__/custom-sbom-java.ts.snap +434 -350
  212. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +846 -969
  213. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +886 -957
  214. package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +894 -969
  215. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +1626 -1728
  216. package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +974 -1137
  217. package/examples/__snapshots__/local-dot-env.ts.snap +480 -384
  218. package/examples/__snapshots__/meteor-kubernetes.ts.snap +906 -1069
  219. package/examples/__snapshots__/multiline-var.ts.snap +4500 -0
  220. package/examples/__snapshots__/native-app.ts.snap +706 -578
  221. package/examples/__snapshots__/node-build-with-custom-image.ts.snap +480 -384
  222. package/examples/__snapshots__/node-build-with-docker-additions.ts.snap +488 -384
  223. package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1656 -1942
  224. package/examples/__snapshots__/wait-for-other-deploy.ts.snap +287 -231
  225. package/examples/__utils__/helpers.ts +2 -2
  226. package/examples/custom-deploy.ts +7 -7
  227. package/examples/multiline-var.ts +64 -0
  228. package/package.json +5 -8
  229. package/scripts/generate-gitlab-ci-types.ts +2 -2
  230. package/src/bash/BashExpression.ts +81 -0
  231. package/src/bash/bashExpressionPerPipelineType.ts +16 -0
  232. package/src/bash/bashYaml.ts +46 -0
  233. package/src/bash/getInjectVarsScript.ts +12 -0
  234. package/src/bash/replaceAsync.ts +50 -0
  235. package/src/build/base/__tests__/createArtifactsConfig.test.ts +3 -3
  236. package/src/build/base/createAppBuildJob.ts +8 -4
  237. package/src/build/base/createArtifactsConfig.ts +2 -2
  238. package/src/build/base/index.ts +1 -1
  239. package/src/build/base/writeBuildInfo.ts +1 -1
  240. package/src/build/base/writeDotEnv.ts +6 -1
  241. package/src/build/custom/__tests__/testJob.test.ts +1 -1
  242. package/src/build/custom/buildJob.ts +4 -6
  243. package/src/build/custom/testJob.ts +6 -5
  244. package/src/build/docker.ts +21 -13
  245. package/src/build/index.ts +1 -1
  246. package/src/build/node/buildJob.ts +3 -5
  247. package/src/build/node/cache.ts +4 -4
  248. package/src/build/node/meteor.ts +1 -1
  249. package/src/build/node/testJob.ts +6 -5
  250. package/src/build/node/yarn.ts +14 -9
  251. package/src/build/rails/test.ts +2 -1
  252. package/src/build/types.ts +8 -1
  253. package/src/catladder-gitlab.ts +8 -55
  254. package/src/config/configruedEnvs.ts +6 -6
  255. package/src/config/readConfig.ts +4 -5
  256. package/src/constants.ts +5 -2
  257. package/src/context/__tests__/resolveReferences.test.ts +11 -6
  258. package/src/context/getBuildInfoVariables.ts +40 -0
  259. package/src/context/getEnvConfig.ts +1 -1
  260. package/src/context/getEnvType.ts +1 -1
  261. package/src/context/getEnvironment.ts +7 -30
  262. package/src/context/getEnvironmentContext.ts +25 -29
  263. package/src/context/getEnvironmentVariables.ts +72 -47
  264. package/src/context/getReviewSlug.ts +27 -0
  265. package/src/context/index.ts +26 -25
  266. package/src/context/resolveReferences.ts +40 -17
  267. package/src/context/transformJobOnlyVars.ts +6 -3
  268. package/src/context/utils/envVars.ts +5 -4
  269. package/src/deploy/base/deploy.ts +25 -23
  270. package/src/deploy/base/index.ts +1 -1
  271. package/src/deploy/base/rollback.ts +9 -11
  272. package/src/deploy/base/stop.ts +9 -10
  273. package/src/deploy/cloudRun/artifactsRegistry.ts +13 -8
  274. package/src/deploy/cloudRun/cleanup.ts +3 -3
  275. package/src/deploy/cloudRun/cloudRunRevisions.ts +3 -3
  276. package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +22 -17
  277. package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +7 -6
  278. package/src/deploy/cloudRun/createJobs/common.ts +1 -1
  279. package/src/deploy/cloudRun/createJobs/constants.ts +1 -0
  280. package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +25 -7
  281. package/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.ts +1 -1
  282. package/src/deploy/cloudRun/createJobs/index.ts +18 -9
  283. package/src/deploy/cloudRun/createJobs/volumes.ts +2 -2
  284. package/src/deploy/cloudRun/index.ts +22 -10
  285. package/src/deploy/cloudRun/utils/createArgsString.ts +3 -2
  286. package/src/deploy/cloudRun/utils/database.ts +7 -7
  287. package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +1 -1
  288. package/src/deploy/cloudRun/utils/jobName.ts +7 -2
  289. package/src/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.ts +1 -1
  290. package/src/deploy/cloudSql/utils.ts +13 -10
  291. package/src/deploy/index.ts +5 -4
  292. package/src/deploy/kubernetes/cloudSql/index.ts +6 -5
  293. package/src/deploy/kubernetes/deployJob.ts +28 -14
  294. package/src/deploy/kubernetes/index.ts +15 -8
  295. package/src/deploy/kubernetes/kubeEnv.ts +9 -7
  296. package/src/deploy/kubernetes/kubeValues.ts +5 -6
  297. package/src/deploy/kubernetes/mongodb.ts +1 -1
  298. package/src/deploy/kubernetes/processSecretsAsFiles.ts +5 -4
  299. package/src/deploy/types/base.ts +6 -0
  300. package/src/deploy/types/googleCloudRun.ts +2 -0
  301. package/src/deploy/utils.ts +2 -2
  302. package/src/index.ts +2 -1
  303. package/src/packageInfos.ts +10 -0
  304. package/src/pipeline/createAllJobs.ts +28 -14
  305. package/src/pipeline/createChildPipeline.ts +20 -9
  306. package/src/pipeline/createJobsForComponent.ts +15 -23
  307. package/src/pipeline/createMainPipeline.ts +91 -0
  308. package/src/pipeline/generatePipelineFiles.ts +29 -0
  309. package/src/pipeline/getPipelineStages.ts +1 -1
  310. package/src/pipeline/gitlab/createGitlabJobs.ts +182 -59
  311. package/src/pipeline/gitlab/createGitlabPipeline.ts +16 -14
  312. package/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.ts +46 -0
  313. package/src/pipeline/gitlab/gitlabReleaseJobs.ts +20 -0
  314. package/src/pipeline/index.ts +2 -0
  315. package/src/pipeline/packageManager.ts +2 -2
  316. package/src/pipeline/yarn/yarnUtils.ts +7 -7
  317. package/src/rules/index.ts +15 -9
  318. package/src/types/config.ts +12 -3
  319. package/src/types/context.ts +39 -26
  320. package/src/types/environmentContext.ts +13 -7
  321. package/src/types/gitlab-ci-yml.ts +0 -1
  322. package/src/types/gitlab-types.ts +5 -4
  323. package/src/types/jobs.ts +29 -4
  324. package/src/types/pipeline.ts +4 -0
  325. package/src/types/utils.ts +4 -4
  326. package/src/utils/gitlab.ts +1 -1
  327. package/src/utils/index.ts +2 -2
  328. package/src/utils/writeFiles.ts +40 -0
  329. package/dist/deploy/cloudRun/createJobs/variables.d.ts +0 -5
  330. package/dist/deploy/cloudRun/createJobs/variables.js +0 -19
  331. package/dist/pipeline/commitInfo/getBuildId.d.ts +0 -6
  332. package/dist/pipeline/commitInfo/getCommitInfo.d.ts +0 -2
  333. package/src/deploy/cloudRun/createJobs/variables.ts +0 -21
  334. package/src/pipeline/commitInfo/getBuildId.ts +0 -17
  335. package/src/pipeline/commitInfo/getCommitInfo.ts +0 -15
@@ -13,7 +13,7 @@ import {
13
13
  } from "../deploy/cloudRun/artifactsRegistry";
14
14
  import { gcloudServiceAccountLoginCommands } from "../deploy/cloudRun/utils/gcloudServiceAccountLoginCommands";
15
15
 
16
- const DOCKER_RUNNER_BUILD_VARIABLES = {
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
- const getDockerBaseVariables = () => ({
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 = (context: Context) => {
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,14 +89,15 @@ export const getDockerJobBaseProps = (context: Context) => {
86
89
  command: ["--tls=false"],
87
90
  },
88
91
  ],
89
- variables: getDockerBaseVariables(),
92
+ variables: {},
93
+ runnerVariables: getDockerBuildRunnerVariables(),
90
94
  };
91
95
  };
92
96
 
93
97
  export type DockerBuildJobDefinition = Partial<CatladderJob>;
94
98
  export const createDockerBuildJobBase = (
95
99
  context: Context,
96
- { script, ...def }: Partial<CatladderJob>
100
+ { script, ...def }: Partial<CatladderJob>,
97
101
  ): CatladderJob => {
98
102
  return merge(
99
103
  {
@@ -105,8 +109,12 @@ 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
- def
117
+ def,
110
118
  );
111
119
  };
112
120
 
@@ -122,23 +130,23 @@ export const gitlabDockerLogin = (context: Context) =>
122
130
 
123
131
  export const getDockerBuildDefaultScript = (
124
132
  context: Context,
125
- ensureDockerFileScript?: string
133
+ ensureDockerFileScript?: string,
126
134
  ) =>
127
135
  [
128
136
  ensureDockerFileScript,
129
137
  ...collapseableSection(
130
138
  "docker-login",
131
- "Docker Login"
139
+ "Docker Login",
132
140
  )(gitlabDockerLogin(context)),
133
141
  ...collapseableSection(
134
142
  "docker-build",
135
- "Docker build"
143
+ "Docker build",
136
144
  )([
137
145
  "docker build --network host --cache-from $DOCKER_CACHE_IMAGE --tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG -f $APP_DIR/Dockerfile . --build-arg BUILDKIT_INLINE_CACHE=1", //BUILDKIT_INLINE_CACHE, see https://testdriven.io/blog/faster-ci-builds-with-docker-cache/
138
146
  ]),
139
147
  ...collapseableSection(
140
148
  "docker-push",
141
- "Docker push and tag"
149
+ "Docker push and tag",
142
150
  )([
143
151
  "docker push $DOCKER_IMAGE:$DOCKER_IMAGE_TAG",
144
152
  "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE",
@@ -14,7 +14,7 @@ export type BuildTypes = {
14
14
  [type in BuildConfigType]: {
15
15
  jobs: (context: Context) => CatladderJob[];
16
16
  defaults: (
17
- envContext: EnvironmentContext<BuildConfigType, any>
17
+ envContext: EnvironmentContext<BuildConfigType, any>,
18
18
  ) => Partial<Extract<BuildConfig, { type: type }>>;
19
19
  };
20
20
  };
@@ -25,9 +25,7 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
25
25
  buildConfig.buildCommand !== null
26
26
  ? {
27
27
  image: buildConfig.jobImage ?? defaultImage,
28
- variables: {
29
- ...NODE_RUNNER_BUILD_VARIABLES,
30
- },
28
+ runnerVariables: NODE_RUNNER_BUILD_VARIABLES,
31
29
  cache: [
32
30
  ...(ensureArray(buildConfig.jobCache) ?? []),
33
31
  ...getNodeCache(context),
@@ -48,7 +46,7 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
48
46
  join(dir, "dist"),
49
47
  join(dir, ".next"),
50
48
  ...(buildConfig.artifactsPaths?.map((path) =>
51
- join(dir, path)
49
+ join(dir, path),
52
50
  ) ?? []),
53
51
  ]),
54
52
  expire_in: "1 day",
@@ -63,7 +61,7 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
63
61
  context,
64
62
  buildConfig.type === "node-static" || buildConfig.type === "storybook"
65
63
  ? "ensureNginxDockerfile"
66
- : "ensureNodeDockerfile"
64
+ : "ensureNodeDockerfile",
67
65
  ),
68
66
  cache: [...getYarnCache(context, "pull")],
69
67
  variables: {
@@ -6,7 +6,7 @@ import { uniq } from "lodash";
6
6
 
7
7
  export const getYarnCache = (
8
8
  context: Context,
9
- policy = "pull-push"
9
+ policy = "pull-push",
10
10
  ): GitlabJobCache[] => {
11
11
  const componentIsInWorkspace =
12
12
  context.packageManagerInfo?.componentIsInWorkspace;
@@ -27,7 +27,7 @@ export const getYarnCache = (
27
27
 
28
28
  export const getNodeModulesCache = (
29
29
  context: Context,
30
- policy = "pull-push"
30
+ policy = "pull-push",
31
31
  ): GitlabJobCache[] => {
32
32
  const componentIsInWorkspace =
33
33
  context.packageManagerInfo?.componentIsInWorkspace;
@@ -46,7 +46,7 @@ export const getNodeModulesCache = (
46
46
  ? uniq([
47
47
  "node_modules",
48
48
  ...(context.packageManagerInfo?.workspaces.map((w) =>
49
- join(w.location, "node_modules")
49
+ join(w.location, "node_modules"),
50
50
  ) ?? []),
51
51
  ])
52
52
  : [join(context.componentConfig.dir, "node_modules")]),
@@ -56,7 +56,7 @@ export const getNodeModulesCache = (
56
56
  };
57
57
  export const getNodeCache = (
58
58
  context: Context,
59
- policy = "pull-push"
59
+ policy = "pull-push",
60
60
  ): GitlabJobCache[] => {
61
61
  return [
62
62
  ...getYarnCache(context, policy),
@@ -18,7 +18,7 @@ const getMeteorCache = (context: Context): GitlabJobCache[] => [
18
18
  paths: [
19
19
  join(
20
20
  context.componentConfig.dir,
21
- ".meteor/local/resolver-result-cache.json"
21
+ ".meteor/local/resolver-result-cache.json",
22
22
  ),
23
23
  join(context.componentConfig.dir, ".meteor/local/plugin-cache"),
24
24
  join(context.componentConfig.dir, ".meteor/local/isopacks"),
@@ -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
- if (context.commitInfo?.trigger === "taggedRelease") {
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",
@@ -46,7 +47,7 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
46
47
  ...createArtifactsConfig(
47
48
  context.componentConfig.dir,
48
49
  buildConfig.audit?.artifactsReports,
49
- buildConfig.audit?.artifacts
50
+ buildConfig.audit?.artifacts,
50
51
  ),
51
52
  }
52
53
  : null;
@@ -67,7 +68,7 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
67
68
  ...createArtifactsConfig(
68
69
  context.componentConfig.dir,
69
70
  buildConfig.lint?.artifactsReports,
70
- buildConfig.lint?.artifacts
71
+ buildConfig.lint?.artifacts,
71
72
  ),
72
73
  }
73
74
  : null;
@@ -89,7 +90,7 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
89
90
  ...createArtifactsConfig(
90
91
  context.componentConfig.dir,
91
92
  buildConfig.test?.artifactsReports,
92
- buildConfig.test?.artifacts
93
+ buildConfig.test?.artifacts,
93
94
  ),
94
95
  }
95
96
  : null;
@@ -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";
@@ -18,7 +19,7 @@ const getYarnInstallCommand = (context: Context) => {
18
19
  export const ensureNodeVersion = (context: Context) =>
19
20
  collapseableSection(
20
21
  "nodeinstall",
21
- "Ensure node version"
22
+ "Ensure node version",
22
23
  )([
23
24
  "if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi",
24
25
  "if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi",
@@ -28,7 +29,7 @@ export const getYarnInstall = (
28
29
  context: Context,
29
30
  options?: {
30
31
  noCustomPostInstall: boolean;
31
- }
32
+ },
32
33
  ) => {
33
34
  const postInstall =
34
35
  "postInstall" in context.componentConfig.build
@@ -38,12 +39,12 @@ export const getYarnInstall = (
38
39
  ...ensureNodeVersion(context),
39
40
  ...collapseableSection(
40
41
  "yarninstall",
41
- "Yarn install"
42
+ "Yarn install",
42
43
  )([getYarnInstallCommand(context)]),
43
44
  ...(postInstall && !options?.noCustomPostInstall
44
45
  ? collapseableSection(
45
46
  "postinstall",
46
- "Custom post install"
47
+ "Custom post install",
47
48
  )(ensureArray(postInstall) ?? [])
48
49
  : []),
49
50
  ];
@@ -53,17 +54,19 @@ 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
64
67
  // trying to import those fail on this version
65
68
  const doesNotShipWithBuiltInPlugins = ["2", "3"].some((v) =>
66
- context.packageManagerInfo?.version.startsWith(v)
69
+ context.packageManagerInfo?.version.startsWith(v),
67
70
  );
68
71
  const maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins
69
72
  ? "RUN yarn plugin import workspace-tools"
@@ -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
  };
@@ -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
- if (context.commitInfo?.trigger === "taggedRelease") {
7
+ // TODO: this will be replaced by using rules
8
+ if (context.trigger === "taggedRelease") {
8
9
  return [];
9
10
  }
10
11
 
@@ -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
  */
@@ -1,59 +1,12 @@
1
- import { writeFileSync } from "fs";
2
- import { dump } from "js-yaml";
3
1
  import { readConfigSync } from "./config";
4
- import { PIPELINE_IMAGE_TAG } from "./constants";
5
- import { createChildPipeline } from "./pipeline";
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 isDefaultBranch =
16
- Boolean(CI_DEFAULT_BRANCH) && CI_COMMIT_BRANCH === CI_DEFAULT_BRANCH;
17
- const isHotfixBranch = CI_COMMIT_BRANCH
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">);
@@ -4,25 +4,25 @@ import { DEFAULT_ENV_TYPES, getEnvTypesByTrigger } from "../types";
4
4
  const getConfiguredAndDefaultEnvs = (
5
5
  config: Config,
6
6
  componentName: string,
7
- envTypes: EnvType[]
7
+ envTypes: EnvType[],
8
8
  ) => {
9
9
  const configuredEnvs = config.components[componentName].env ?? {};
10
10
  // the default envs have the same name as the env types
11
11
  // these can be disabled with settimg them to `false`
12
12
  // this is the list of all not disabled envs. These are always returned
13
13
  const enabledDefaultEnvs = envTypes.filter(
14
- (e) => configuredEnvs[e] !== false
14
+ (e) => configuredEnvs[e] !== false,
15
15
  );
16
16
 
17
17
  const configuredCustomEnvs = Object.entries(
18
- config.components[componentName].env ?? {}
18
+ config.components[componentName].env ?? {},
19
19
  )
20
20
  .filter(
21
21
  ([, config]) =>
22
22
  config &&
23
23
  "type" in config &&
24
24
  config.type &&
25
- envTypes.includes(config.type)
25
+ envTypes.includes(config.type),
26
26
  )
27
27
  .map(([envName]) => envName);
28
28
 
@@ -36,7 +36,7 @@ export const getAllEnvs = (config: Config, componentName: string) => {
36
36
  export const getAllEnvsInAllComponents = (config: Config) => {
37
37
  return [
38
38
  ...new Set(
39
- Object.keys(config.components).flatMap((c) => getAllEnvs(config, c))
39
+ Object.keys(config.components).flatMap((c) => getAllEnvs(config, c)),
40
40
  ),
41
41
  ];
42
42
  };
@@ -44,7 +44,7 @@ export const getAllEnvsInAllComponents = (config: Config) => {
44
44
  export const getAllEnvsByTrigger = (
45
45
  config: Config,
46
46
  componentName: string,
47
- trigger: PipelineTrigger
47
+ trigger: PipelineTrigger,
48
48
  ) => {
49
49
  const envTypesByTrigger = getEnvTypesByTrigger(trigger);
50
50
  return getConfiguredAndDefaultEnvs(config, componentName, envTypesByTrigger);
@@ -1,6 +1,6 @@
1
1
  import { existsSync, readFileSync } from "fs";
2
2
  import { register } from "ts-node";
3
- import { load } from "js-yaml";
3
+ import { parse } from "yaml";
4
4
  import type { Config } from "../types";
5
5
 
6
6
  // allows us to load ts files
@@ -14,7 +14,7 @@ function requireUncached(module: string) {
14
14
  }
15
15
 
16
16
  export const readConfigSync = (
17
- directory: string = process.cwd()
17
+ directory: string = process.cwd(),
18
18
  ): { config: Config; path: string; ext: string } | null => {
19
19
  register({
20
20
  cwd: directory,
@@ -25,7 +25,7 @@ export const readConfigSync = (
25
25
  });
26
26
 
27
27
  const found = ["ts", "js", "yml", "yaml"].find((extension) =>
28
- existsSync(fullPath(directory, extension))
28
+ existsSync(fullPath(directory, extension)),
29
29
  );
30
30
  if (found) {
31
31
  const filePath = fullPath(directory, found);
@@ -33,14 +33,13 @@ export const readConfigSync = (
33
33
  return {
34
34
  path: filePath,
35
35
  ext: found,
36
- // eslint-disable-next-line @typescript-eslint/no-var-requires
37
36
  config: requireUncached(filePath).default,
38
37
  };
39
38
  } else {
40
39
  return {
41
40
  path: filePath,
42
41
  ext: found,
43
- config: load(readFileSync(filePath, { encoding: "utf-8" })) as Config,
42
+ config: parse(readFileSync(filePath, { encoding: "utf-8" })) as Config,
44
43
  };
45
44
  }
46
45
  }
package/src/constants.ts CHANGED
@@ -1,2 +1,5 @@
1
- export const PIPELINE_IMAGE_TAG = process.env.INLINE_PIPELINE_IMAGE_TAG || "";
2
- export const DOCKER_REGISTRY = process.env.INLINE_DOCKER_REGISTRY || "";
1
+ export const PIPELINE_IMAGE_TAG =
2
+ process.env.INLINE_PIPELINE_IMAGE_TAG || "latest";
3
+ export const DOCKER_REGISTRY =
4
+ process.env.INLINE_DOCKER_REGISTRY ||
5
+ "git.panter.ch:5001/catladder/catladder";
@@ -1,8 +1,13 @@
1
+ import type { BashExpression } from "../../bash/BashExpression";
1
2
  import {
2
3
  resolveReferences,
3
4
  translateLegacyFromComponents,
4
5
  } from "../resolveReferences";
5
6
 
7
+ const unpackBashExpressions = (obj: Record<string, string | BashExpression>) =>
8
+ Object.fromEntries(
9
+ Object.entries(obj).map(([key, value]) => [key, value.toString()]),
10
+ );
6
11
  describe("resolveReferences", () => {
7
12
  it("replaces occurences of ${componentName:VARIABLE_NAME}", async () => {
8
13
  const variables = {
@@ -21,7 +26,7 @@ describe("resolveReferences", () => {
21
26
  return otherVariables[componentName];
22
27
  });
23
28
 
24
- expect(result).toEqual({
29
+ expect(unpackBashExpressions(result)).toEqual({
25
30
  a: "hello world",
26
31
  b: "a replaced value looks like this: 'foo from api', nice!",
27
32
  });
@@ -34,7 +39,7 @@ describe("resolveReferences", () => {
34
39
  };
35
40
  const result = await resolveReferences(variables);
36
41
 
37
- expect(result).toEqual({
42
+ expect(unpackBashExpressions(result)).toEqual({
38
43
  FOO: "hello world",
39
44
  BAR: "this: hello world!",
40
45
  });
@@ -54,7 +59,7 @@ describe("resolveReferences", () => {
54
59
  return otherVariables[componentName];
55
60
  });
56
61
 
57
- expect(result).toEqual({
62
+ expect(unpackBashExpressions(result)).toEqual({
58
63
  FOO: "hello from foo from api",
59
64
  BAR: "this: hello from foo from api!",
60
65
  });
@@ -70,7 +75,7 @@ describe("resolveReferences", () => {
70
75
  return otherVariables[componentName];
71
76
  });
72
77
 
73
- expect(result).toEqual({
78
+ expect(unpackBashExpressions(result)).toEqual({
74
79
  a: "hello world",
75
80
  b: "a not found value looks like this: '${api:FOO}'",
76
81
  });
@@ -92,7 +97,7 @@ describe("resolveReferences", () => {
92
97
  return otherVariables[componentName];
93
98
  });
94
99
 
95
- expect(result).toEqual({
100
+ expect(unpackBashExpressions(result)).toEqual({
96
101
  a: "value is hi, foo from api!",
97
102
  });
98
103
  });
@@ -113,7 +118,7 @@ describe("resolveReferences", () => {
113
118
  return otherVariables[componentName];
114
119
  });
115
120
 
116
- expect(result).toEqual({
121
+ expect(unpackBashExpressions(result)).toEqual({
117
122
  a: "value is frontend api ${frontend:FOO}!",
118
123
  });
119
124
  });
@@ -0,0 +1,40 @@
1
+ import { BashExpression } from "../bash/BashExpression";
2
+ import type { BashExpressionPerPipelineType } from "../bash/bashExpressionPerPipelineType";
3
+ import { getBashExpressionPerPipelineType } from "../bash/bashExpressionPerPipelineType";
4
+ import type { EnvironmentContext } from "../types/environmentContext";
5
+
6
+ const BUILD_TIME: BashExpressionPerPipelineType = {
7
+ default: "unknown-build-time",
8
+ gitlab: new BashExpression(`$CI_JOB_STARTED_AT`),
9
+ };
10
+
11
+ const BUILD_ID: BashExpressionPerPipelineType = {
12
+ default: new BashExpression(
13
+ `$(git describe --tags 2>/dev/null || git rev-parse HEAD)`,
14
+ ),
15
+ };
16
+ const CURRENT_VERSION: BashExpressionPerPipelineType = {
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\\///'); [ -z "$tag" ] && echo "v0.0.0" || echo "$tag")`,
20
+ ),
21
+ };
22
+
23
+ export const getBuildInfoVariables = (ctx: EnvironmentContext<any, any>) => {
24
+ const { pipelineType } = ctx;
25
+
26
+ return {
27
+ BUILD_INFO_BUILD_ID: getBashExpressionPerPipelineType(
28
+ BUILD_ID,
29
+ pipelineType,
30
+ ),
31
+ BUILD_INFO_BUILD_TIME: getBashExpressionPerPipelineType(
32
+ BUILD_TIME,
33
+ pipelineType,
34
+ ),
35
+ BUILD_INFO_CURRENT_VERSION: getBashExpressionPerPipelineType(
36
+ CURRENT_VERSION,
37
+ pipelineType,
38
+ ),
39
+ };
40
+ };
@@ -5,7 +5,7 @@ import { mergeWithMergingArrays } from "../utils";
5
5
  export const getEnvConfig = (
6
6
  config: Config,
7
7
  componentName: string,
8
- env: string
8
+ env: string,
9
9
  ): EnvConfigWithComponent => {
10
10
  const defaultConfig = config.components[componentName];
11
11
  if (!defaultConfig) {
@@ -5,7 +5,7 @@ export const getEnvType = (
5
5
  env: string,
6
6
  envConfig: {
7
7
  type?: EnvType;
8
- }
8
+ },
9
9
  ): EnvType => {
10
10
  if (envConfig.type) return envConfig.type;
11
11