@catladder/pipeline 1.88.0 → 1.89.1

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 (42) hide show
  1. package/dist/build/docker.d.ts +4 -18
  2. package/dist/build/docker.js +15 -9
  3. package/dist/build/rails/build.js +4 -8
  4. package/dist/bundles/catladder-gitlab/index.js +3 -3
  5. package/dist/constants.js +1 -1
  6. package/dist/deploy/kubernetes/kubeValues.d.ts +1 -0
  7. package/dist/deploy/kubernetes/kubeValues.js +9 -6
  8. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +1 -0
  9. package/dist/deploy/types/kubernetes.d.ts +4 -0
  10. package/dist/pipeline/createAllJobs.d.ts +8 -0
  11. package/dist/pipeline/createAllJobs.js +164 -0
  12. package/dist/pipeline/createChildPipeline.js +24 -48
  13. package/dist/pipeline/createJobsForComponent.d.ts +3 -0
  14. package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +8 -100
  15. package/dist/pipeline/gitlab/createGitlabJobs.d.ts +14 -0
  16. package/dist/pipeline/gitlab/createGitlabJobs.js +260 -0
  17. package/dist/pipeline/index.d.ts +1 -1
  18. package/dist/pipeline/index.js +1 -1
  19. package/dist/tsconfig.tsbuildinfo +1 -1
  20. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +8 -20
  21. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +8 -20
  22. package/examples/__snapshots__/cloud-run-non-public.ts.snap +8 -20
  23. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +16 -40
  24. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +16 -40
  25. package/examples/__snapshots__/custom-build-job.ts.snap +8 -20
  26. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +2280 -0
  27. package/examples/kubernetes-application-customization.ts +57 -0
  28. package/package.json +1 -1
  29. package/src/build/docker.ts +13 -6
  30. package/src/build/rails/build.ts +2 -5
  31. package/src/deploy/kubernetes/kubeValues.ts +7 -5
  32. package/src/deploy/types/kubernetes.ts +7 -2
  33. package/src/pipeline/createAllJobs.ts +38 -0
  34. package/src/pipeline/createChildPipeline.ts +6 -22
  35. package/src/pipeline/createJobsForComponent.ts +64 -0
  36. package/src/pipeline/gitlab/createGitlabJobs.ts +149 -0
  37. package/src/pipeline/index.ts +1 -1
  38. package/dist/pipeline/createJobs.d.ts +0 -3
  39. package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -10
  40. package/dist/pipeline/gitlab/makeGitlabJob.js +0 -75
  41. package/src/pipeline/createJobs.ts +0 -196
  42. package/src/pipeline/gitlab/makeGitlabJob.ts +0 -25
