@catladder/pipeline 0.0.0-refactor-docker-c24f8608 → 0.0.0-refactor-docker-45f6e733

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 (78) hide show
  1. package/dist/build/base/createAppBuildJob.js +6 -6
  2. package/dist/build/base/writeBuildInfo.js +1 -1
  3. package/dist/build/base/writeDotEnv.js +1 -1
  4. package/dist/build/custom/__tests__/testJob.test.js +11 -14
  5. package/dist/build/custom/buildJob.js +3 -3
  6. package/dist/build/custom/testJob.js +5 -5
  7. package/dist/build/docker.d.ts +2 -6
  8. package/dist/build/docker.js +13 -10
  9. package/dist/build/node/buildJob.js +7 -7
  10. package/dist/build/node/cache.js +1 -1
  11. package/dist/build/node/meteor.js +5 -5
  12. package/dist/build/node/testJob.js +11 -11
  13. package/dist/build/rails/build.js +3 -3
  14. package/dist/build/rails/test.js +4 -4
  15. package/dist/build/sbom.js +2 -2
  16. package/dist/bundles/catladder-gitlab/index.js +181 -162
  17. package/dist/constants.js +1 -1
  18. package/dist/context/getLabels.js +1 -1
  19. package/dist/context/index.js +34 -12
  20. package/dist/deploy/base/deploy.js +9 -8
  21. package/dist/deploy/cloudRun/artifactsRegistry.d.ts +1 -5
  22. package/dist/deploy/cloudRun/artifactsRegistry.js +8 -9
  23. package/dist/deploy/cloudRun/cloudRunRevisions.js +4 -5
  24. package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +1 -1
  25. package/dist/deploy/cloudRun/createJobs/common.d.ts +4 -4
  26. package/dist/deploy/cloudRun/createJobs/common.js +2 -1
  27. package/dist/deploy/cloudRun/createJobs/index.js +2 -4
  28. package/dist/deploy/custom/deployJob.js +7 -10
  29. package/dist/deploy/dockerTag/deployJob.js +3 -5
  30. package/dist/deploy/kubernetes/cloudSql/index.js +11 -9
  31. package/dist/deploy/kubernetes/deployJob.js +4 -7
  32. package/dist/deploy/kubernetes/kubeEnv.js +2 -1
  33. package/dist/deploy/kubernetes/kubeValues.js +10 -10
  34. package/dist/deploy/kubernetes/mongodb.js +11 -11
  35. package/dist/deploy/sbom.js +1 -1
  36. package/dist/deploy/types/index.d.ts +1 -1
  37. package/dist/deploy/types/index.js +1 -1
  38. package/dist/deploy/utils.js +2 -1
  39. package/dist/pipeline/createJobsForComponent.js +5 -5
  40. package/dist/tsconfig.tsbuildinfo +1 -1
  41. package/dist/types/config.d.ts +1 -1
  42. package/dist/types/context.d.ts +13 -1
  43. package/package.json +1 -1
  44. package/src/build/base/createAppBuildJob.ts +7 -7
  45. package/src/build/base/writeBuildInfo.ts +1 -1
  46. package/src/build/base/writeDotEnv.ts +1 -1
  47. package/src/build/custom/__tests__/testJob.test.ts +5 -8
  48. package/src/build/custom/buildJob.ts +4 -4
  49. package/src/build/custom/testJob.ts +5 -5
  50. package/src/build/docker.ts +21 -14
  51. package/src/build/node/buildJob.ts +8 -8
  52. package/src/build/node/cache.ts +1 -1
  53. package/src/build/node/meteor.ts +9 -15
  54. package/src/build/node/testJob.ts +14 -14
  55. package/src/build/rails/build.ts +3 -3
  56. package/src/build/rails/test.ts +4 -4
  57. package/src/build/sbom.ts +3 -3
  58. package/src/context/getLabels.ts +1 -1
  59. package/src/context/index.ts +21 -5
  60. package/src/deploy/base/deploy.ts +8 -14
  61. package/src/deploy/cloudRun/artifactsRegistry.ts +5 -10
  62. package/src/deploy/cloudRun/cloudRunRevisions.ts +3 -5
  63. package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +1 -1
  64. package/src/deploy/cloudRun/createJobs/common.ts +5 -5
  65. package/src/deploy/cloudRun/createJobs/index.ts +1 -4
  66. package/src/deploy/custom/deployJob.ts +4 -6
  67. package/src/deploy/dockerTag/deployJob.ts +2 -5
  68. package/src/deploy/kubernetes/cloudSql/index.ts +7 -4
  69. package/src/deploy/kubernetes/deployJob.ts +1 -4
  70. package/src/deploy/kubernetes/kubeEnv.ts +1 -1
  71. package/src/deploy/kubernetes/kubeValues.ts +3 -3
  72. package/src/deploy/kubernetes/mongodb.ts +6 -6
  73. package/src/deploy/sbom.ts +1 -2
  74. package/src/deploy/types/index.ts +2 -2
  75. package/src/deploy/utils.ts +1 -1
  76. package/src/pipeline/createJobsForComponent.ts +6 -10
  77. package/src/types/config.ts +3 -1
  78. package/src/types/context.ts +16 -1
