@catladder/pipeline 1.12.0 → 1.15.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 (57) hide show
  1. package/dist/build/base/createBuildJob.d.ts +3 -2
  2. package/dist/build/base/createBuildJob.js +11 -17
  3. package/dist/build/docker.d.ts +25 -3
  4. package/dist/build/docker.js +46 -32
  5. package/dist/build/index.d.ts +2 -2
  6. package/dist/build/node/buildJob.d.ts +2 -2
  7. package/dist/build/node/buildJob.js +1 -1
  8. package/dist/build/node/index.d.ts +4 -4
  9. package/dist/build/node/meteor.d.ts +2 -2
  10. package/dist/build/node/meteor.js +1 -1
  11. package/dist/build/node/testJob.d.ts +2 -2
  12. package/dist/build/node/testJob.js +20 -29
  13. package/dist/build/tests/storybook.test.js +10 -23
  14. package/dist/catladder-gitlab.js +33 -2
  15. package/dist/constants.js +1 -1
  16. package/dist/deploy/base.d.ts +3 -4
  17. package/dist/deploy/base.js +27 -33
  18. package/dist/deploy/index.d.ts +2 -2
  19. package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
  20. package/dist/deploy/kubernetes/deployJob.js +32 -38
  21. package/dist/pipeline/createChildPipeline.d.ts +2 -11
  22. package/dist/pipeline/createChildPipeline.js +24 -18
  23. package/dist/pipeline/createChildPipeline.test.js +3 -14
  24. package/dist/pipeline/createJobs.d.ts +2 -2
  25. package/dist/pipeline/createJobs.js +24 -18
  26. package/dist/pipeline/gitlab/makeGitlabJob.d.ts +8 -0
  27. package/dist/pipeline/gitlab/makeGitlabJob.js +45 -0
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/dist/types/gitlab-types.d.ts +10 -22
  30. package/dist/types/gitlab-types.js +1 -3
  31. package/dist/types/index.d.ts +2 -1
  32. package/dist/types/index.js +3 -1
  33. package/dist/types/jobs.d.ts +75 -0
  34. package/dist/types/jobs.js +5 -0
  35. package/dist/types/pipeline.d.ts +4 -0
  36. package/dist/types/pipeline.js +3 -0
  37. package/package.json +1 -1
  38. package/src/build/base/createBuildJob.ts +28 -32
  39. package/src/build/docker.ts +66 -52
  40. package/src/build/index.ts +3 -2
  41. package/src/build/node/buildJob.ts +5 -5
  42. package/src/build/node/index.ts +4 -4
  43. package/src/build/node/meteor.ts +7 -9
  44. package/src/build/node/testJob.ts +31 -40
  45. package/src/build/tests/storybook.test.ts +4 -2
  46. package/src/catladder-gitlab.ts +9 -5
  47. package/src/deploy/base.ts +40 -45
  48. package/src/deploy/index.ts +2 -2
  49. package/src/deploy/kubernetes/deployJob.ts +43 -48
  50. package/src/pipeline/createChildPipeline.test.ts +2 -1
  51. package/src/pipeline/createChildPipeline.ts +23 -21
  52. package/src/pipeline/createJobs.ts +47 -38
  53. package/src/pipeline/gitlab/makeGitlabJob.ts +16 -0
  54. package/src/types/gitlab-types.ts +10 -30
  55. package/src/types/index.ts +1 -0
  56. package/src/types/jobs.ts +88 -0
  57. package/src/types/pipeline.ts +11 -0
@@ -1,6 +1,7 @@
1
- import { Context, GitlabJob, GitlabJobDef } from "../..";
1
+ import { Context } from "../..";
2
+ import { CatladderJob } from "../../types/jobs";
2
3
  export declare const createBuildJob: (context: Context, {
3
4
  script,
4
5
  variables,
5
6
  ...def
6
- }: Partial<GitlabJobDef>) => GitlabJob;
7
+ }: Partial<CatladderJob>) => CatladderJob;
@@ -67,8 +67,6 @@ var lodash_1 = require("lodash");
67
67
 
68
68
  var __1 = require("../..");
69
69
 