@@ -0,0 +1,57 @@
1
+ import type { Config } from "../src";
2
+ import { createAllPipelines } from "./__utils__/helpers";
3
+ const config: Config = {
4
+ appName: "test-app",
5
+ customerName: "pan",
6
+ components: {
7
+ api: {
8
+ dir: "api",
9
+ build: {
10
+ type: "node",
11
+ },
12
+ deploy: {
13
+ type: "kubernetes",
14
+ cluster: {
15
+ name: "some-cluster-name",
16
+ region: "europe-west6",
17
+ projectId: "some-project-id",
18
+ type: "gcloud",
19
+ domainCanonical: "panter.cloud",
20
+ },
21
+
22
+ values: {
23
+ application: {
24
+ command: "node main.js",
25
+ autoscale: {
26
+ minReplicas: 2,
27
+ maxReplicas: 5,
28
+ metrics: [
29
+ {
30
+ type: "Resource",
31
+ resource: {
32
+ name: "cpu",
33
+
34
+ target: {
35
+ type: "Utilization",
36
+ averageUtilization: 0.5,
37
+ },
38
+ },
39
+ },
40
+ ],
41
+ },
42
+ resources: {
43
+ limits: {
44
+ cpu: "1",
45
+ memory: "2048Mi",
46
+ },
47
+ },
48
+ },
49
+ },
50
+ },
51
+ },
52
+ },
53
+ };
54
+
55
+ it("matches snapshot", async () => {
56
+ expect(await createAllPipelines(config)).toMatchSnapshot();
57
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@catladder/pipeline",
3
- "version": "1.88.0",
3
+ "version": "1.89.1",
4
4
  "scripts": {
5
5
  "build:tsc": "yarn tsc",
6
6
  "build": "yarn build:compile && yarn build:inline-variables && yarn build:bundle",
@@ -45,20 +45,24 @@ export const requiresDockerBuild = (context: Context) => {
45
45
  return false;
46
46
  };
47
47
 
48
+ const getDockerBaseVariables = () => ({
49
+ DOCKER_HOST: "tcp://0.0.0.0:2375",
50
+ DOCKER_TLS_CERTDIR: "",
51
+ DOCKER_DRIVER: "overlay2",
52
+ DOCKER_BUILDKIT: "1", // see https://docs.docker.com/develop/develop-images/build_enhancements/
53
+ });
54
+
48
55
  export const getDockerBuildVariables = (context: Context) => {
49
56
  return {
50
57
  ...DOCKER_RUNNER_BUILD_VARIABLES,
51
- DOCKER_BUILDKIT: "1", // see https://docs.docker.com/develop/develop-images/build_enhancements/
52
58
  DOCKERFILE_ADDITIONS:
53
59
  context.componentConfig.build.docker?.additionsBegin?.join("\n"),
54
60
  DOCKERFILE_ADDITIONS_END:
55
61
  context.componentConfig.build.docker?.additionsEnd?.join("\n"),
56
62
  APP_DIR: context.componentConfig.dir,
57
- DOCKER_HOST: "tcp://0.0.0.0:2375",
58
- DOCKER_TLS_CERTDIR: "",
59
- DOCKER_DIR: ".", // relative to componentdir
60
63
 
61
- DOCKER_DRIVER: "overlay2",
64
+ DOCKER_DIR: ".", // relative to componentdir
65
+ ...getDockerBaseVariables(),
62
66
 
63
67
  ...getDockerImageVariables(context),
64
68
  };
@@ -74,7 +78,7 @@ export const getDockerJobBaseProps = (context: Context) => {
74
78
  command: ["--tls=false"],
75
79
  },
76
80
  ],
77
- variables: getDockerBuildVariables(context),
81
+ variables: getDockerBaseVariables(),
78
82
  };
79
83
  };
80
84
  export const createDockerBuildJobBase = (
@@ -89,6 +93,9 @@ export const createDockerBuildJobBase = (
89
93
  ...getDockerJobBaseProps(context),
90
94
  script: script || [],
91
95
  },
96
+ {
97
+ variables: getDockerBuildVariables(context),
98
+ },
92
99
  def
93
100
  );
94
101
  };
@@ -12,10 +12,7 @@ export const createRailsBuildJobs = (context: Context): CatladderJob[] => {
12
12
 
13
13
  const cnbConf = buildConfig.cnbBuilder;
14
14
 
15
- // backwards compatabilty with CNB_ENV_VARS
16
- // TODO: remove when all projects are migrated
17
- const packEnvArgs = buildConfig.extraVars?.CNB_ENV_VARS?.split(" ").map(v => `--env '${v}'`)
18
- ?? Object.entries(cnbConf?.buildVars ?? {}).map(([k, v]) => `--env '${k}${v ? `=${v}` : ""}'`)
15
+ const packEnvArgs = Object.entries(cnbConf?.buildVars ?? {}).map(([k, v]) => `--env '${k}${v ? `=${v}` : ""}'`).join(" ")
19
16
 
20
17
  return [
21
18
  createDockerBuildJobBase(context, {
@@ -28,7 +25,7 @@ export const createRailsBuildJobs = (context: Context): CatladderJob[] => {
28
25
  `chmod +x /usr/local/bin/pack`,
29
26
  // replace private git ssh gem sources with https to make bundler with credentials via env var work
30
27
  `sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock`,
31
- `pack build "$DOCKER_IMAGE:$DOCKER_IMAGE_TAG" --builder '${cnbConf?.image}' --publish --cache-image "$DOCKER_CACHE_IMAGE" ${packEnvArgs.join(" ")} ${cnbConf?.packExtraArgs?.join(" ") ?? ""}`
28
+ `pack build "$DOCKER_IMAGE:$DOCKER_IMAGE_TAG" --builder '${cnbConf?.image}' --publish --cache-image "$DOCKER_CACHE_IMAGE" ${packEnvArgs} ${cnbConf?.packExtraArgs?.join(" ") ?? ""}`
32
29
  ],
33
30
  }),
34
31
  ];
@@ -20,27 +20,29 @@ const createAppConfig = (
20
20
  };
21
21
  }