@@ -74,15 +74,15 @@ var createAppBuildJob = function (context, _a) {
74
74
  image: (0, __1.getRunnerImage)("jobs-default"),
75
75
  needs: [],
76
76
  cache: [],
77
- variables: __assign(__assign(__assign(__assign({}, variables !== null && variables !== void 0 ? variables : {}), context.environment.envVars), context.environment.jobOnlyVars.build.envVars), (_b = context.componentConfig.build.extraVars) !== null && _b !== void 0 ? _b : {}),
78
- runnerVariables: __assign(__assign(__assign({}, constants_1.RUNNER_BUILD_RESOURCE_VARIABLES), runnerVariables !== null && runnerVariables !== void 0 ? runnerVariables : {}), (_c = context.componentConfig.build.runnerVariables) !== null && _c !== void 0 ? _c : {}),
77
+ variables: __assign(__assign(__assign(__assign({}, variables !== null && variables !== void 0 ? variables : {}), context.environment.envVars), context.environment.jobOnlyVars.build.envVars), (_b = context.build.config.extraVars) !== null && _b !== void 0 ? _b : {}),
78
+ runnerVariables: __assign(__assign(__assign({}, constants_1.RUNNER_BUILD_RESOURCE_VARIABLES), runnerVariables !== null && runnerVariables !== void 0 ? runnerVariables : {}), (_c = context.build.config.runnerVariables) !== null && _c !== void 0 ? _c : {}),
79
79
  script: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(context.componentConfig.dotEnv === true // don't build when set to `local`
80
- ? (0, writeDotEnv_1.writeDotEnv)(context) : []), false), __read((0, writeBuildInfo_1.writeBuildInfo)(context)), false), __read((0, yarn_1.ensureNodeVersion)(context.buildContext)), false), ["cd ".concat(context.componentConfig.dir)], false), __read((_d = (0, utils_1.ensureArray)(script)) !== null && _d !== void 0 ? _d : []), false),
80
+ ? (0, writeDotEnv_1.writeDotEnv)(context) : []), false), __read((0, writeBuildInfo_1.writeBuildInfo)(context)), false), __read((0, yarn_1.ensureNodeVersion)(context.build)), false), ["cd ".concat(context.build.dir)], false), __read((_d = (0, utils_1.ensureArray)(script)) !== null && _d !== void 0 ? _d : []), false),
81
81
  artifacts: {
82
- paths: [(0, path_1.join)(context.componentConfig.dir, "__build_info.json")],
82
+ paths: [(0, path_1.join)(context.build.dir, "__build_info.json")],
83
83
  reports: {
84
- junit: (_f = (_e = context.componentConfig.build.artifactsReports) === null || _e === void 0 ? void 0 : _e.junit) === null || _f === void 0 ? void 0 : _f.map(function (p) {
85
- return (0, path_1.join)(context.componentConfig.dir, p);
84
+ junit: (_f = (_e = context.build.config.artifactsReports) === null || _e === void 0 ? void 0 : _e.junit) === null || _f === void 0 ? void 0 : _f.map(function (p) {
85
+ return (0, path_1.join)(context.build.dir, p);
86
86
  })
87
87
  }
88
88
  }
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.writeBuildInfo = void 0;
7
7
  var writeBuildInfo = function (context) {
8
- return ["echo '{\"id\":\"".concat(context.environment.envVars.BUILD_INFO_BUILD_ID, "\",\"time\":\"").concat(context.environment.envVars.BUILD_INFO_BUILD_TIME, "\"}' > ").concat(context.componentConfig.dir, "/__build_info.json")];
8
+ return ["echo '{\"id\":\"".concat(context.environment.envVars.BUILD_INFO_BUILD_ID, "\",\"time\":\"").concat(context.environment.envVars.BUILD_INFO_BUILD_TIME, "\"}' > ").concat(context.build.dir, "/__build_info.json")];
9
9
  };
10
10
  exports.writeBuildInfo = writeBuildInfo;
@@ -47,6 +47,6 @@ var writeDotEnv = function (context) {
47
47
  value = _b[1];
48
48
  return "".concat(key, "=").concat(value === null || value === void 0 ? void 0 : value.toString().replaceAll("\n", "\\n"));
49
49
  }).join("\n");
50
- return ["cat <<EOF > ".concat(context.componentConfig.dir, "/.env\n").concat(keyValueString, "\nEOF")];
50
+ return ["cat <<EOF > ".concat(context.build.dir, "/.env\n").concat(keyValueString, "\nEOF")];
51
51
  };
52
52
  exports.writeDotEnv = writeDotEnv;
