@catladder/pipeline 2.0.5 → 2.1.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 (83) hide show
  1. package/dist/build/base/writeDotEnv.js +0 -1
  2. package/dist/build/docker.js +0 -1
  3. package/dist/build/node/meteor.js +0 -1
  4. package/dist/build/rails/test.js +0 -1
  5. package/dist/catladder-gitlab.js +2 -3
  6. package/dist/config/readConfig.js +0 -1
  7. package/dist/constants.js +1 -1
  8. package/dist/context/getEnvironmentVariables.js +0 -1
  9. package/dist/context/getReviewSlug.js +0 -1
  10. package/dist/deploy/cloudRun/createJobs/index.js +0 -1
  11. package/dist/deploy/kubernetes/deployJob.js +0 -1
  12. package/dist/deploy/types/index.d.ts +3 -3
  13. package/dist/pipeline/generatePipelineFiles.d.ts +3 -22
  14. package/dist/pipeline/generatePipelineFiles.js +4 -39
  15. package/dist/pipeline/gitlab/gitlabReleaseJobs.d.ts +0 -2
  16. package/dist/pipeline/gitlab/gitlabReleaseJobs.js +2 -4
  17. package/dist/pipeline/index.d.ts +0 -1
  18. package/dist/pipeline/index.js +0 -1
  19. package/dist/tsconfig.tsbuildinfo +1 -1
  20. package/dist/types/pipeline.d.ts +0 -1
  21. package/dist/utils/writeFiles.js +0 -2
  22. package/dist/variables/__tests__/resolveAllReferences.test.js +0 -1
  23. package/dist/variables/__tests__/resolveReferencesOnce.test.js +0 -3
  24. package/examples/__snapshots__/cloud-run-http2.test.ts.snap +0 -2
  25. package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +0 -2
  26. package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +0 -2
  27. package/examples/__snapshots__/cloud-run-nextjs.test.ts.snap +0 -2
  28. package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +0 -2
  29. package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +0 -2
  30. package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +0 -2
  31. package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +0 -2
  32. package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +0 -2
  33. package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +0 -2
  34. package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +0 -2
  35. package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +0 -2
  36. package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +0 -2
  37. package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +0 -2
  38. package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +0 -2
  39. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +0 -2
  40. package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +0 -2
  41. package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +0 -2
  42. package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +0 -2
  43. package/examples/__snapshots__/custom-build-job.test.ts.snap +0 -2
  44. package/examples/__snapshots__/custom-deploy.test.ts.snap +0 -2
  45. package/examples/__snapshots__/custom-envs.test.ts.snap +0 -2
  46. package/examples/__snapshots__/custom-sbom-java.test.ts.snap +0 -2
  47. package/examples/__snapshots__/git-submodule.test.ts.snap +0 -2
  48. package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +0 -2
  49. package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +0 -2
  50. package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +0 -2
  51. package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +0 -2
  52. package/examples/__snapshots__/local-dot-env.test.ts.snap +0 -2
  53. package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +0 -2
  54. package/examples/__snapshots__/multiline-var.test.ts.snap +0 -2
  55. package/examples/__snapshots__/native-app.test.ts.snap +0 -2
  56. package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +0 -2
  57. package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +0 -2
  58. package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +0 -2
  59. package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +0 -2
  60. package/examples/__snapshots__/referencing-other-vars.test.ts.snap +0 -2
  61. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +0 -2
  62. package/examples/__snapshots__/workspace-api-www-turbo-cache.test.ts.snap +0 -2
  63. package/examples/__snapshots__/workspace-api-www.test.ts.snap +0 -2
  64. package/examples/__utils__/helpers.ts +1 -17
  65. package/package.json +16 -17
  66. package/src/build/cache/createJobCache.ts +2 -2
  67. package/src/build/sbom.ts +2 -2
  68. package/src/catladder-gitlab.ts +2 -9
  69. package/src/config/readConfig.ts +0 -1
  70. package/src/context/createComponentContext.ts +1 -1
  71. package/src/context/getEnvironmentVariables.ts +1 -1
  72. package/src/deploy/base/deploy.ts +3 -3
  73. package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +1 -1
  74. package/src/pipeline/generatePipelineFiles.ts +1 -37
  75. package/src/pipeline/gitlab/gitlabReleaseJobs.ts +2 -4
  76. package/src/pipeline/index.ts +0 -1
  77. package/src/types/pipeline.ts +0 -4
  78. package/dist/pipeline/createChildPipeline.d.ts +0 -3
  79. package/dist/pipeline/createChildPipeline.js +0 -163
  80. package/dist/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.d.ts +0 -1
  81. package/dist/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.js +0 -29
  82. package/src/pipeline/createChildPipeline.ts +0 -37
  83. package/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.ts +0 -46
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "2.0.5",
56
+ "version": "2.1.0",
57
57
  "scripts": {
58
58
  "build:tsc": "yarn tsc",
59
59
  "build": "yarn build:compile && yarn build:inline-variables",
@@ -69,28 +69,27 @@
69
69
  "main": "dist/index.js",
70
70
  "sideEffects": false,
71
71
  "devDependencies": {
72
- "@babel/cli": "^7.16.0",
73
- "@babel/core": "^7.0.0-0",
74
- "@babel/plugin-syntax-typescript": "^7.16.7",
75
- "@babel/preset-typescript": "^7.16.5",
76
- "@jest/globals": "^29.3.1",
77
- "@types/child-process-promise": "^2.2.2",
78
- "@types/jest": "^27.4.0",
79
- "@types/lodash": "^4.14.185",
80
- "@types/node": "^20.14.2",
72
+ "@babel/cli": "^7.24.8",
73
+ "@babel/core": "^7.25.2",
74
+ "@babel/plugin-syntax-typescript": "^7.25.4",
75
+ "@babel/preset-typescript": "^7.24.7",
76
+ "@jest/globals": "^29.7.0",
77
+ "@types/child-process-promise": "^2.2.6",
78
+ "@types/jest": "^29.5.12",
79
+ "@types/lodash": "^4.17.7",
80
+ "@types/node": "^22.5.1",
81
81
  "babel-plugin-transform-inline-environment-variables": "^0.4.3",
82
82
  "child-process-promise": "^2.2.1",
83
- "glob": "^10.4.2",
83
+ "glob": "^11.0.0",
84
84
  "json-schema-to-typescript": "^13.0.2",
85
85
  "lodash": "^4.17.21",
86
- "memoizee": "^0.4.15",
87
- "path-equal": "1.1.3",
88
- "slugify": "^1.6.3",
89
- "tsx": "^4.16.2",
86
+ "memoizee": "^0.4.17",
87
+ "path-equal": "1.2.5",
88
+ "slugify": "^1.6.6",
90
89
  "typescript": "^5.4.5",
91
- "yaml": "^2.4.5"
90
+ "yaml": "^2.5.0"
92
91
  },
93
92
  "dependencies": {
94
- "tsx": "^4.16.2"
93
+ "tsx": "^4.19.0"
95
94
  }
96
95
  }