22
22
 
23
+ const { healthRoute, command, ...rest } = application ?? {};
24
+
23
25
  return mergeWithMergingArrays(
24
26
  {
25
27
  host: context.environment.host,
26
- command: context.componentConfig.build.startCommand,
28
+ command: command ?? context.componentConfig.build.startCommand,
27
29
  livenessProbe: {
28
30
  httpGet: {
29
- path: application?.healthRoute ?? "__health",
31
+ path: healthRoute ?? "__health",
30
32
  },
31
33
  },
32
34
  readinessProbe: {
33
35
  httpGet: {
34
- path: application?.healthRoute ?? "__health",
36
+ path: healthRoute ?? "__health",
35
37
  },
36
38
  },
37
39
  startupProbe: {
38
40
  httpGet: {
39
- path: application?.healthRoute ?? "__health",
41
+ path: healthRoute ?? "__health",
40
42
  },
41
43
  },
42
44
  }, // default
43
- application // merge rest in
45
+ rest // merge rest in
44
46
  );
45
47
  };
46
48
 
@@ -192,6 +192,11 @@ export type DeployConfigKubernetesValues = AllowUnknownProps<{
192
192
  application?:
193
193
  | false
194
194
  | AllowUnknownProps<{
195
+ /**
196
+ * command to start, defaults to build's startCommand
197
+ */
198
+ command?: string;
199
+
195
200
  /**
196
201
  * enable, disable app deployment, defaults to true
197
202
  */
@@ -240,7 +245,7 @@ export type DeployConfigKubernetesValues = AllowUnknownProps<{
240
245
  */
241
246
  jobDefaults?: {
242
247
  resources: KubernetesResourcesDef;
243
- }
248
+ };
244
249
  }>;
245
250
 
246
251
  /**
@@ -292,5 +297,5 @@ export type DeployConfigKubernetes = {
292
297
  * Custom Helm chart location.
293
298
  * Not recommended to use.
294
299
  */
295
- chartName?: string
300
+ chartName?: string;
296
301
  } & DeployConfigBase;
@@ -0,0 +1,38 @@
1
+ import { getAllEnvsByTrigger } from "../config";
2
+ import type { Config, PipelineTrigger } from "../types";
3
+ import type { CatladderJob } from "../types/jobs";
4
+ import { createJobsForComponent } from "./createJobsForComponent";
5
+
6
+ export type AllCatladderJobs = {
7
+ [componentName: string]: {
8
+ [env: string]: Array<CatladderJob>;
9
+ };
10
+ };
11
+ export const createAllJobs = async (
12
+ config: Config,
13
+ trigger: PipelineTrigger
14
+ ): Promise<AllCatladderJobs> => {
15
+ return Object.fromEntries(
16
+ await Promise.all(
17
+ Object.keys(config.components).map(async (componentName) => {
18
+ const envs = getAllEnvsByTrigger(config, componentName, trigger);
19
+ return [
20
+ componentName,
21
+ Object.fromEntries(
22
+ await Promise.all(
23
+ envs.map(async (env) => [
24
+ env,
25
+ await createJobsForComponent(
26
+ config,
27
+ componentName,
28
+ env,
29
+ trigger
30
+ ),
31
+ ])
32
+ )
33
+ ),
34
+ ];
35
+ })
36
+ )
37
+ );
38
+ };
@@ -1,34 +1,18 @@
1
- import { getAllEnvsByTrigger, getAllEnvsInAllComponents } from "../config";
1
+ import { getAllEnvsInAllComponents } from "../config";
2
2
  import { RULES_ALWAYS } from "../rules";
3
3
  import { getRunnerImage } from "../runner";
4
- import type {
5
- GitlabPipeline,
6
- Pipeline,
7
- PipelineJob,
8
- PipelineType,
9
- } from "../types";
4
+ import type { GitlabPipeline, Pipeline, PipelineType } from "../types";
10
5
  import type { Config, PipelineTrigger } from "../types/config";
