@catladder/pipeline 2.7.0 → 2.7.2
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.
- package/dist/constants.js +1 -1
- package/dist/deploy/cloudRun/createJobs/cloudRunJobs.js +39 -32
- package/dist/pipeline/gitlab/createGitlabJobs.js +13 -9
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/__snapshots__/cloud-run-http2.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-nextjs.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +0 -32
- package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +0 -16
- package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +0 -16
- package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +0 -16
- package/examples/__snapshots__/custom-build-job.test.ts.snap +0 -16
- package/examples/__snapshots__/custom-deploy.test.ts.snap +0 -4
- package/examples/__snapshots__/custom-sbom-java.test.ts.snap +0 -16
- package/examples/__snapshots__/custom-verify-job.test.ts.snap +0 -24
- package/examples/__snapshots__/git-submodule.test.ts.snap +0 -16
- package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +0 -32
- package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +0 -32
- package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +0 -64
- package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +0 -32
- package/examples/__snapshots__/local-dot-env.test.ts.snap +0 -16
- package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +0 -32
- package/examples/__snapshots__/multiline-var.test.ts.snap +0 -64
- package/examples/__snapshots__/native-app.test.ts.snap +0 -16
- package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +0 -16
- package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +0 -16
- package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +0 -32
- package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +0 -32
- package/examples/__snapshots__/referencing-other-vars.test.ts.snap +0 -64
- package/examples/__snapshots__/workspace-api-www-turbo-cache.test.ts.snap +0 -32
- package/examples/__snapshots__/workspace-api-www.test.ts.snap +0 -32
- package/package.json +1 -1
- package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +65 -49
- package/src/pipeline/gitlab/createGitlabJobs.ts +18 -12
package/dist/constants.js
CHANGED
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
7
|
-
exports.PIPELINE_IMAGE_TAG = "v2-7-
|
|
7
|
+
exports.PIPELINE_IMAGE_TAG = "v2-7-2-85751a1a" || "latest";
|
|
8
8
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";
|
|
@@ -67,14 +67,14 @@ var getJobRunScriptForJob = function (context, jobName, wait) {
|
|
|
67
67
|
};
|
|
68
68
|
var getDeleteSchedulesScripts = function (context) {
|
|
69
69
|
var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
70
|
-
var
|
|
70
|
+
var schedules = getSchedules(context);
|
|
71
71
|
var argsString = (0, createArgsString_1.createArgsString)({
|
|
72
72
|
project: deployConfig.projectId,
|
|
73
73
|
location: deployConfig.region
|
|
74
74
|
});
|
|
75
|
-
return
|
|
76
|
-
var
|
|
77
|
-
return ["".concat((0, common_1.gcloudSchedulerCmd)(), " jobs delete ").concat(
|
|
75
|
+
return schedules.map(function (_a) {
|
|
76
|
+
var name = _a.name;
|
|
77
|
+
return ["".concat((0, common_1.gcloudSchedulerCmd)(), " jobs delete ").concat(name, " ").concat(argsString)];
|
|
78
78
|
}).flat();
|
|
79
79
|
};
|
|
80
80
|
exports.getDeleteSchedulesScripts = getDeleteSchedulesScripts;
|
|
@@ -141,45 +141,52 @@ var getJobCreateScripts = function (context) {
|
|
|
141
141
|
};
|
|
142
142
|
exports.getJobCreateScripts = getJobCreateScripts;
|
|
143
143
|
var getCreateScheduleScripts = function (context) {
|
|
144
|
-
var
|
|
144
|
+
var schedules = getSchedules(context);
|
|
145
145
|
var _a = (0, common_1.getCloudRunDeployConfig)(context),
|
|
146
146
|
location = _a.region,
|
|
147
147
|
project = _a.projectId;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
schedulerName = _a.schedulerName;
|
|
162
|
-
var argsString = (0, createArgsString_1.createArgsString)(__assign(__assign({}, gcloudArgs), {
|
|
163
|
-
schedule: "\"".concat(schedule, "\""),
|
|
164
|
-
"max-retry-attempts": maxRetryAttempts !== null && maxRetryAttempts !== void 0 ? maxRetryAttempts : 0
|
|
165
|
-
}));
|
|
166
|
-
return [jobIndex === 0 ? "exist_scheduler_names=\"$(\n ".concat((0, common_1.gcloudSchedulerCmd)(), " jobs list --filter='httpTarget.uri ~ ").concat(context.env, ".*").concat(context.name, "' --format='value(name)' --limit=999 --location='").concat(location, "' --project='").concat(project, "'\n)\"") : null, "current_job_uri=\"".concat(uriBase, "/").concat(jobName, ":run\""), "current_scheduler_name=\"".concat(schedulerName, "\""), "if grep \"$current_scheduler_name\" <<<\"$exist_scheduler_names\" >/dev/null; then", " ".concat((0, common_1.gcloudSchedulerCmd)(), " jobs update http \"$current_scheduler_name\" ").concat(argsString), "else", " ".concat((0, common_1.gcloudSchedulerCmd)(), " jobs create http \"$current_scheduler_name\" ").concat(argsString), "fi"].filter(utils_1.notNil).join("\n");
|
|
148
|
+
return schedules.map(function (scheduler, jobIndex) {
|
|
149
|
+
var _a;
|
|
150
|
+
var uri = getSchedulerUrl(scheduler, context);
|
|
151
|
+
var argsString = (0, createArgsString_1.createArgsString)({
|
|
152
|
+
project: project,
|
|
153
|
+
location: location,
|
|
154
|
+
uri: "\"$current_job_uri\"",
|
|
155
|
+
"http-method": "POST",
|
|
156
|
+
"oauth-service-account-email": "\"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com\"",
|
|
157
|
+
schedule: "\"".concat(scheduler.schedule, "\""),
|
|
158
|
+
"max-retry-attempts": (_a = scheduler.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0
|
|
159
|
+
});
|
|
160
|
+
return [jobIndex === 0 ? "exist_scheduler_names=\"$(\n ".concat((0, common_1.gcloudSchedulerCmd)(), " jobs list --filter='httpTarget.uri ~ ").concat(context.env, ".*").concat(context.name, "' --format='value(name)' --limit=999 --location='").concat(location, "' --project='").concat(project, "'\n)\"") : null, "current_job_uri=\"".concat(uri, "\""), "current_scheduler_name=\"".concat(scheduler.name, "\""), "if grep \"$current_scheduler_name\" <<<\"$exist_scheduler_names\" >/dev/null; then", " ".concat((0, common_1.gcloudSchedulerCmd)(), " jobs update http \"$current_scheduler_name\" ").concat(argsString), "else", " ".concat((0, common_1.gcloudSchedulerCmd)(), " jobs create http \"$current_scheduler_name\" ").concat(argsString), "fi"].filter(utils_1.notNil).join("\n");
|
|
167
161
|
});
|
|
168
162
|
};
|
|
169
163
|
exports.getCreateScheduleScripts = getCreateScheduleScripts;
|
|
170
|
-
var
|
|
164
|
+
var getSchedulerUrl = function (scheduler, context) {
|
|
165
|
+
if (scheduler.type === "cloudRunJob") {
|
|
166
|
+
var _a = (0, common_1.getCloudRunDeployConfig)(context),
|
|
167
|
+
location_1 = _a.region,
|
|
168
|
+
project = _a.projectId;
|
|
169
|
+
var uriBase = "https://".concat(location_1, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(project, "/jobs");
|
|
170
|
+
return "".concat(uriBase, "/").concat(scheduler.jobName, ":run");
|
|
171
|
+
}
|
|
172
|
+
throw new Error("Unknown scheduler type: ".concat(scheduler.type));
|
|
173
|
+
};
|
|
174
|
+
var getSchedules = function (context) {
|
|
171
175
|
var jobsWithNames = getCloudRunJobsWithNames(context);
|
|
172
176
|
return jobsWithNames.filter(function (entry) {
|
|
173
177
|
return entry.job.when === "schedule";
|
|
174
178
|
}).map(function (_a) {
|
|
175
|
-
var
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
var _b = _a.job,
|
|
180
|
+
maxRetryAttempts = _b.maxRetryAttempts,
|
|
181
|
+
schedule = _b.schedule,
|
|
182
|
+
jobName = _a.jobName;
|
|
183
|
+
var schedulerName = jobName.concat("-scheduler");
|
|
178
184
|
return {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
185
|
+
name: schedulerName,
|
|
186
|
+
maxRetryAttempts: maxRetryAttempts,
|
|
187
|
+
schedule: schedule,
|
|
188
|
+
type: "cloudRunJob",
|
|
189
|
+
jobName: jobName
|
|
183
190
|
};
|
|
184
191
|
});
|
|
185
192
|
};
|
|
@@ -312,24 +312,28 @@ var addGitlabEnvironment = function (context, catladderJobEnvironment, job, allJ
|
|
|
312
312
|
restEnvironment = __rest(catladderJobEnvironment, ["on_stop"]);
|
|
313
313
|
// those can be dynamic, so we therefore have to do this: https://docs.gitlab.com/ee/ci/environments/#set-a-dynamic-environment-url
|
|
314
314
|
var dotEnvFile = "gitlab_environment.env";
|
|
315
|
+
var createsJobEnv = !catladderJobEnvironment.action || catladderJobEnvironment.action === "start";
|
|
316
|
+
var artifacts = (0, lodash_1.merge)((_a = job.artifacts) !== null && _a !== void 0 ? _a : {}, createsJobEnv ? {
|
|
317
|
+
reports: {
|
|
318
|
+
dotenv: dotEnvFile
|
|
319
|
+
}
|
|
320
|
+
} : {});
|
|
315
321
|
var scriptToAdd = ["echo \"".concat(exports.GITLAB_ENVIRONMENT_URL_VARIABLE, "=").concat((0, BashExpression_1.getBashVariable)("ROOT_URL"), "\" >> ").concat(dotEnvFile)];
|
|
316
322
|
// this is NOT a bashVariable since it NEEDS to be used as a string in gitlab
|
|
317
323
|
var gitlabEnvironmentName = envType === "review" ? "".concat(env, "/$CI_COMMIT_REF_NAME/").concat(name) // FIXME: should be replaced with mr name as well
|
|
318
324
|
: "".concat(env, "/").concat(name);
|
|
319
|
-
return __assign(__assign({}, job), {
|
|
325
|
+
return __assign(__assign(__assign(__assign({}, job), {
|
|
320
326
|
environment: __assign(__assign(__assign({
|
|
321
327
|
name: gitlabEnvironmentName
|
|
322
|
-
},
|
|
328
|
+
}, createsJobEnv ? {
|
|
323
329
|
url: "$".concat(exports.GITLAB_ENVIRONMENT_URL_VARIABLE)
|
|
324
330
|
} : {}), on_stop ? {
|
|
325
331
|
on_stop: getFullReferencedJobNameFromComponent(on_stop, name, env, allJobs)
|
|
326
|
-
} : {}), restEnvironment)
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}),
|
|
332
|
-
script: __spreadArray(__spreadArray([], __read((_b = job.script) !== null && _b !== void 0 ? _b : []), false), __read(scriptToAdd), false)
|
|
332
|
+
} : {}), restEnvironment)
|
|
333
|
+
}), !(0, lodash_1.isEmpty)(artifacts) ? {
|
|
334
|
+
artifacts: artifacts
|
|
335
|
+
} : {}), {
|
|
336
|
+
script: __spreadArray(__spreadArray([], __read((_b = job.script) !== null && _b !== void 0 ? _b : []), false), __read(createsJobEnv ? scriptToAdd : []), false)
|
|
333
337
|
});
|
|
334
338
|
};
|
|
335
339
|
var createGitlabJobs = function (allJobs, baseRules) {
|