70
- var defaults_1 = require("../../defaults");
71
-
72
70
  var utils_1 = require("../../utils");
73
71
 
74
72
  var constants_1 = require("./constants");
@@ -82,23 +80,19 @@ var createBuildJob = function (context, _a) {
82
80
  variables = _a.variables,
83
81
  def = __rest(_a, ["script", "variables"]);
84
82
 
85
- return {
83
+ return (0, lodash_1.merge)({
86
84
  name: constants_1.APP_BUILD_JOB_NAME,
87
85
  envMode: "jobPerEnv",
88
- job: (0, lodash_1.merge)({
89
- stage: "build",
90
- image: (0, __1.getRunnerImage)("jobs-default"),
91
- needs: [],
92
- cache: [],
93
- variables: __assign(__assign(__assign(__assign({}, constants_1.RUNNER_BUILD_RESOURCE_VARIABLES), variables !== null && variables !== void 0 ? variables : {}), context.environment.envVars), (_b = context.componentConfig.build.extraVars) !== null && _b !== void 0 ? _b : {}),
94
- retry: defaults_1.BASE_RETRY,
95
- interruptible: true,
96
- script: __spreadArray(__spreadArray(__spreadArray([], __read((0, getBuildInfo_1.getBuildInfo)(context)), false), ["cd ".concat(context.componentConfig.dir)], false), __read((_c = (0, utils_1.ensureArray)(script)) !== null && _c !== void 0 ? _c : []), false),
97
- artifacts: {
98
- paths: [context.componentConfig.dir + "/__build_info.json"]
99
- }
100
- }, def)
101
- };
86
+ stage: "build",
87
+ image: (0, __1.getRunnerImage)("jobs-default"),
88
+ needs: [],
89
+ cache: [],
90
+ variables: __assign(__assign(__assign(__assign({}, constants_1.RUNNER_BUILD_RESOURCE_VARIABLES), variables !== null && variables !== void 0 ? variables : {}), context.environment.envVars), (_b = context.componentConfig.build.extraVars) !== null && _b !== void 0 ? _b : {}),
91
+ script: __spreadArray(__spreadArray(__spreadArray([], __read((0, getBuildInfo_1.getBuildInfo)(context)), false), ["cd ".concat(context.componentConfig.dir)], false), __read((_c = (0, utils_1.ensureArray)(script)) !== null && _c !== void 0 ? _c : []), false),
92
+ artifacts: {
93
+ paths: [context.componentConfig.dir + "/__build_info.json"]
94
+ }
95
+ }, def);
102
96
  };
103
97
 
104
98
  exports.createBuildJob = createBuildJob;
@@ -1,7 +1,29 @@
1
- import { GitlabJobDef, Context, GitlabJob } from "../types";
1
+ import { Context } from "../types";
2
+ import { CatladderJob } from "../types/jobs";
3
+ export declare const getDockerBuildVariables: (context: Context) => {
4
+ DOCKER_BUILDKIT: string;
5
+ DOCKERFILE_ADDITIONS: string | undefined;
6
+ DOCKERFILE_ADDITIONS_END: string | undefined;
7
+ APP_DIR: string;
8
+ DOCKER_HOST: string;
9
+ DOCKER_TLS_CERTDIR: string;
10
+ DOCKER_DIR: string;
11
+ IMAGE_TAG: string;
12
+ DOCKER_DRIVER: string;
13
+ IMAGE_NAME: string;
14
+ CACHE_IMAGE: string;
15
+ KUBERNETES_CPU_REQUEST: string;
16
+ KUBERNETES_CPU_LIMIT: string;
17
+ KUBERNETES_MEMORY_REQUEST: string;
18
+ KUBERNETES_MEMORY_LIMIT: string;
19
+ };
2
20
  export declare const DOCKER_BUILD_JOB_NAME = "\uD83D\uDD28 docker";
3
- export declare const createDockerBuildJob: (context: Context, {
21
+ export declare const createDockerBuildJobBase: (context: Context, {
4
22
  script,
5
23
  variables,
6
24
  ...def
7
- }: Partial<GitlabJobDef>) => GitlabJob;
25
+ }: Partial<CatladderJob>) => CatladderJob;
26
+ export declare const createDockerBuildJobDefault: (context: Context, {
27
+ script,
28
+ ...def
29
+ }: Partial<CatladderJob>) => CatladderJob;
@@ -61,54 +61,68 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
61
61
  };