11
6
  import { BASE_STAGES } from "../types/jobs";
12
- import { createJobs } from "./createJobs";
7
+ import { createAllJobs } from "./createAllJobs";
8
+ import { createGitlabJobs } from "./gitlab/createGitlabJobs";
13
9
 
14
10
  export const createChildPipeline = async <T extends PipelineType>(
15
11
  type: T,
16
12
  trigger: PipelineTrigger,
17
13
  config: Config
18
14
  ): Promise<Pipeline<T>> => {
19
- const components = Object.keys(config.components);
20
-
21
- // 2. write the triggering pipeline
22
- const jobs = await components.reduce<Promise<Record<string, PipelineJob<T>>>>(
23
- async (acc, componentName) => {
24
- const envs = getAllEnvsByTrigger(config, componentName, trigger);
25
- return {
26
- ...(await acc),
27
- ...(await createJobs(type, envs, config, componentName, trigger)),
28
- };
29
- },
30
- Promise.resolve({})
31
- );
15
+ const jobs = await createAllJobs(config, trigger);
32
16
 
33
17
  // while technically not required, we group different envs in its own stage
34
18
  // each job from `createJobs` that is defined as `envMode: "stagePerEnv"` will have `deploy dev`, etc. instead of just `deploy`
@@ -53,7 +37,7 @@ export const createChildPipeline = async <T extends PipelineType>(
53
37
  rules: RULES_ALWAYS,
54
38
  },
55
39
  stages,
56
- jobs,
40
+ jobs: await createGitlabJobs(jobs),
57
41
  };
58
42
  return pipeline as Pipeline<T>;
59
43
  }
