@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
@@ -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
+ };
@@ -1,2 +1,4 @@
1
1
  export * from "./createChildPipeline";
2
2
  export * from "./createJobsForComponent";
3
+ export * from "./generatePipelineFiles";
4
+ export * from "./gitlab/gitlabReleaseJobs";
@@ -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) {
@@ -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
 
@@ -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 { load } from "js-yaml";
8
- export type PipelineTrigger = "mainBranch" | "mr" | "taggedRelease";
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
  */
@@ -1,18 +1,28 @@
1
- import type { SecretEnvVar } from "../context";
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 EnvironmentEnvVars = {
10
- envVars: Record<string, string>;
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: string;
15
- url: string;
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: string;
27
- url: string;
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: string;
42
+ fullName: StringOrBashExpression;
32
43
 
33
- gitlabEnvironment: {
34
- name: string;
35
- url?: string;
36
- };
37
44
  shortName: string;
38
- slugPrefix: string;
39
- slug: string;
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
- commitInfo?: CommitInfo;
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 { CommitInfo } from "./context";
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
- commitInfo?: CommitInfo;
15
+
15
16
  env: string;
16
17
  envType: EnvType;
17
18
  componentName: string;
18
- fullName: string;
19
+ fullName: StringOrBashExpression;
19
20
  /**
20
21
  * the environment slug without component name.
21
22
  */
22
- environmentSlugPrefix: string;
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: string;
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
  };
@@ -1,4 +1,3 @@
1
- /* eslint-disable */
2
1
  /**
3
2
  * This file was automatically generated by json-schema-to-typescript.
4
3
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -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 interface Artifacts extends Omit<GitlabCiArtifacts, "paths"> {
12
- paths: string[];
13
- }
11
+ export type Artifacts = GitlabCiArtifacts;
14
12
  export type GitlabJobCache = Cache;
15
- export type GitlabRule = Exclude<Rules, null>[number];
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: GitlabJobDef["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
- environment?: GitlabEnvironment;
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
 
@@ -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;
@@ -1,7 +1,7 @@
1
1
  export type PartialDeep<T> = T extends any[]
2
2
  ? T
3
3
  : T extends Record<string, any>
4
- ? {
5
- [P in keyof T]?: PartialDeep<T[P]>;
6
- }
7
- : T;
4
+ ? {
5
+ [P in keyof T]?: PartialDeep<T[P]>;
6
+ }
7
+ : T;
@@ -11,7 +11,7 @@ export const repeatOnFailure = (
11
11
  command: string,
12
12
  options: {
13
13
  pauseInSeconds: number;
14
- }
14
+ },
15
15
  ): string => {
16
16
  return `
17
17
  until ${command}
@@ -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,5 +0,0 @@
1
- import type { Context } from "../../../types/context";
2
- export declare function getDeployJobVariables(context: Context): {
3
- CLOUDSDK_CORE_DISABLE_PROMPTS: string;
4
- ENV_VARS: string;
5
- };
@@ -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,6 +0,0 @@
1
- export declare const getBuildId: () => Promise<string>;
2
- /**
3
- * returns the last tagged version string Major.minor.patch
4
- * returns 0.0.0 if there is no tag
5
- */
6
- export declare const getCurrentVersionString: () => Promise<string>;
@@ -1,2 +0,0 @@
1
- import type { CommitInfo } from "../../types";
2
- export declare const getBaseCommitInfo: () => Promise<Omit<CommitInfo, "trigger">>;
@@ -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
- });