62
62
 
63
63
  exports.__esModule = true;
64
- exports.createDockerBuildJob = exports.DOCKER_BUILD_JOB_NAME = void 0;
65
-
66
- var runner_1 = require("../runner");
64
+ exports.createDockerBuildJobDefault = exports.createDockerBuildJobBase = exports.DOCKER_BUILD_JOB_NAME = exports.getDockerBuildVariables = void 0;
67
65
 
68
66
  var lodash_1 = require("lodash");
69
67
 
68
+ var runner_1 = require("../runner");
69
+
70
70
  var DOCKER_RUNNER_BUILD_VARIABLES = {
71
71
  KUBERNETES_CPU_REQUEST: "0.5",
72
72
  KUBERNETES_CPU_LIMIT: "1",
73
73
  KUBERNETES_MEMORY_REQUEST: "1Gi",
74
74
  KUBERNETES_MEMORY_LIMIT: "2Gi"
75
75
  };
76
- exports.DOCKER_BUILD_JOB_NAME = "🔨 docker";
77
76
 
78
- var createDockerBuildJob = function (context, _a) {
79
- var _b, _c, _d, _e;
77
+ var getDockerBuildVariables = function (context) {
78
+ var _a, _b, _c, _d;
79
+
80
+ return __assign(__assign({}, DOCKER_RUNNER_BUILD_VARIABLES), {
81
+ DOCKER_BUILDKIT: "1",
82
+ DOCKERFILE_ADDITIONS: (_b = (_a = context.componentConfig.build.docker) === null || _a === void 0 ? void 0 : _a.additionsBegin) === null || _b === void 0 ? void 0 : _b.join("\n"),
83
+ DOCKERFILE_ADDITIONS_END: (_d = (_c = context.componentConfig.build.docker) === null || _c === void 0 ? void 0 : _c.additionsEnd) === null || _d === void 0 ? void 0 : _d.join("\n"),
84
+ APP_DIR: context.componentConfig.dir,
85
+ DOCKER_HOST: "tcp://0.0.0.0:2375",
86
+ DOCKER_TLS_CERTDIR: "",
87
+ DOCKER_DIR: ".",
88
+ IMAGE_TAG: "$CI_COMMIT_SHA",
89
+ DOCKER_DRIVER: "overlay2",
90
+ IMAGE_NAME: "$CI_REGISTRY_IMAGE/" + context.environment.shortName + "/" + context.componentName,
91
+ CACHE_IMAGE: "$CI_REGISTRY_IMAGE/caches/" + context.componentName
92
+ });
93
+ };
94
+
95
+ exports.getDockerBuildVariables = getDockerBuildVariables;
96
+ exports.DOCKER_BUILD_JOB_NAME = "🔨 docker";
80
97
 
98
+ var createDockerBuildJobBase = function (context, _a) {
81
99
  var script = _a.script,
82
100
  variables = _a.variables,
83
101
  def = __rest(_a, ["script", "variables"]);
84
102
 
85
- return {
103
+ return (0, lodash_1.merge)({
86
104
  name: exports.DOCKER_BUILD_JOB_NAME,
87
105
  envMode: "jobPerEnv",
88
- job: (0, lodash_1.merge)({
89
- stage: "build",
90
- image: (0, runner_1.getRunnerImage)("docker-build"),
91
- interruptible: true,
92
- services: [{
93
- name: "docker:20-dind",
94
- command: ["--tls=false"]
95
- }],
96
- variables: __assign(__assign(__assign({}, DOCKER_RUNNER_BUILD_VARIABLES), {
97
- DOCKER_BUILDKIT: "1",
98
- DOCKERFILE_ADDITIONS: (_c = (_b = context.componentConfig.build.docker) === null || _b === void 0 ? void 0 : _b.additionsBegin) === null || _c === void 0 ? void 0 : _c.join("\n"),
99
- DOCKERFILE_ADDITIONS_END: (_e = (_d = context.componentConfig.build.docker) === null || _d === void 0 ? void 0 : _d.additionsEnd) === null || _e === void 0 ? void 0 : _e.join("\n"),
100
- APP_DIR: context.componentConfig.dir,
101
- DOCKER_HOST: "tcp://0.0.0.0:2375",
102
- DOCKER_TLS_CERTDIR: "",
103
- DOCKER_DIR: ".",
104
- IMAGE_TAG: "$CI_COMMIT_SHA",
105
- DOCKER_DRIVER: "overlay2",
106
- IMAGE_NAME: "$CI_REGISTRY_IMAGE/" + context.environment.shortName + "/" + context.componentName,
107
- CACHE_IMAGE: "$CI_REGISTRY_IMAGE/caches/" + context.componentName
108
- }), variables !== null && variables !== void 0 ? variables : {}),
109
- script: __spreadArray(__spreadArray([], __read(script || []), false), ["docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY", "docker build --network host --cache-from $CACHE_IMAGE --tag $IMAGE_NAME:$IMAGE_TAG -f $APP_DIR/Dockerfile . --build-arg BUILDKIT_INLINE_CACHE=1", "docker push $IMAGE_NAME:$IMAGE_TAG", "docker tag $IMAGE_NAME:$IMAGE_TAG $CACHE_IMAGE", "docker push $CACHE_IMAGE"], false)
110
- }, def)
111
- };
106
+ stage: "build",
107
+ image: (0, runner_1.getRunnerImage)("docker-build"),
108
+ services: [{
109
+ name: "docker:20-dind",
110
+ command: ["--tls=false"]
111
+ }],
112
+ variables: __assign(__assign({}, (0, exports.getDockerBuildVariables)(context)), variables !== null && variables !== void 0 ? variables : {}),
113
+ script: script || []
114
+ }, def);
115
+ };
116
+
117
+ exports.createDockerBuildJobBase = createDockerBuildJobBase;
118
+
119
+ var createDockerBuildJobDefault = function (context, _a) {
120
+ var script = _a.script,
121
+ def = __rest(_a, ["script"]);
122
+
123
+ return (0, exports.createDockerBuildJobBase)(context, __assign({
124
+ script: __spreadArray(__spreadArray([], __read(script || []), false), ["docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY", "docker build --network host --cache-from $CACHE_IMAGE --tag $IMAGE_NAME:$IMAGE_TAG -f $APP_DIR/Dockerfile . --build-arg BUILDKIT_INLINE_CACHE=1", "docker push $IMAGE_NAME:$IMAGE_TAG", "docker tag $IMAGE_NAME:$IMAGE_TAG $CACHE_IMAGE", "docker push $CACHE_IMAGE"], false)
125
+ }, def));
112
126
  };
113
127
 
114
- exports.createDockerBuildJob = createDockerBuildJob;
128
+ exports.createDockerBuildJobDefault = createDockerBuildJobDefault;
@@ -1,10 +1,10 @@
1
1
  import { Context } from "../types/context";
2
- import { GitlabJobs } from "../types/gitlab-types";
2
+ import { CatladderJob } from "../types/jobs";
3
3
  import { BuildConfig } from "./types";
4
4
  export * from "./types";
5
5
  export * from "./node";
6
6
  export declare type BuildTypes = { [type in BuildConfig["type"]]: {
7
- jobs: (context: Context) => GitlabJobs;
7
+ jobs: (context: Context) => CatladderJob[];
8
8
  defaults: () => Partial<Extract<BuildConfig, {
9
9
  type: type;
10
10
  }>>;
@@ -1,3 +1,3 @@
1
1
  import { Context } from "../../types/context";
2
- import { GitlabJobs } from "../../types/gitlab-types";
3
- export declare const createNodeBuildJobs: (context: Context) => GitlabJobs;
2
+ import { CatladderJob } from "../../types/jobs";
3
+ export declare const createNodeBuildJobs: (context: Context) => CatladderJob[];
@@ -90,7 +90,7 @@ var createNodeBuildJobs = function (context) {
90
90
  })) !== null && _c !== void 0 ? _c : []), false)