@@ -0,0 +1,64 @@
1
+ import { isFunction } from "lodash";
2
+ import { BUILD_TYPES } from "../build";
3
+ import { createContext } from "../context";
4
+ import { DEPLOY_TYPES } from "../deploy";
5
+ import type { Config, PipelineTrigger } from "../types/config";
6
+ import type { CommitInfo, Context } from "../types/context";
7
+ import type { CatladderJob } from "../types/jobs";
8
+ import { getBaseCommitInfo } from "./commitInfo/getCommitInfo";
9
+ import { getPackageManagerInfo } from "./packageManager";
10
+
11
+ const injectDefaultVarsInCustomJobs = (
12
+ context: Context,
13
+ jobs: CatladderJob[]
14
+ ) =>
15
+ jobs.map(({ variables, ...job }) => ({
16
+ variables: {
17
+ ...(context.environment.envVars ?? {}),
18
+ ...(variables ?? {}),
19
+ },
20
+ ...job,
21
+ }));
22
+ const getCustomJobs = (context: Context) => {
23
+ if (!context.componentConfig.customJobs) {
24
+ return [];
25
+ }
26
+ const rawJobs = isFunction(context.componentConfig.customJobs)
27
+ ? context.componentConfig.customJobs(context)
28
+ : context.componentConfig.customJobs;
29
+ return injectDefaultVarsInCustomJobs(context, rawJobs);
30
+ };
31
+ const createRawJobs = (context: Context): CatladderJob[] => {
32
+ if (context.componentConfig.deploy === false) {
33
+ return [];
34
+ }
35
+ const buildJobs =
36
+ BUILD_TYPES[context.componentConfig.build.type].jobs(context);
37
+ const deployJobs =
38
+ DEPLOY_TYPES[context.componentConfig.deploy.type].jobs(context);
39
+
40
+ const customJobs = getCustomJobs(context);
41
+ return [...buildJobs, ...deployJobs, ...customJobs];
42
+ };
43
+ export const createJobsForComponent = async (
44
+ config: Config,
45
+ componentName: string,
46
+ env: string,
47
+ trigger: PipelineTrigger
48
+ ): Promise<Array<CatladderJob>> => {
49
+ const commitInfo: CommitInfo = {
50
+ ...(await getBaseCommitInfo()),
51
+ trigger,
52
+ };
53
+
54
+ const packageManagerInfo = await getPackageManagerInfo(config, componentName);
55
+
56
+ const context = await createContext(
57
+ config,
58
+ componentName,
59
+ env,
60
+ commitInfo,
61
+ packageManagerInfo
62
+ );
63
+ return createRawJobs(context);
64
+ };
@@ -0,0 +1,149 @@
1
+ import { isObject } from "lodash";
2
+ import { BASE_RETRY } from "../../defaults";
3
+ import type { GitlabJobDef } from "../../types";
4
+ import type { CatladderJob, CatladderJobNeed } from "../../types/jobs";
5
+ import type { AllCatladderJobs } from "../createAllJobs";
6
+
7
+ type AllGitlabJobs = Record<string, GitlabJobDef>;
8
+
9
+ const getFullJobName = (
10
+ name: string,
11
+ componentName: string,
12
+ env?: string | null
13
+ ) => {
14
+ if (env) {
15
+ return `${componentName} ${name} | ${env} `;
16
+ }
17
+ return `${componentName} ${name}`;
18
+ };
19
+
20
+ const getFullReferencedJobName = (
21
+ referencedJobName: string,
22
+ componentName: string,
23
+ env: string,
24
+ allJobs: AllCatladderJobs
25
+ ) => {
26
+ const referencedJob = allJobs[componentName]?.[env]?.find(
27
+ (j) => j.name === referencedJobName
28
+ );
29
+ if (!referencedJob) {
30
+ throw new Error(
31
+ `unknown job referenced: '${referencedJobName}' from '${env}:${componentName}'`
32
+ );
33
+ }
34
+ const envToSet = referencedJob.envMode !== "none" ? env : null;
35
+ return getFullJobName(referencedJobName, componentName, envToSet);
36
+ };
37
+
38
+ const getJobName = (need: CatladderJobNeed) =>
39
+ isObject(need) ? need.job : need;
40
+
41
+ export const makeGitlabJob = (
42
+ componentName: string,
43
+ env: string,
44
+ {
45
+ envMode,
46
+ needsStages,
47
+ needsOtherComponent,
48
+ name,
49
+ needs,
50
+ ...job
51
+ }: CatladderJob<string>,
52
+ allJobs: AllCatladderJobs
53
+ ): [fullName: string, job: GitlabJobDef] => {
54
+ const stage = envMode === "stagePerEnv" ? `${job.stage} ${env}` : job.stage;
55
+
56
+ const needsFromStages: CatladderJob["needs"] = needsStages?.flatMap((n) => {
57
+ const referencedComponentName = componentName;
58
+ const allJobNamesFromThatStage =
59
+ allJobs[referencedComponentName]?.[env]
60
+ ?.filter((j) => j.stage === n.stage)
61
+ ?.map((j) => j.name) ?? [];
62
+
63
+ return allJobNamesFromThatStage.map((job) => ({
64
+ job,
65
+ artifacts: n.artifacts ?? false,
66
+ componentName: referencedComponentName,
67
+ }));
68
+ });
69
+ const cleanedNeeds: CatladderJob["needs"] = [
70
+ ...(needs ?? []),
71
+ // pull in legacy needs from other component, which is now identical to needs
72
+ ...(needsOtherComponent ?? []),
73
+ ...(needsFromStages ?? []),
74
+ ];
75
+
76
+ const gitlabNeeds: GitlabJobDef["needs"] = cleanedNeeds
77
+ ?.map((n) =>
78
+ isObject(n)
79
+ ? {
80
+ job: getFullReferencedJobName(
81
+ n.job,
82
+ n.componentName ?? componentName,
83
+ env,
84
+ allJobs
85
+ ),
86
+ artifacts: n.artifacts,
87
+ }
88
+ : getFullReferencedJobName(n, componentName, env, allJobs)
89
+ ) // sort in a predictable manner for snapshot tests
90
+ .sort((a, b) => getJobName(a).localeCompare(getJobName(b)));
91
+
92
+ const fullJobName = getFullJobName(
93
+ name,
94
+ componentName,
95
+ envMode !== "none" ? env : undefined
96
+ );
97
+
98
+ const gitlabJob = {
99
+ ...job,
100
+ stage,
101
+ environment: job.environment?.on_stop
102
+ ? {
103
+ ...job.environment,
104
+ on_stop: getFullReferencedJobName(
105
+ job.environment.on_stop,
106
+ componentName,
107
+ env,
108
+ allJobs
109
+ ),
110
+ }
111
+ : job.environment,
112
+ // sort in a predictable manner for snapshot tests
113
+ needs: gitlabNeeds,
114
+ retry: BASE_RETRY,
115
+ interruptible: true,
116
+ };
117
+
118
+ return [fullJobName, gitlabJob];
119
+ };
120
+
121
+ export const createGitlabJobs = async (
122
+ allJobs: AllCatladderJobs
123
+ ): Promise<AllGitlabJobs> => {
124
+ return Object.keys(allJobs).reduce((accForComponents, componentName) => {
125
+ const componentJobs = allJobs[componentName];
126
+ return {
127
+ ...accForComponents,
128
+ ...Object.keys(componentJobs).reduce((accForEnvs, env) => {
129
+ const jobs = componentJobs[env];
130
+
131
+ return {
132
+ ...accForEnvs,
133
+ ...jobs.reduce((accForJobs, job) => {
134
+ const [fullJobName, gitlabJob] = makeGitlabJob(
135
+ componentName,
136
+ env,
137
+ job,
138
+ allJobs
139
+ );
140
+ return {
141
+ ...accForJobs,
142
+ [fullJobName]: gitlabJob,
143
+ };
144
+ }, {} as AllGitlabJobs),
145
+ };
146
+ }, {} as AllGitlabJobs),
147
+ };
148
+ }, {} as AllGitlabJobs);
149
+ };
@@ -1,2 +1,2 @@
1
1
  export * from "./createChildPipeline";
