Added dev reporting

This commit is contained in:
Dunemask 2022-07-07 21:45:38 +00:00
parent d4acc497f1
commit f559b653f2
10 changed files with 145 additions and 12 deletions

59
lib/core/job-builder.js Normal file
View file

@ -0,0 +1,59 @@
const baseCommand = "node";
const suiteEntry = "dev/suite/runner.js";
const pipelineMapping = [
{
id: 0,
pipeline: [{ name: "primary" }, { name: "secondary", delay: 5000 }],
},
];
const buildCommon = (jobRequest) => {
const { testName } = jobRequest;
if (!testName) throw Error("'testName' must be provided!");
const command = [baseCommand, suiteEntry, `test=${testName}`];
// Apply Common Flags
command.push("isRetry=false");
// Return new request
return { ...jobRequest, command };
};
const buildSingle = (jobReq) => jobReq;
const buildMarker = (jobReq) => {};
const buildProject = (jobReq) => {};
const pipelineMaxLife = (testName) => {
const pipelines = pipelineMapping
.filter((m) => m.pipeline.find((t) => t.name === testName))
.map((m) => m.pipeline);
return Math.max(pipelines.map((p) => p.length)) + 1;
};
const buildCompound = (jobReq, socketId) => {
const { testName, command } = jobReq;
const pipelineLife = jobReq.pipelineLife ?? pipelineMaxLife(testName);
command.push(`pipelineLife=${pipelineLife}`);
command.push(`pipelineDashboardSocket=${socketId}`);
return { ...jobReq, command };
};
const nextCompound = (previousTest) => {};
export default function jobBuilder(jobRequest, id) {
const jobReq = buildCommon(jobRequest, id);
switch (jobRequest.type) {
case "single":
return buildSingle(jobReq);
case "marker":
return buildMarker(jobReq);
case "project":
return buildProject(jobReq);
case "compound":
return buildCompound(jobReq, id);
default:
throw Error("No Job Request Type Specified!");
}
}