@@ -5,17 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  var testJob_1 = require("../testJob");
7
7
  describe("createCustomTestJobs", function () {
8
- var componentConfig = {
9
- dir: ".",
10
- build: {
11
- type: "custom",
12
- docker: {
13
- type: "custom"
14
- },
15
- jobImage: ""
16
- },
17
- deploy: {}
18
- };
19
8
  var baseContext = {
20
9
  componentName: "testComponent",
21
10
  environment: {
@@ -23,14 +12,22 @@ describe("createCustomTestJobs", function () {
23
12
  build: {}
24
13
  }
25
14
  },
26
- componentConfig: componentConfig
15
+ build: {
16
+ config: {
17
+ type: "custom",
18
+ docker: {
19
+ type: "custom"
20
+ },
21
+ jobImage: ""
22
+ }
23
+ }
27
24
  };
28
25
  it("throws error when not build type custom", function () {
29
- componentConfig.build.type = "node";
26
+ baseContext.build.config.type = "node";
30
27
  expect(function () {
31
28
  return (0, testJob_1.createCustomTestJobs)(baseContext);
32
29
  }).toThrowError("deploy config is not custom");
33
- componentConfig.build.type = "custom";
30
+ baseContext.build.config.type = "custom";
34
31
  });
35
32
  it("returns empty array if no audit, lint, and test definition", function () {
36
33
  var jobs = (0, testJob_1.createCustomTestJobs)(baseContext);
@@ -47,7 +47,7 @@ var RUNNER_BUILD_VARIABLES = {
47
47
  };
48
48
  var createCustomBuildJobs = function (context) {
49
49
  var _a, _b, _c;
50
- var buildConfig = context.componentConfig.build;
50
+ var buildConfig = context.build.config;
51
51
  if (!(0, types_1.isOfBuildType)(buildConfig, "custom")) {
52
52
  throw new Error("deploy config is not custom");
53
53
  }
@@ -59,8 +59,8 @@ var createCustomBuildJobs = function (context) {
59
59
  services: buildConfig.jobServices,
60
60
  script: __spreadArray([], __read((_a = (0, utils_1.ensureArray)(buildConfig.buildCommand)) !== null && _a !== void 0 ? _a : []), false),
61
61
  artifacts: {
62
- paths: __spreadArray([(0, path_1.join)(context.componentConfig.dir, "__build_info.json"), (0, path_1.join)(context.componentConfig.dir, "dist")], __read((_c = (_b = buildConfig.artifactsPaths) === null || _b === void 0 ? void 0 : _b.map(function (path) {
63
- return (0, path_1.join)(context.componentConfig.dir, path);
62
+ paths: __spreadArray([(0, path_1.join)(context.build.dir, "__build_info.json"), (0, path_1.join)(context.build.dir, "dist")], __read((_c = (_b = buildConfig.artifactsPaths) === null || _b === void 0 ? void 0 : _b.map(function (path) {
63
+ return (0, path_1.join)(context.build.dir, path);
64
64
  })) !== null && _c !== void 0 ? _c : []), false),
65
65
  expire_in: "1 day"
66
66
  }
@@ -60,13 +60,13 @@ var createCustomTestJobs = function (context) {
60
60
  if (context.trigger === "taggedRelease") {
61
61
  return [];
62
62
  }
63
- var buildConfig = context.componentConfig.build;
63
+ var buildConfig = context.build.config;
64
64
  if (!(0, types_1.isOfBuildType)(buildConfig, "custom")) {
65
65
  throw new Error("deploy config is not custom");
66
66
  }
67
67
  var base = {
68
68
  variables: __assign(__assign({
69
- APP_PATH: context.componentConfig.dir
69
+ APP_PATH: context.build.dir
70
70
  }, context.environment.jobOnlyVars.build.envVars), (_a = buildConfig.extraVars) !== null && _a !== void 0 ? _a : {}),
71
71
  runnerVariables: RUNNER_CUSTOM_TEST_VARIABLES,
72
72
  services: buildConfig.jobServices,
@@ -82,19 +82,19 @@ var createCustomTestJobs = function (context) {
82
82
  cache: undefined,
83
83
  script: __spreadArray([], __read((_e = (0, utils_1.ensureArray)((_d = buildConfig.audit) === null || _d === void 0 ? void 0 : _d.command)) !== null && _e !== void 0 ? _e : []), false),
84
84
  allow_failure: true
85
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.componentConfig.dir, (_f = buildConfig.audit) === null || _f === void 0 ? void 0 : _f.artifactsReports, (_g = buildConfig.audit) === null || _g === void 0 ? void 0 : _g.artifacts)) : null;
85
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_f = buildConfig.audit) === null || _f === void 0 ? void 0 : _f.artifactsReports, (_g = buildConfig.audit) === null || _g === void 0 ? void 0 : _g.artifacts)) : null;
86
86
  var lintJob = buildConfig.lint ? __assign(__assign(__assign({
87
87
  name: "👮 lint"
88
88
  }, base), {
89
89
  image: (_j = (_h = buildConfig.lint) === null || _h === void 0 ? void 0 : _h.jobImage) !== null && _j !== void 0 ? _j : buildConfig.jobImage,
90
90
  script: __spreadArray([], __read((_l = (0, utils_1.ensureArray)((_k = buildConfig.lint) === null || _k === void 0 ? void 0 : _k.command)) !== null && _l !== void 0 ? _l : []), false)
91
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.componentConfig.dir, (_m = buildConfig.lint) === null || _m === void 0 ? void 0 : _m.artifactsReports, (_o = buildConfig.lint) === null || _o === void 0 ? void 0 : _o.artifacts)) : null;
91
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_m = buildConfig.lint) === null || _m === void 0 ? void 0 : _m.artifactsReports, (_o = buildConfig.lint) === null || _o === void 0 ? void 0 : _o.artifacts)) : null;
92
92
  var testJob = buildConfig.test ? __assign(__assign(__assign({
93
93
  name: "🧪 test"
94
94
  }, base), {
95
95
  image: (_q = (_p = buildConfig.test) === null || _p === void 0 ? void 0 : _p.jobImage) !== null && _q !== void 0 ? _q : buildConfig.jobImage,
96
96
  script: __spreadArray([], __read((_s = (0, utils_1.ensureArray)((_r = buildConfig.test) === null || _r === void 0 ? void 0 : _r.command)) !== null && _s !== void 0 ? _s : []), false)
97
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.componentConfig.dir, (_t = buildConfig.test) === null || _t === void 0 ? void 0 : _t.artifactsReports, (_u = buildConfig.test) === null || _u === void 0 ? void 0 : _u.artifacts)) : null;
97
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_t = buildConfig.test) === null || _t === void 0 ? void 0 : _t.artifactsReports, (_u = buildConfig.test) === null || _u === void 0 ? void 0 : _u.artifacts)) : null;
98
98
  return [auditJob, lintJob, testJob].filter(utils_1.notNil);
99
99
  };
100
100
  exports.createCustomTestJobs = createCustomTestJobs;
@@ -16,11 +16,7 @@ export declare const getDockerImageVariables: (context: ComponentContext) => {
16
16
  /**
17
17
  * Weather the context requires a docker build
18
18
  */
19
- export declare const requiresDockerBuild: ({
20
- componentConfig: {
21
- deploy
22
- }
23
- }: ComponentContext) => boolean;
19
+ export declare const requiresDockerBuild: (context: ComponentContext) => boolean;
24
20
  export declare const getDockerBuildVariables: (context: ComponentContext) => {
25
21
  DOCKER_IMAGE_TAG: string;
26
22
  DOCKER_REGISTRY: string;
@@ -61,7 +57,7 @@ export declare const getDockerBuildVariables: (context: ComponentContext) => {
61
57
  DOCKERFILE_ADDITIONS_END: string | undefined;
62
58
  };
63
59
  export declare const DOCKER_BUILD_JOB_NAME = "\uD83D\uDD28 docker";
64
- export declare const getDockerJobBaseProps: (context: ComponentContext) => Pick<CatladderJob, "image" | "services" | "variables" | "runnerVariables">;
60
+ export declare const getDockerJobBaseProps: () => Pick<CatladderJob, "image" | "services" | "variables" | "runnerVariables">;
65
61
  export type DockerBuildJobDefinition = Partial<CatladderJob>;
66
62
  export declare const createDockerBuildJobBase: (context: ComponentContext, {
67
63
  script,
@@ -72,7 +72,9 @@ var DOCKER_BUILD_RUNNER_REQUESTS = {
72
72
  KUBERNETES_MEMORY_LIMIT: "2Gi"
73
73
  };
74
74
  var getDockerImageVariables = function (context) {
75
- return __assign(__assign({}, (0, deploy_1.isOfDeployType)(context.componentConfig.deploy, "google-cloudrun") ? {
75
+ var _a;
76
+ var deployConfig = (_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config;
77
+ return __assign(__assign({}, (0, deploy_1.isOfDeployType)(deployConfig, "google-cloudrun") ? {
76
78
  DOCKER_REGISTRY: (0, artifactsRegistry_1.getArtifactsRegistryHost)(context),
77
79
  DOCKER_IMAGE: (0, artifactsRegistry_1.getArtifactsRegistryImageName)(context),
78
80
  DOCKER_CACHE_IMAGE: (0, artifactsRegistry_1.getArtifactsRegistryBuildCacheImage)(context)
@@ -92,9 +94,10 @@ exports.getDockerImageVariables = getDockerImageVariables;
92
94
  /**
93
95
  * Weather the context requires a docker build
94
96
  */
95
- var requiresDockerBuild = function (_a) {
96
- var deploy = _a.componentConfig.deploy;
97
- return (0, deploy_1.isOfDeployType)(deploy, "kubernetes", "google-cloudrun", "dockerTag") || (0, deploy_1.isOfDeployType)(deploy, "custom") && deploy.requiresDocker;
97
+ var requiresDockerBuild = function (context) {
98
+ var _a;
99
+ var deployConfig = (_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config;
100
+ return (0, deploy_1.isOfDeployType)(deployConfig, "kubernetes", "google-cloudrun", "dockerTag") || (0, deploy_1.isOfDeployType)(deployConfig, "custom") && deployConfig.requiresDocker;
98
101
  };
99
102
  exports.requiresDockerBuild = requiresDockerBuild;
100
103
  // those need to be runner variables
@@ -117,14 +120,14 @@ var getDockerAdditions = function (build) {
117
120
  };
118
121
  };
119
122
  var getDockerBuildVariables = function (context) {
120
- return __assign(__assign(__assign({}, getDockerAdditions(context.buildContext.config)), {
121
- APP_DIR: context.buildContext.dir,
123
+ return __assign(__assign(__assign({}, getDockerAdditions(context.build.config)), {
124
+ APP_DIR: context.build.dir,
122
125
  DOCKER_DIR: "."
123
126
  }), (0, exports.getDockerImageVariables)(context));
124
127
  };
125
128
  exports.getDockerBuildVariables = getDockerBuildVariables;
126
129
  exports.DOCKER_BUILD_JOB_NAME = "🔨 docker";
127
- var getDockerJobBaseProps = function (context) {
130
+ var getDockerJobBaseProps = function () {
128
131
  return {
129
132
  image: (0, runner_1.getRunnerImage)("docker-build"),
130
133
  services: [{
@@ -144,7 +147,7 @@ var createDockerBuildJobBase = function (context, _a) {
144
147
  name: exports.DOCKER_BUILD_JOB_NAME,
145
148
  envMode: "jobPerEnv",
146
149
  stage: "build"
147
- }, (0, exports.getDockerJobBaseProps)(context)), {
150
+ }, (0, exports.getDockerJobBaseProps)()), {
148
151
  script: script || []
149
152
  }), {
150
153
  variables: (0, exports.getDockerBuildVariables)(context),
@@ -153,7 +156,7 @@ var createDockerBuildJobBase = function (context, _a) {
153
156
  };
154
157
  exports.createDockerBuildJobBase = createDockerBuildJobBase;
155
158
  var gitlabDockerLogin = function (context) {
156
- return (0, deploy_1.isOfDeployType)(context.componentConfig.deploy, "google-cloudrun") ? __spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), ["gcloud auth configure-docker ".concat((0, artifactsRegistry_1.getArtifactsRegistryHost)(context))], false) : ["docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY"];
159
+ return context.deploy && (0, deploy_1.isOfDeployType)(context.deploy.config, "google-cloudrun") ? __spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), ["gcloud auth configure-docker ".concat((0, artifactsRegistry_1.getArtifactsRegistryHost)(context))], false) : ["docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY"];
157
160
  };
158
161
  exports.gitlabDockerLogin = gitlabDockerLogin;
159
162
  var BUILT_IN_ENSURE_DOCKERFILE_SCRIPTS = {
@@ -174,6 +177,6 @@ var getDockerBuildDefaultScript = function (context, ensureDockerFileScript) {
174
177
  };
175
178
  exports.getDockerBuildDefaultScript = getDockerBuildDefaultScript;
176
179
  var hasDockerfile = function (context) {
177
- return (0, fs_1.existsSync)(path_1.default.join(context.componentConfig.dir, "Dockerfile"));
180
+ return (0, fs_1.existsSync)(path_1.default.join(context.build.dir, "Dockerfile"));
178
181
  };
179
182
  exports.hasDockerfile = hasDockerfile;
@@ -46,20 +46,20 @@ var constants_1 = require("./constants");
46
46
  var yarn_1 = require("./yarn");
47
47
  var createNodeBuildJobs = function (context) {
48
48
  var _a, _b, _c, _d, _e, _f, _g;
49
- var buildConfig = context.componentConfig.build;
49
+ var buildConfig = context.build.config;
50
50
  if (!(0, types_1.isOfBuildType)(buildConfig, "node", "node-static", "storybook")) {
51
51
  throw new Error("deploy config is not node, node-static or storybook");
52
52
  }
53
53
  var defaultImage = (0, runner_1.getRunnerImage)("jobs-default");
54
- var yarnInstall = (0, yarn_1.getYarnInstall)(context.buildContext);
54
+ var yarnInstall = (0, yarn_1.getYarnInstall)(context.build);
55
55
  return (0, base_1.createBuildJobs)(context, {
56
56
  appBuild: buildConfig.buildCommand !== null ? {
57
57
  image: (_a = buildConfig.jobImage) !== null && _a !== void 0 ? _a : defaultImage,
58
58
  runnerVariables: constants_1.NODE_RUNNER_BUILD_VARIABLES,
59
- cache: __spreadArray(__spreadArray(__spreadArray([], __read((_b = (0, utils_1.ensureArray)(buildConfig.jobCache)) !== null && _b !== void 0 ? _b : []), false), __read((0, cache_1.getNodeCache)(context.buildContext)), false), __read((0, cache_1.getNextCache)(context)), false),
59
+ cache: __spreadArray(__spreadArray(__spreadArray([], __read((_b = (0, utils_1.ensureArray)(buildConfig.jobCache)) !== null && _b !== void 0 ? _b : []), false), __read((0, cache_1.getNodeCache)(context.build)), false), __read((0, cache_1.getNextCache)(context)), false),
60
60
  script: __spreadArray(__spreadArray([], __read(yarnInstall), false), __read((_c = (0, utils_1.ensureArray)(buildConfig.buildCommand)) !== null && _c !== void 0 ? _c : []), false),
61
61
  artifacts: {
62
- paths: __spreadArray([context.componentConfig.dir], __read((_e = (_d = context.buildContext.packageManagerInfo) === null || _d === void 0 ? void 0 : _d.currentWorkspaceDependencies) !== null && _e !== void 0 ? _e : []), false).flatMap(function (dir) {
62
+ paths: __spreadArray([context.build.dir], __read((_e = (_d = context.build.packageManagerInfo) === null || _d === void 0 ? void 0 : _d.currentWorkspaceDependencies) !== null && _e !== void 0 ? _e : []), false).flatMap(function (dir) {
63
63
  var _a, _b;
64
64
  return __spreadArray([(0, path_1.join)(dir, "__build_info.json"), (0, path_1.join)(dir, "dist"), (0, path_1.join)(dir, ".next")], __read((_b = (_a = buildConfig.artifactsPaths) === null || _a === void 0 ? void 0 : _a.map(function (path) {
65
65
  return (0, path_1.join)(dir, path);
@@ -72,11 +72,11 @@ var createNodeBuildJobs = function (context) {
72
72
  } : undefined,
73
73
  dockerBuild: {
74
74
  script: (0, docker_1.getDockerBuildScriptWithBuiltInDockerFile)(context, buildConfig.type === "node-static" || buildConfig.type === "storybook" ? "nginx" : "node"),
75
- cache: __spreadArray([], __read((0, cache_1.getYarnCache)(context.buildContext, "pull")), false),
75
+ cache: __spreadArray([], __read((0, cache_1.getYarnCache)(context.build, "pull")), false),
76
76
  variables: {
77
77
  // only required for non static
78
- DOCKER_COPY_AND_INSTALL_APP: (0, yarn_1.getDockerAppCopyAndBuildScript)(context.buildContext),
79
- DOCKER_COPY_WORKSPACE_FILES: (_g = (_f = context.buildContext.packageManagerInfo) === null || _f === void 0 ? void 0 : _f.pathsToCopyInDocker.map(function (dir) {
78
+ DOCKER_COPY_AND_INSTALL_APP: (0, yarn_1.getDockerAppCopyAndBuildScript)(context.build),
79
+ DOCKER_COPY_WORKSPACE_FILES: (_g = (_f = context.build.packageManagerInfo) === null || _f === void 0 ? void 0 : _f.pathsToCopyInDocker.map(function (dir) {
80
80
  return "COPY --chown=node:node ".concat(dir, " /app/").concat(dir);
81
81
  })) === null || _g === void 0 ? void 0 : _g.join("\n")
82
82
  }
@@ -90,7 +90,7 @@ var getNextCache = function (context) {
90
90
  return [{
91
91
  key: context.componentName + "-next-cache",
92
92
  policy: "pull-push",
93
- paths: [context.componentConfig.dir + "/.next/cache/"]
93
+ paths: [context.build.dir + "/.next/cache/"]
94
94
  }];
95
95
  };
96
96
  exports.getNextCache = getNextCache;
@@ -46,18 +46,18 @@ var getMeteorCache = function (context) {
46
46
  return [{
47
47
  key: context.componentName + "meteor-build-cache",
48
48
  policy: "pull-push",
49
- paths: [(0, path_1.join)(context.componentConfig.dir, ".meteor/local/resolver-result-cache.json"), (0, path_1.join)(context.componentConfig.dir, ".meteor/local/plugin-cache"), (0, path_1.join)(context.componentConfig.dir, ".meteor/local/isopacks"), (0, path_1.join)(context.componentConfig.dir, ".meteor/local/bundler-cache/scanner")]
49
+ paths: [(0, path_1.join)(context.build.dir, ".meteor/local/resolver-result-cache.json"), (0, path_1.join)(context.build.dir, ".meteor/local/plugin-cache"), (0, path_1.join)(context.build.dir, ".meteor/local/isopacks"), (0, path_1.join)(context.build.dir, ".meteor/local/bundler-cache/scanner")]
50
50
  }];
51
51
  };
52
52
  var createMeteorBuildJobs = function (context) {
53
- var buildConfig = context.componentConfig.build;
53
+ var buildConfig = context.build.config;
54
54
  if (!(0, types_1.isOfBuildType)(buildConfig, "meteor")) {
55
55
  throw new Error("deploy config is not meteor");
56
56
  }
57
- var yarnInstall = (0, yarn_1.getYarnInstall)(context.buildContext);
57
+ var yarnInstall = (0, yarn_1.getYarnInstall)(context.build);
58
58
  return (0, base_1.createBuildJobs)(context, {
59
59
  appBuild: buildConfig.buildCommand !== null ? {
60
- cache: __spreadArray(__spreadArray([], __read((0, cache_1.getNodeCache)(context.buildContext)), false), __read(getMeteorCache(context)), false),
60
+ cache: __spreadArray(__spreadArray([], __read((0, cache_1.getNodeCache)(context.build)), false), __read(getMeteorCache(context)), false),
61
61
  image: (0, runner_1.getRunnerImage)("jobs-meteor"),
62
62
  variables: {
63
63
  METEOR_DISABLE_OPTIMISTIC_CACHING: "1" // see https://forums.meteor.com/t/veeery-long-building-time-inside-docker-container/58673/17?u=macrozone
@@ -65,7 +65,7 @@ var createMeteorBuildJobs = function (context) {
65
65
 
66
66
  script: __spreadArray(__spreadArray([], __read(yarnInstall), false), ['echo "add healthcheck package"', "meteor add panter:healthroute --allow-superuser", "meteor add qualia:prod-shell --allow-superuser", 'TOOL_NODE_FLAGS="--max_old_space_size=3584 --min_semi_space_size=8 --max_semi_space_size=256 --optimize_for_size" meteor build ./dist --architecture os.linux.x86_64 --allow-superuser --server-only --directory', "cp ./__build_info.json ./dist/bundle/programs/server"], false),
67
67
  artifacts: {
68
- paths: [context.componentConfig.dir + "/__build_info.json", context.componentConfig.dir + "/dist"]
68
+ paths: [context.build.dir + "/__build_info.json", context.build.dir + "/dist"]
69
69
  }
70
70
  } : undefined,
71
71
  dockerBuild: {
@@ -58,41 +58,41 @@ var createNodeTestJobs = function (context) {
58
58
  if (context.trigger === "taggedRelease") {
59
59
  return [];
60
60
  }
61
- var buildConfig = context.componentConfig.build;
61
+ var buildConfig = context.build.config;
62
62
  var defaultImage = (0, runner_1.getRunnerImage)("jobs-default");
63
63
  var base = {
64
64
  variables: __assign(__assign({
65
- APP_PATH: context.componentConfig.dir
65
+ APP_PATH: context.build.dir
66
66
  }, context.environment.jobOnlyVars.build.envVars), (_a = buildConfig.extraVars) !== null && _a !== void 0 ? _a : {}),
67
67
  runnerVariables: constants_1.NODE_RUNNER_BUILD_VARIABLES,
68
68
  stage: "test",
69
69
  needs: [],
70
70
  envMode: "none"
71
71
  };
72
- var yarnInstall = (0, yarn_1.getYarnInstall)(context.buildContext);
72
+ var yarnInstall = (0, yarn_1.getYarnInstall)(context.build);
73
73
  var auditJob = buildConfig.audit !== false ? __assign(__assign(__assign({
74
74
  name: "🛡 audit"
75
75
  }, base), {
76
76
  image: (_c = (_b = buildConfig.audit) === null || _b === void 0 ? void 0 : _b.jobImage) !== null && _c !== void 0 ? _c : defaultImage,
77
77
  cache: undefined,
78
- script: __spreadArray(["cd ".concat(context.componentConfig.dir)], __read((_e = (0, utils_1.ensureArray)((_d = buildConfig.audit) === null || _d === void 0 ? void 0 : _d.command)) !== null && _e !== void 0 ? _e : [((_f = context.buildContext.packageManagerInfo) === null || _f === void 0 ? void 0 : _f.isClassic) ? "yarn audit" : "yarn npm audit --environment production" // yarn 2
78
+ script: __spreadArray(["cd ".concat(context.build.dir)], __read((_e = (0, utils_1.ensureArray)((_d = buildConfig.audit) === null || _d === void 0 ? void 0 : _d.command)) !== null && _e !== void 0 ? _e : [((_f = context.build.packageManagerInfo) === null || _f === void 0 ? void 0 : _f.isClassic) ? "yarn audit" : "yarn npm audit --environment production" // yarn 2
79
79
  ]), false),
80
80
  allow_failure: true
81
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.componentConfig.dir, (_g = buildConfig.audit) === null || _g === void 0 ? void 0 : _g.artifactsReports, (_h = buildConfig.audit) === null || _h === void 0 ? void 0 : _h.artifacts)) : null;
81
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_g = buildConfig.audit) === null || _g === void 0 ? void 0 : _g.artifactsReports, (_h = buildConfig.audit) === null || _h === void 0 ? void 0 : _h.artifacts)) : null;
82
82
  var lintJob = buildConfig.lint !== false ? __assign(__assign(__assign({
83
83
  name: "👮 lint"
84
84
  }, base), {
85
85
  image: (_k = (_j = buildConfig.lint) === null || _j === void 0 ? void 0 : _j.jobImage) !== null && _k !== void 0 ? _k : defaultImage,
86
- cache: (0, cache_1.getNodeCache)(context.buildContext),
87
- script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, yarn_1.ensureNodeVersion)(context.buildContext)), false), ["cd ".concat(context.componentConfig.dir)], false), __read(yarnInstall), false), __read((_m = (0, utils_1.ensureArray)((_l = buildConfig.lint) === null || _l === void 0 ? void 0 : _l.command)) !== null && _m !== void 0 ? _m : ["yarn lint"]), false)
88
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.componentConfig.dir, (_o = buildConfig.lint) === null || _o === void 0 ? void 0 : _o.artifactsReports, (_p = buildConfig.lint) === null || _p === void 0 ? void 0 : _p.artifacts)) : null;
86
+ cache: (0, cache_1.getNodeCache)(context.build),
87
+ script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, yarn_1.ensureNodeVersion)(context.build)), false), ["cd ".concat(context.build.dir)], false), __read(yarnInstall), false), __read((_m = (0, utils_1.ensureArray)((_l = buildConfig.lint) === null || _l === void 0 ? void 0 : _l.command)) !== null && _m !== void 0 ? _m : ["yarn lint"]), false)
88
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_o = buildConfig.lint) === null || _o === void 0 ? void 0 : _o.artifactsReports, (_p = buildConfig.lint) === null || _p === void 0 ? void 0 : _p.artifacts)) : null;
89
89
  var testJob = buildConfig.test !== false ? __assign(__assign(__assign({
90
90
  name: "🧪 test"
91
91
  }, base), {
92
92
  image: (_r = (_q = buildConfig.test) === null || _q === void 0 ? void 0 : _q.jobImage) !== null && _r !== void 0 ? _r : (0, runner_1.getRunnerImage)("jobs-testing-chrome"),
93
- cache: (0, cache_1.getNodeCache)(context.buildContext),
94
- script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, yarn_1.ensureNodeVersion)(context.buildContext)), false), ["cd ".concat(context.componentConfig.dir)], false), __read(yarnInstall), false), __read((_t = (0, utils_1.ensureArray)((_s = buildConfig.test) === null || _s === void 0 ? void 0 : _s.command)) !== null && _t !== void 0 ? _t : ["yarn test"]), false)
95
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.componentConfig.dir, (_u = buildConfig.test) === null || _u === void 0 ? void 0 : _u.artifactsReports, (_v = buildConfig.test) === null || _v === void 0 ? void 0 : _v.artifacts)) : null;
93
+ cache: (0, cache_1.getNodeCache)(context.build),
94
+ script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, yarn_1.ensureNodeVersion)(context.build)), false), ["cd ".concat(context.build.dir)], false), __read(yarnInstall), false), __read((_t = (0, utils_1.ensureArray)((_s = buildConfig.test) === null || _s === void 0 ? void 0 : _s.command)) !== null && _t !== void 0 ? _t : ["yarn test"]), false)
95
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_u = buildConfig.test) === null || _u === void 0 ? void 0 : _u.artifactsReports, (_v = buildConfig.test) === null || _v === void 0 ? void 0 : _v.artifacts)) : null;
96
96
  return [auditJob, lintJob, testJob].filter(utils_1.notNil);
97
97
  };
98
98
  exports.createNodeTestJobs = createNodeTestJobs;
@@ -50,7 +50,7 @@ var docker_1 = require("../docker");
50
50
  var types_1 = require("../types");
51
51
  var createRailsBuildJobs = function (context) {
52
52
  var _a, _b, _c;
53
- var buildConfig = context.componentConfig.build;
53
+ var buildConfig = context.build.config;
54
54
  if (!(0, types_1.isOfBuildType)(buildConfig, "rails")) {
55
55
  // should not happen
56
56
  throw new Error("build type is not rails");
@@ -74,9 +74,9 @@ var createRailsBuildJobs = function (context) {
74
74
  return (0, base_1.createBuildJobs)(context, {
75
75
  appBuild: undefined,
76
76
  dockerBuild: {
77
- variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), context.componentConfig.build.extraVars),
77
+ variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), context.build.config.extraVars),
78
78
  // custom script
79
- script: __spreadArray(__spreadArray([], __read((0, docker_1.gitlabDockerLogin)(context)), false), ["cd ".concat(context.componentConfig.dir), "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
79
+ script: __spreadArray(__spreadArray([], __read((0, docker_1.gitlabDockerLogin)(context)), false), ["cd ".concat(context.build.dir), "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
80
80
  // replace private git ssh gem sources with https to make bundler with credentials via env var work
81
81
  "sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "pack build \"$DOCKER_IMAGE:$DOCKER_IMAGE_TAG\" --builder '".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.image, "' --publish --cache-image \"$DOCKER_CACHE_IMAGE\" ").concat(packEnvArgs, " ").concat((_c = (_b = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _b === void 0 ? void 0 : _b.join(" ")) !== null && _c !== void 0 ? _c : "")], false)
82
82
  }
@@ -53,7 +53,7 @@ var createRailsTestJobs = function (context) {
53
53
  if (context.trigger === "taggedRelease") {
54
54
  return [];
55
55
  }
56
- var buildConfig = context.componentConfig.build;
56
+ var buildConfig = context.build.config;
57
57
  var base = {
58
58
  variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), (_a = buildConfig.extraVars) !== null && _a !== void 0 ? _a : {}),
59
59
  stage: "test",
@@ -76,7 +76,7 @@ var createRailsTestJobs = function (context) {
76
76
  }, base), {
77
77
  cache: undefined,
78
78
  image: (_d = (_c = (_b = buildConfig.audit) === null || _b === void 0 ? void 0 : _b.jobImage) !== null && _c !== void 0 ? _c : buildConfig.jobImage) !== null && _d !== void 0 ? _d : defaultImage,
79
- script: __spreadArray(["cd ".concat(context.componentConfig.dir)], __read((_f = (0, utils_1.ensureArray)((_e = buildConfig.audit) === null || _e === void 0 ? void 0 : _e.command)) !== null && _f !== void 0 ? _f : ["gem install bundler-audit", "bundle audit check"]), false),
79
+ script: __spreadArray(["cd ".concat(context.build.dir)], __read((_f = (0, utils_1.ensureArray)((_e = buildConfig.audit) === null || _e === void 0 ? void 0 : _e.command)) !== null && _f !== void 0 ? _f : ["gem install bundler-audit", "bundle audit check"]), false),
80
80
  allow_failure: true
81
81
  }) : null;
82
82
  var lintJob = buildConfig.lint !== false ? __assign(__assign({
@@ -84,14 +84,14 @@ var createRailsTestJobs = function (context) {
84
84
  }, base), {
85
85
  cache: bundlerCache,
86
86
  image: (_j = (_h = (_g = buildConfig.lint) === null || _g === void 0 ? void 0 : _g.jobImage) !== null && _h !== void 0 ? _h : buildConfig.jobImage) !== null && _j !== void 0 ? _j : defaultImage,
87
- script: __spreadArray(__spreadArray(["cd ".concat(context.componentConfig.dir)], __read(bundlerInstall), false), __read((_l = (0, utils_1.ensureArray)((_k = buildConfig.lint) === null || _k === void 0 ? void 0 : _k.command)) !== null && _l !== void 0 ? _l : ["bundle exec rubocop"]), false)
87
+ script: __spreadArray(__spreadArray(["cd ".concat(context.build.dir)], __read(bundlerInstall), false), __read((_l = (0, utils_1.ensureArray)((_k = buildConfig.lint) === null || _k === void 0 ? void 0 : _k.command)) !== null && _l !== void 0 ? _l : ["bundle exec rubocop"]), false)
88
88
  }) : null;
89
89
  var testJob = buildConfig.test !== false ? __assign(__assign({
90
90
  name: "🧪 test"
91
91
  }, base), {
92
92
  cache: bundlerCache,
93
93
  image: (_p = (_o = (_m = buildConfig.test) === null || _m === void 0 ? void 0 : _m.jobImage) !== null && _o !== void 0 ? _o : buildConfig.jobImage) !== null && _p !== void 0 ? _p : defaultImage,
94
- script: __spreadArray(__spreadArray(["cd ".concat(context.componentConfig.dir)], __read(bundlerInstall), false), __read((_r = (0, utils_1.ensureArray)((_q = buildConfig.test) === null || _q === void 0 ? void 0 : _q.command)) !== null && _r !== void 0 ? _r : ["bundle exec rspec"]), false)
94
+ script: __spreadArray(__spreadArray(["cd ".concat(context.build.dir)], __read(bundlerInstall), false), __read((_r = (0, utils_1.ensureArray)((_q = buildConfig.test) === null || _q === void 0 ? void 0 : _q.command)) !== null && _r !== void 0 ? _r : ["bundle exec rspec"]), false)
95
95
  }) : null;
96
96
  return [auditJob, lintJob, testJob].filter(utils_1.notNil);
97
97
  };
@@ -9,9 +9,9 @@ exports.SBOM_BUILD_JOB_NAME = "🧾 sbom";
9
9
  exports.SBOM_FILE = "__sbom.json";
10
10
  var createSbomBuildJob = function (context) {
11
11
  var _a, _b, _c, _d, _e;
12
- var buildConfig = context.componentConfig.build;
12
+ var buildConfig = context.build.config;
13
13
  var defaultImage = "aquasec/trivy:0.38.3";
14
- var defaultScript = ["trivy fs --quiet --format cyclonedx --output \"".concat(exports.SBOM_FILE, "\" ").concat(((_a = context.buildContext.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.componentIsInWorkspace) ? "." : context.buildContext.dir)];
14
+ var defaultScript = ["trivy fs --quiet --format cyclonedx --output \"".concat(exports.SBOM_FILE, "\" ").concat(((_a = context.build.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.componentIsInWorkspace) ? "." : context.build.dir)];
15
15
  var image = buildConfig.type === "custom" && buildConfig.sbom !== false ? (_c = (_b = buildConfig.sbom) === null || _b === void 0 ? void 0 : _b.jobImage) !== null && _c !== void 0 ? _c : defaultImage : defaultImage;
16
16
  var script = buildConfig.type === "custom" && buildConfig.sbom !== false ? (_e = (0, utils_1.ensureArray)((_d = buildConfig.sbom) === null || _d === void 0 ? void 0 : _d.command)) !== null && _e !== void 0 ? _e : defaultScript : defaultScript;
17
17
  return {