2
- export * from "./createJobs";
2
+ export * from "./createJobsForComponent";
@@ -1,3 +0,0 @@
1
- import type { PipelineJob } from "../types";
2
- import type { Config, PipelineTrigger } from "../types/config";
3
- export declare const createJobs: <T extends "gitlab">(type: T, envs: string[], config: Config, componentName: string, trigger: PipelineTrigger) => Promise<Record<string, PipelineJob<T>>>;
@@ -1,10 +0,0 @@
1
- import type { GitlabJobDef } from "../../types";
2
- import type { CatladderJob } from "../../types/jobs";
3
- export declare const makeGitlabJob: ({
4
- envMode,
5
- needsStages,
6
- needsOtherComponent,
7
- name,
8
- needs,
9
- ...rest
10
- }: CatladderJob<string>) => GitlabJobDef;
@@ -1,75 +0,0 @@
1
- "use strict";
2
-
3
- var __assign = this && this.__assign || function () {
4
- __assign = Object.assign || function (t) {
5
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6
- s = arguments[i];
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = this && this.__rest || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- var __read = this && this.__read || function (o, n) {
22
- var m = typeof Symbol === "function" && o[Symbol.iterator];
23
- if (!m) return o;
24
- var i = m.call(o),
25
- r,
26
- ar = [],
27
- e;
28
- try {
29
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
30
- } catch (error) {
31
- e = {
32
- error: error
33
- };
34
- } finally {
35
- try {
36
- if (r && !r.done && (m = i["return"])) m.call(i);
37
- } finally {
38
- if (e) throw e.error;
39
- }
40
- }
41
- return ar;
42
- };
43
- var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
44
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
45
- if (ar || !(i in from)) {
46
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
47
- ar[i] = from[i];
48
- }
49
- }
50
- return to.concat(ar || Array.prototype.slice.call(from));
51
- };
52
- exports.__esModule = true;
53
- exports.makeGitlabJob = void 0;
54
- var lodash_1 = require("lodash");
55
- var defaults_1 = require("../../defaults");
56
- var getJobName = function (need) {
57
- return (0, lodash_1.isObject)(need) ? need.job : need;
58
- };
59
- var makeGitlabJob = function (_a) {
60
- var envMode = _a.envMode,
61
- needsStages = _a.needsStages,
62
- needsOtherComponent = _a.needsOtherComponent,
63
- name = _a.name,
64
- needs = _a.needs,
65
- rest = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
66
- return __assign(__assign({}, rest), {
67
- // sort in a predictable manner for snapshot tests
68
- needs: needs ? __spreadArray([], __read(needs), false).sort(function (a, b) {
69
- return getJobName(a).localeCompare(getJobName(b));
70
- }) : undefined,
71
- retry: defaults_1.BASE_RETRY,
72
- interruptible: true
73
- });
74
- };
75
- exports.makeGitlabJob = makeGitlabJob;