@@ -30,7 +30,7 @@ export const createJobCacheFromCacheConfigs = (
30
30
  const baseDir =
31
31
  c.pathMode === "absolute"
32
32
  ? ""
33
- : c.baseDir ?? context.build.dir;
33
+ : (c.baseDir ?? context.build.dir);
34
34
  return join(baseDir, p);
35
35
  }),
36
36
  ),
@@ -41,7 +41,7 @@ export const createJobCacheFromCacheConfigs = (
41
41
  const advancedCaches = advancedCacheDefs.map(
42
42
  ({ key, paths, policy, scope, pathMode, buildDir, ...rest }) => {
43
43
  const baseDir =
44
- pathMode === "absolute" ? "" : buildDir ?? context.build.dir;
44
+ pathMode === "absolute" ? "" : (buildDir ?? context.build.dir);
45
45
  const transformedKey =
46
46
  scope === "global"
47
47
  ? key
package/src/build/sbom.ts CHANGED
@@ -22,14 +22,14 @@ export const createSbomBuildJob = (context: ComponentContext): CatladderJob => {
22
22
  isStandaloneBuildConfig(buildConfig) &&
23
23
  buildConfig.type === "custom" &&
24
24
  buildConfig.sbom !== false
25
- ? buildConfig.sbom?.jobImage ?? defaultImage
25
+ ? (buildConfig.sbom?.jobImage ?? defaultImage)
26
26
  : defaultImage;
27
27
 
28
28
  const script =
29
29
  isStandaloneBuildConfig(buildConfig) &&
30
30
  buildConfig.type === "custom" &&
31
31
  buildConfig.sbom !== false
32
- ? ensureArrayOrNull(buildConfig.sbom?.command) ?? defaultScript
32
+ ? (ensureArrayOrNull(buildConfig.sbom?.command) ?? defaultScript)
33
33
  : defaultScript;
34
34
 
35
35
  return {
@@ -1,17 +1,10 @@
1
1
  import { readConfig } from "./config";
2
2
  import { generatePipelineFiles } from "./pipeline/generatePipelineFiles";
3
- import type { PipelineMode } from "./types";
4
3
 
5
- const mode = process.argv[2] || "local";
6
-
7
- const config = readConfig().then(async (result) => {
4
+ readConfig().then(async (result) => {
8
5
  if (!result?.config) {
9
6
  throw new Error("no catladder config found");
10
7
  }
11
8
 
12
- await generatePipelineFiles(
13
- result.config,
14
- "gitlab",
15
- mode as PipelineMode<"gitlab">,
16
- );
9
+ await generatePipelineFiles(result.config, "gitlab");
17
10
  });
@@ -1,6 +1,5 @@
1
1
  import { existsSync, readFileSync } from "fs";
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-var-requires
4
3
  const tsx = require("tsx/cjs/api");
5
4
 
6
5
  import { parse } from "yaml";
@@ -76,7 +76,7 @@ export const createComponentContext = async (
76
76
  dir,
77
77
  // also copy workspace dependencies in monorepo if packages are shared and they create build artifacts
78
78
  ...(mode === "all"
79
- ? packageManagerInfo.currentWorkspaceDependencies ?? []
79
+ ? (packageManagerInfo.currentWorkspaceDependencies ?? [])
80
80
  : []),
81
81
  ];
82
82
  const _getBuildContext = (): BuildContextComponent => {
@@ -134,7 +134,7 @@ export const getEnvironmentVariables = async (
134
134
  );
135
135
 
136
136
  const publicEnvVars =
137
- options.shouldResolveReferences ?? true
137
+ (options.shouldResolveReferences ?? true)
138
138
  ? await resolveAllReferences(
139
139
  publicEnvVarsUnresolved,
140
140
  async (otherComponentName) => {
@@ -62,11 +62,11 @@ export const createDeployJob = (
62
62
  ? []
63
63
  : [{ job: SBOM_BUILD_JOB_NAME, artifacts: true }]),
64
64
  ...(deployConfig
65
- ? deployConfig.waitFor?.map((c) => ({
65
+ ? (deployConfig.waitFor?.map((c) => ({
66
66
  componentName: c,
67
67
  job: DEPLOY_JOB_NAME,
68
68
  artifacts: false,
69
- })) ?? []
69
+ })) ?? [])
70
70
  : []),
71
71
  ],
72
72
  // we don't want to deploy when there is a broken test
@@ -117,7 +117,7 @@ export const createDeployJob = (
117
117
  runnerVariables: {
118
118
  ...DEPLOY_RUNNER_VARIABLES,
119
119
  ...(jobDefinition.runnerVariables ?? {}),
120
- ...(deployConfig ? deployConfig.runnerVariables ?? {} : {}),
120
+ ...(deployConfig ? (deployConfig.runnerVariables ?? {}) : {}),
121
121
  },
122
122
  environment: isStoppable
123
123
  ? {
@@ -25,7 +25,7 @@ export const getServiceDeployScript = (
25
25
  const customConfig = service !== true ? service : undefined;
26
26
  const command =
27
27
  service !== true
28
- ? service?.command ?? context.build.config.startCommand
28
+ ? (service?.command ?? context.build.config.startCommand)
29
29
  : undefined;
30
30
 
31
31
  const commandArray = command
@@ -1,36 +1,8 @@
1
- import type { Config, PipelineMode, PipelineType } from "../types";
1
+ import type { Config, PipelineType } from "../types";
2
2
  import { writeYamlfile } from "../utils/writeFiles";
3
- import { createChildPipeline } from "./createChildPipeline";
4
3
  import { createMainPipeline } from "./createMainPipeline";
5
- import { getPipelineTriggerForGitlabChildPipeline } from "./gitlab/getPipelineTriggerForGitlabChildPipeline";
6
4
  import { sortGitLabJobDefProps } from "./gitlab/sortGitLabJobDefProps";
7
5
 
8
- export async function generateChildPipelineContent<T extends PipelineType>(
9
- config: Config,
10
- pipelineType: T,
11
- ) {
12
- const trigger = getPipelineTriggerForGitlabChildPipeline();
13
- const { jobs, image, stages, variables, workflow, ...pipelineRest } =
14
- await createChildPipeline(pipelineType, trigger, config);
15
-
16
- const jobsWithSortedProps = Object.fromEntries(
17
- Object.entries(jobs).map(([jobName, job]) => [
18
- jobName,
19
- sortGitLabJobDefProps(job),
20
- ]),
21
- );
22
-
23
- return {
24
- image,
25
- stages,
26
- variables,
27
- workflow,
28
- ...pipelineRest,
29
- // jobs need to be spread into main YAML, because GitLab pipeline YAML has no jobs key - jobs are top level with their key as their name
30
- ...jobsWithSortedProps,
31
- };
32
- }
33
-
34
6
  export async function generateLocalPipelineContent<T extends PipelineType>(
35
7
  config: Config,
36
8
  pipelineType: T,
@@ -59,15 +31,7 @@ export async function generateLocalPipelineContent<T extends PipelineType>(
59
31
  export async function generatePipelineFiles<T extends PipelineType>(
60
32
  config: Config,
61
33
  pipelineType: T,
62
- mode: PipelineMode<T>,
63
34
  ) {
64
- if (mode === "childpipeline") {
65
- const pipelineContent = await generateChildPipelineContent(
66
- config,
67
- pipelineType,
68
- );
69
- return writeYamlfile(`__pipeline.yml`, pipelineContent);
70
- }
71
35
  const pipelineContent = await generateLocalPipelineContent(
72
36
  config,
73
37
  pipelineType,
@@ -9,15 +9,13 @@ export const getGitlabReleaseJobs = () => {
9
9
  ["create release"]: {
10
10
  stage: "release",
11
11
  image: getRunnerImage("semantic-release"),
12
- script: ["semanticRelease"],
13
- after_script: [EXPIRED_TOKEN_HELP],
12
+ script: ["semanticRelease", EXPIRED_TOKEN_HELP],
14
13
  rules: RULES_RELEASE,
15
14
  },
16
15
  ["⚠️ force create release"]: {
17
16
  stage: "release",
18
17
  image: getRunnerImage("semantic-release"),
19
- script: ["semanticRelease"],
20
- after_script: [EXPIRED_TOKEN_HELP],
18
+ script: ["semanticRelease", EXPIRED_TOKEN_HELP],
21
19
  needs: [],
22
20
  rules: RULES_MANUAL_RELEASE,
23
21
  },
@@ -1,4 +1,3 @@
1
- export * from "./createChildPipeline";
2
1
  export * from "./createJobsForComponent";
3
2
  export * from "./generatePipelineFiles";
4
3
  export * from "./gitlab/gitlabReleaseJobs";
@@ -2,10 +2,6 @@ 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
-
9
5
  export type PipelineJob<T extends PipelineType> = T extends "gitlab"
10
6
  ? GitlabJobDef
11
7
  : never;
@@ -1,3 +0,0 @@
1
- import type { Pipeline } from "../types";
2
- import type { Config, PipelineTrigger } from "../types/config";
3
- export declare const createChildPipeline: <T extends "gitlab">(pipelineType: T, trigger: PipelineTrigger, config: Config) => Promise<Pipeline<T>>;
@@ -1,163 +0,0 @@
1
- "use strict";
2
-
3
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) {
5
- return value instanceof P ? value : new P(function (resolve) {
6
- resolve(value);
7
- });
8
- }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) {
11
- try {
12
- step(generator.next(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- }
17
- function rejected(value) {
18
- try {
19
- step(generator["throw"](value));
20
- } catch (e) {
21
- reject(e);
22
- }
23
- }
24
- function step(result) {
25
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
26
- }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
- var __generator = this && this.__generator || function (thisArg, body) {
31
- var _ = {
32
- label: 0,
33
- sent: function () {
34
- if (t[0] & 1) throw t[1];
35
- return t[1];
36
- },
37
- trys: [],
38
- ops: []
39
- },
40
- f,
41
- y,
42
- t,
43
- g;
44
- return g = {
45
- next: verb(0),
46
- "throw": verb(1),
47
- "return": verb(2)
48
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
49
- return this;
50
- }), g;
51
- function verb(n) {
52
- return function (v) {
53
- return step([n, v]);
54
- };
55
- }
56
- function step(op) {
57
- if (f) throw new TypeError("Generator is already executing.");
58
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
59
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
60
- if (y = 0, t) op = [op[0] & 2, t.value];
61
- switch (op[0]) {
62
- case 0:
63
- case 1:
64
- t = op;
65
- break;
66
- case 4:
67
- _.label++;
68
- return {
69
- value: op[1],
70
- done: false
71
- };
72
- case 5:
73
- _.label++;
74
- y = op[1];
75
- op = [0];
76
- continue;
77
- case 7:
78
- op = _.ops.pop();
79
- _.trys.pop();
80
- continue;
81
- default:
82
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
83
- _ = 0;
84
- continue;
85
- }
86
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
87
- _.label = op[1];
88
- break;
89
- }
90
- if (op[0] === 6 && _.label < t[1]) {
91
- _.label = t[1];
92
- t = op;
93
- break;
94
- }
95
- if (t && _.label < t[2]) {
96
- _.label = t[2];
97
- _.ops.push(op);
98
- break;
99
- }
100
- if (t[2]) _.ops.pop();
101
- _.trys.pop();
102
- continue;
103
- }
104
- op = body.call(thisArg, _);
105
- } catch (e) {
106
- op = [6, e];
107
- y = 0;
108
- } finally {
109
- f = t = 0;
110
- }
111
- if (op[0] & 5) throw op[1];
112
- return {
113
- value: op[0] ? op[1] : void 0,
114
- done: true
115
- };
116
- }
117
- };
118
- Object.defineProperty(exports, "__esModule", {
119
- value: true
120
- });
121
- exports.createChildPipeline = void 0;
122
- var rules_1 = require("../rules");
123
- var createAllJobs_1 = require("./createAllJobs");
124
- var getPipelineStages_1 = require("./getPipelineStages");
125
- var createGitlabJobs_1 = require("./gitlab/createGitlabJobs");
126
- var createGitlabPipeline_1 = require("./gitlab/createGitlabPipeline");
127
- var createChildPipeline = function (pipelineType, trigger, config) {
128
- return __awaiter(void 0, void 0, void 0, function () {
129
- var jobs, stages, gitlabJobs;
130
- return __generator(this, function (_a) {
131
- switch (_a.label) {
132
- case 0:
133
- return [4 /*yield*/, (0, createAllJobs_1.createAllJobs)({
134
- config: config,
135
- trigger: trigger,
136
- pipelineType: pipelineType
137
- })];
138
- case 1:
139
- jobs = _a.sent();
140
- stages = (0, getPipelineStages_1.getPipelineStages)(config);
141
- if (!(pipelineType === "gitlab")) return [3 /*break*/, 3];
142
- return [4 /*yield*/, (0, createGitlabJobs_1.createGitlabJobs)(jobs)];
143
- case 2:
144
- gitlabJobs = _a.sent();
145
- return [2 /*return*/, (0, createGitlabPipeline_1.createGitlabPipelineWithDefaults)({
146
- workflow: {
147
- rules: rules_1.RULES_ALWAYS
148
- },
149
- stages: stages,
150
- jobs: Object.fromEntries(gitlabJobs.map(function (_a) {
151
- var gitlabJob = _a.gitlabJob,
152
- name = _a.name;
153
- return [name, gitlabJob];
154
- })),
155
- variables: config.runnerVariables
156
- })];
157
- case 3:
158
- throw new Error("".concat(pipelineType, " is not supported"));
159
- }
160
- });
161
- });
162
- };
163
- exports.createChildPipeline = createChildPipeline;
@@ -1 +0,0 @@
1
- export declare function getPipelineTriggerForGitlabChildPipeline(): "mainBranch" | "mr" | "taggedRelease";
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getPipelineTriggerForGitlabChildPipeline = void 0;
7
- var constants_1 = require("../../constants");
8
- function getPipelineTriggerForGitlabChildPipeline() {
9
- var _a = process.env,
10
- CI_MERGE_REQUEST_ID = _a.CI_MERGE_REQUEST_ID,
11
- CI_COMMIT_TAG = _a.CI_COMMIT_TAG,
12
- CI_COMMIT_BRANCH = _a.CI_COMMIT_BRANCH,
13
- CI_DEFAULT_BRANCH = _a.CI_DEFAULT_BRANCH;
14
- var isDefaultBranch = Boolean(CI_DEFAULT_BRANCH) && CI_COMMIT_BRANCH === CI_DEFAULT_BRANCH;
15
- var isHotfixBranch = CI_COMMIT_BRANCH ? /^[0-9]+\.([0-9]+|x)\.x$/.test(CI_COMMIT_BRANCH) : false;
16
- var isMergeRequest = Boolean(CI_MERGE_REQUEST_ID);
17
- var isTaggedRelease = Boolean(CI_COMMIT_TAG);
18
- console.info("catladder version ".concat(constants_1.PIPELINE_IMAGE_TAG));
19
- var trigger = isMergeRequest || isHotfixBranch ? "mr" : isDefaultBranch ? "mainBranch" : isTaggedRelease ? "taggedRelease" : null;
20
- if (!trigger) {
21
- throw new Error("no matching trigger: " + JSON.stringify({
22
- isMergeRequest: isMergeRequest,
23
- isDefaultBranch: isDefaultBranch,
24
- isTaggedRelease: isTaggedRelease
25
- }, null, 2));
26
- }
27
- return trigger;
28
- }
29
- exports.getPipelineTriggerForGitlabChildPipeline = getPipelineTriggerForGitlabChildPipeline;
@@ -1,37 +0,0 @@
1
- import { RULES_ALWAYS } from "../rules";
2
-
3
- import type { Pipeline, PipelineType } from "../types";
4
- import type { Config, PipelineTrigger } from "../types/config";
5
- import { createAllJobs } from "./createAllJobs";
6
- import { getPipelineStages } from "./getPipelineStages";
7
- import { createGitlabJobs } from "./gitlab/createGitlabJobs";
8
- import { createGitlabPipelineWithDefaults } from "./gitlab/createGitlabPipeline";
9
-
10
- export const createChildPipeline = async <T extends PipelineType>(
11
- pipelineType: T,
12
- trigger: PipelineTrigger,
13
- config: Config,
14
- ): Promise<Pipeline<T>> => {
15
- const jobs = await createAllJobs({
16
- config,
17
- trigger,
18
- pipelineType,
19
- });
20
-
21
- const stages = getPipelineStages(config);
22
-
23
- if (pipelineType === "gitlab") {
24
- const gitlabJobs = await createGitlabJobs(jobs);
25
- return createGitlabPipelineWithDefaults({
26
- workflow: {
27
- rules: RULES_ALWAYS,
28
- },
29
- stages,
30
- jobs: Object.fromEntries(
31
- gitlabJobs.map(({ gitlabJob, name }) => [name, gitlabJob]),
32
- ),
33
- variables: config.runnerVariables,
34
- }) as Pipeline<T>;
35
- }
36
- throw new Error(`${pipelineType} is not supported`);
37
- };
@@ -1,46 +0,0 @@
1
- import type { PipelineTrigger } from "../..";
2
- import { PIPELINE_IMAGE_TAG } from "../../constants";
3
-
4
- export function getPipelineTriggerForGitlabChildPipeline() {
5
- const {
6
- CI_MERGE_REQUEST_ID,
7
- CI_COMMIT_TAG,
8
- CI_COMMIT_BRANCH,
9
- CI_DEFAULT_BRANCH,
10
- } = process.env;
11
-
12
- const isDefaultBranch =
13
- Boolean(CI_DEFAULT_BRANCH) && CI_COMMIT_BRANCH === CI_DEFAULT_BRANCH;
14
- const isHotfixBranch = CI_COMMIT_BRANCH
15
- ? /^[0-9]+\.([0-9]+|x)\.x$/.test(CI_COMMIT_BRANCH)
16
- : false;
17
- const isMergeRequest = Boolean(CI_MERGE_REQUEST_ID);
18
- const isTaggedRelease = Boolean(CI_COMMIT_TAG);
19
-
20
- console.info(`catladder version ${PIPELINE_IMAGE_TAG}`);
21
-
22
- const trigger: PipelineTrigger | null =
23
- isMergeRequest || isHotfixBranch
24
- ? "mr"
25
- : isDefaultBranch
26
- ? "mainBranch"
27
- : isTaggedRelease
28
- ? "taggedRelease"
29
- : null;
30
-
31
- if (!trigger) {
32
- throw new Error(
33
- "no matching trigger: " +
34
- JSON.stringify(
35
- {
36
- isMergeRequest,
37
- isDefaultBranch,
38
- isTaggedRelease,
39
- },
40
- null,
41
- 2,
42
- ),
43
- );
44
- }
45
- return trigger;
46
- }