91
91
  }
92
92
  }) : null;
93
- return __spreadArray(__spreadArray([], __read(appBuildJob ? [appBuildJob] : []), false), [(0, docker_1.createDockerBuildJob)(context, {
93
+ return __spreadArray(__spreadArray([], __read(appBuildJob ? [appBuildJob] : []), false), [(0, docker_1.createDockerBuildJobDefault)(context, {
94
94
  script: [buildConfig.type === "node-static" || buildConfig.type === "storybook" ? "ensureNginxDockerfile" : "ensureNodeDockerfile"],
95
95
  cache: __spreadArray([], __read((0, cache_1.getYarnCache)(context, "pull")), false),
96
96
  variables: {
@@ -1,5 +1,5 @@
1
1
  import type { Context } from "../../types/context";
2
- import type { GitlabJobs } from "../../types/gitlab-types";
3
- export declare const createNodeJobs: (context: Context) => GitlabJobs;
4
- export declare const createStorybookJobs: (context: Context) => GitlabJobs;
5
- export declare const createMeteorJobs: (context: Context) => GitlabJobs;
2
+ import { CatladderJob } from "../../types/jobs";
3
+ export declare const createNodeJobs: (context: Context) => CatladderJob[];
4
+ export declare const createStorybookJobs: (context: Context) => CatladderJob[];
5
+ export declare const createMeteorJobs: (context: Context) => CatladderJob[];
@@ -1,3 +1,3 @@
1
1
  import type { Context } from "../../types/context";
2
- import type { GitlabJobs } from "../../types/gitlab-types";
3
- export declare const createMeteorBuildJobs: (context: Context) => GitlabJobs;
2
+ import { CatladderJob } from "../../types/jobs";
3
+ export declare const createMeteorBuildJobs: (context: Context) => CatladderJob[];
@@ -78,7 +78,7 @@ var createMeteorBuildJobs = function (context) {
78
78
  paths: [context.componentConfig.dir + "/__build_info.json", context.componentConfig.dir + "/dist"]
79
79
  }
80
80
  }) : null;
81
- return __spreadArray(__spreadArray([], __read(appBuildJob ? [appBuildJob] : []), false), [(0, docker_1.createDockerBuildJob)(context, {
81
+ return __spreadArray(__spreadArray([], __read(appBuildJob ? [appBuildJob] : []), false), [(0, docker_1.createDockerBuildJobDefault)(context, {
82
82
  script: ["ensureMeteorDockerfile"],
83
83
  needs: appBuildJob ? [constants_1.APP_BUILD_JOB_NAME] : []
84
84
  })], false);
@@ -1,3 +1,3 @@
1
1
  import { Context } from "../../types/context";
2
- import { GitlabJobs } from "../../types/gitlab-types";
3
- export declare const createNodeTestJobs: (context: Context) => GitlabJobs;
2
+ import { CatladderJob } from "../../types/jobs";
3
+ export declare const createNodeTestJobs: (context: Context) => CatladderJob[];
@@ -52,8 +52,6 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
52
52
  exports.__esModule = true;
53
53
  exports.createNodeTestJobs = void 0;
54
54
 
55
- var defaults_1 = require("../../defaults");
56
-
57
55
  var utils_1 = require("../../utils");
58
56
 
59
57
  var cache_1 = require("./cache");
@@ -76,36 +74,29 @@ var createNodeTestJobs = function (context) {
76
74
  APP_PATH: context.componentConfig.dir
77
75
  }, constants_1.NODE_RUNNER_BUILD_VARIABLES), (_b = buildConfig.extraVars) !== null && _b !== void 0 ? _b : {}),
78
76
  stage: "test",
79
- interruptible: true,
80
77
  needs: [],
81
- retry: defaults_1.BASE_RETRY
78
+ envMode: "none"
82
79
  };
83
80
  var yarnInstall = (0, yarn_1.getYarnInstall)(context);
84
- var auditJob = buildConfig.audit !== false ? {
85
- name: "🛡 audit",
86
- envMode: "none",
87
- job: __assign(__assign({}, base), {
88
- cache: undefined,
89
- script: __spreadArray(["cd ".concat(context.componentConfig.dir)], __read((_d = (0, utils_1.ensureArray)((_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.command)) !== null && _d !== void 0 ? _d : ["yarn audit"]), false),
90
- allow_failure: true
91
- })
92
- } : null;
93
- var lintJob = buildConfig.lint !== false ? {
94
- name: "👮 lint",
95
- envMode: "none",
96
- job: __assign(__assign({}, base), {
97
- cache: (0, cache_1.getNodeCache)(context),
98
- script: __spreadArray(__spreadArray(["cd ".concat(context.componentConfig.dir)], __read(yarnInstall), false), __read((_f = (0, utils_1.ensureArray)((_e = buildConfig.lint) === null || _e === void 0 ? void 0 : _e.command)) !== null && _f !== void 0 ? _f : ["yarn lint"]), false)
99
- })
100
- } : null;
101
- var testJob = buildConfig.test !== false ? {
102
- name: "🧪 test",
103
- envMode: "none",
104
- job: __assign(__assign({}, base), {
105
- cache: (0, cache_1.getNodeCache)(context),
106
- script: __spreadArray(__spreadArray(["cd ".concat(context.componentConfig.dir)], __read(yarnInstall), false), __read((_h = (0, utils_1.ensureArray)((_g = buildConfig.test) === null || _g === void 0 ? void 0 : _g.command)) !== null && _h !== void 0 ? _h : ["yarn test"]), false)
107
- })
108
- } : null;
81
+ var auditJob = buildConfig.audit !== false ? __assign(__assign({
82
+ name: "🛡 audit"
83
+ }, base), {
84
+ cache: undefined,
85
+ script: __spreadArray(["cd ".concat(context.componentConfig.dir)], __read((_d = (0, utils_1.ensureArray)((_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.command)) !== null && _d !== void 0 ? _d : ["yarn audit"]), false),
86
+ allow_failure: true
87
+ }) : null;
88
+ var lintJob = buildConfig.lint !== false ? __assign(__assign({
89
+ name: "👮 lint"
90
+ }, base), {
91
+ cache: (0, cache_1.getNodeCache)(context),
92
+ script: __spreadArray(__spreadArray(["cd ".concat(context.componentConfig.dir)], __read(yarnInstall), false), __read((_f = (0, utils_1.ensureArray)((_e = buildConfig.lint) === null || _e === void 0 ? void 0 : _e.command)) !== null && _f !== void 0 ? _f : ["yarn lint"]), false)
93
+ }) : null;
94
+ var testJob = buildConfig.test !== false ? __assign(__assign({
95
+ name: "🧪 test"
96
+ }, base), {
97
+ cache: (0, cache_1.getNodeCache)(context),
98
+ script: __spreadArray(__spreadArray(["cd ".concat(context.componentConfig.dir)], __read(yarnInstall), false), __read((_h = (0, utils_1.ensureArray)((_g = buildConfig.test) === null || _g === void 0 ? void 0 : _g.command)) !== null && _h !== void 0 ? _h : ["yarn test"]), false)
99
+ }) : null;
109
100
  return [auditJob, lintJob, testJob].filter(utils_1.notNil);
110
101
  };
111
102
 
@@ -141,17 +141,6 @@ var __generator = this && this.__generator || function (thisArg, body) {
141
141
  }
142
142
  };
143
143
 
144
- var __rest = this && this.__rest || function (s, e) {
145
- var t = {};
146
-
147
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
148
-
149
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
150
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
151
- }
152
- return t;
153
- };
154
-
155
144
  exports.__esModule = true;
156
145
 
157
146
  var __1 = require("../../");
@@ -181,17 +170,16 @@ describe("storybook build", function () {
181
170
  };
182
171
  it("creates a pipeline for storybook that does not contain test stages", function () {
183
172
  return __awaiter(void 0, void 0, void 0, function () {
184
- var _a, image, stages, workflow, jobs;
185
-
186
- return __generator(this, function (_b) {
187
- switch (_b.label) {
173
+ var jobs;
174
+ return __generator(this, function (_a) {
175
+ switch (_a.label) {
188
176
  case 0:
189
177
  return [4
190
178
  /*yield*/
191
- , (0, __1.createChildPipeline)("mainBranch", config)];
179
+ , (0, __1.createChildPipeline)("gitlab", "mainBranch", config)];
192
180
 
193
181
  case 1:
194
- _a = _b.sent(), image = _a.image, stages = _a.stages, workflow = _a.workflow, jobs = __rest(_a, ["image", "stages", "workflow"]);
182
+ jobs = _a.sent().jobs;
195
183
  expect(Object.keys(jobs)).toEqual(["dev my-app app-build", "dev my-app docker-build", "dev my-app deploy-to-kubernetes", "dev my-app kubernetes-stop"]);
196
184
  return [2
197
185
  /*return*/
@@ -202,17 +190,16 @@ describe("storybook build", function () {
202
190
  });
203
191
  it("runs build and renames folder", function () {
204
192
  return __awaiter(void 0, void 0, void 0, function () {
205
- var _a, image, stages, workflow, jobs, buildJob;
206
-
207
- return __generator(this, function (_b) {
208
- switch (_b.label) {
193
+ var jobs, buildJob;
194
+ return __generator(this, function (_a) {
195
+ switch (_a.label) {
209
196
  case 0:
210
197
  return [4
211
198
  /*yield*/
212
- , (0, __1.createChildPipeline)("mainBranch", config)];
199
+ , (0, __1.createChildPipeline)("gitlab", "mainBranch", config)];
213
200
 
214
201
  case 1:
215
- _a = _b.sent(), image = _a.image, stages = _a.stages, workflow = _a.workflow, jobs = __rest(_a, ["image", "stages", "workflow"]);
202
+ jobs = _a.sent().jobs;
216
203
  buildJob = jobs["dev my-app app-build"];
217
204
  expect(buildJob.script).toContain("yarn storybook");
218
205
  expect(buildJob.script).toContain("mv ./storybook-out /dist");
@@ -1,9 +1,36 @@
1
1
  "use strict";
2
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
+
8
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
9
+ }
10
+
11
+ return t;
12
+ };
13
+
14
+ return __assign.apply(this, arguments);
15
+ };
16
+
17
+ var __rest = this && this.__rest || function (s, e) {
18
+ var t = {};
19
+
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
21
+
22
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
24
+ }
25
+ return t;
26
+ };
27
+
3
28
  exports.__esModule = true;
4
29
 
5
30
  var fs_1 = require("fs");
6
31
 
32
+ var js_yaml_1 = require("js-yaml");
33
+
7
34
  var config_1 = require("./config");
8
35
 
9
36
  var constants_1 = require("./constants");
@@ -30,8 +57,12 @@ if (trigger) {
30
57
  throw new Error("no catladder config found");
31
58
  }
32
59
 
33
- (0, pipeline_1.createChildPipeline)(trigger, config).then(function (mainPipeline) {
34
- (0, fs_1.writeFileSync)("__pipeline.yml", JSON.stringify(mainPipeline, null, 2), {
60
+ (0, pipeline_1.createChildPipeline)("gitlab", trigger, config).then(function (_a) {
61
+ var jobs = _a.jobs,
62
+ mainPipeline = __rest(_a, ["jobs"]); // need to spread out the jobs
63
+
64
+
65
+ (0, fs_1.writeFileSync)("__pipeline.yml", (0, js_yaml_1.dump)(__assign(__assign({}, jobs), mainPipeline)), {
35
66
  encoding: "utf-8"
36
67
  });
37
68
  });
package/dist/constants.js CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
5
- exports.PIPELINE_IMAGE_TAG = "v1-12-0-eb5ba084" || "";
5
+ exports.PIPELINE_IMAGE_TAG = "v1-15-0-c7ff99cc" || "";
6
6
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
@@ -1,9 +1,8 @@
1
- import { GitlabJob, Context, GitlabJobDef } from "../types";
1
+ import { Context } from "../types";
2
+ import { CatladderJob } from "../types/jobs";
2
3
  export declare const DEPLOY_JOB_NAME = "\uD83D\uDE80 Deploy";
3
4
  export declare const STOP_JOB_NAME = "\uD83D\uDED1 Stop \u26A0\uFE0F";
4
- declare type JobWithoutScript = Omit<GitlabJob, "job"> & {
5
- job: Omit<GitlabJobDef, "script">;
6
- };
5
+ declare type JobWithoutScript = Omit<CatladderJob, "script">;
7
6
  export declare const getBaseDeploymentJob: (context: Context) => JobWithoutScript;
8
7
  export declare const getBaseDeploymentStopJob: (context: Context) => JobWithoutScript;
9
8
  export {};
@@ -49,20 +49,17 @@ var getBaseDeploymentJob = function (context) {
49
49
  stage: "test",
50
50
  artifacts: false
51
51
  }],
52
- job: {
53
- rules: [autoDeploy ? {
54
- when: "on_success"
55
- } : {
56
- when: "manual"
57
- }],
58
- stage: "deploy",
59
- dependencies: [],
60
- variables: __assign({}, DEPLOY_RUNNER_VARIABLES),
61
- environment: __assign(__assign({}, environment), {
62
- on_stop: exports.STOP_JOB_NAME,
63
- auto_stop_in: autoStop
64
- })
65
- }
52
+ rules: [autoDeploy ? {
53
+ when: "on_success"
54
+ } : {
55
+ when: "manual"
56
+ }],
57
+ stage: "deploy",
58
+ variables: __assign({}, DEPLOY_RUNNER_VARIABLES),
59
+ environment: __assign(__assign({}, environment), {
60
+ on_stop: exports.STOP_JOB_NAME,
61
+ auto_stop_in: autoStop
62
+ })
66
63
  };
67
64
  };
68
65
 
@@ -76,25 +73,22 @@ var getBaseDeploymentStopJob = function (context) {
76
73
  return {
77
74
  name: exports.STOP_JOB_NAME,
78
75
  envMode: "stagePerEnv",
79
- job: {
80
- needs: [exports.DEPLOY_JOB_NAME],
81
- rules: [{
82
- "if": "$CI_COMMIT_BRANCH =~ /^[0-9]+\\.([0-9]+|x)\\.x$/",
83
- when: "on_success",
84
- allow_failure: true
85
- }, {
86
- when: "manual",
87
- allow_failure: true
88
- }],
89
- variables: __assign(__assign({}, DEPLOY_RUNNER_VARIABLES), {
90
- GIT_STRATEGY: "none"
91
- }),
92
- stage: "stop",
93
- dependencies: [],
94
- environment: __assign(__assign({}, environment), {
95
- action: "stop"
96
- })
97
- }
76
+ needs: [exports.DEPLOY_JOB_NAME],
77
+ rules: [{
78
+ "if": "$CI_COMMIT_BRANCH =~ /^[0-9]+\\.([0-9]+|x)\\.x$/",
79
+ when: "on_success",
80
+ allow_failure: true
81
+ }, {
82
+ when: "manual",
83
+ allow_failure: true
84
+ }],
85
+ variables: __assign(__assign({}, DEPLOY_RUNNER_VARIABLES), {
86
+ GIT_STRATEGY: "none"
87
+ }),
88
+ stage: "stop",
89
+ environment: __assign(__assign({}, environment), {
90
+ action: "stop"
91
+ })
98
92
  };
99
93
  };
100
94
 
@@ -1,11 +1,11 @@
1
- import { GitlabJobs } from "../types/gitlab-types";
2
1
  import { Context } from "../types/context";
2
+ import { CatladderJob } from "../types/jobs";
3
3
  import { DeployConfig } from "./types";
4
4
  export * from "./kubernetes";
5
5
  export * from "./types";
6
6
  export * from "./utils";
7
7
  export declare type DeployTypes = { [type in DeployConfig["type"]]: {
8
- jobs: (context: Context) => GitlabJobs;
8
+ jobs: (context: Context) => CatladderJob[];
9
9
  defaults: () => Partial<Extract<DeployConfig, {
10
10
  type: type;
11
11
  }>>;
@@ -1,3 +1,3 @@
1
- import { GitlabJobs } from "../../types/gitlab-types";
2
1
  import { Context } from "../../types/context";
3
- export declare const createKubernetesDeployJobs: (context: Context) => GitlabJobs;
2
+ import { CatladderJob } from "../../types/jobs";
3
+ export declare const createKubernetesDeployJobs: (context: Context) => CatladderJob[];