Initial loading of AutoPipeline (#6)

Co-authored-by: Dunemask <dunemask@gmail.com>
Reviewed-on: https://gitea.dunemask.net/elysium/qualiteer/pulls/6
This commit is contained in:
dunemask 2023-08-15 13:18:05 +00:00
parent 124151207f
commit ba8e6ded26
2 changed files with 20 additions and 2 deletions

View file

@ -1,8 +1,10 @@
// Imports
import { Worker } from "rabbiteer";
import { VERB } from "../../util/logging.js";
import { getPipelineMappings } from "../../database/queries/catalog.js";
import { insertTestResult } from "../../database/queries/results.js";
import evt from "../../../common/sockets/events.js";
import { asTree, asBranches, as1d } from "../../../../src/util/pipelines.js";
// Class
export default class TestResultsWorker extends Worker {
constructor(skio) {
@ -26,8 +28,9 @@ export default class TestResultsWorker extends Worker {
}
*/
async onMessage(testResult) {
const { pipeline } = testResult;
const { pipeline, autoPipeline } = testResult;
await this.handleReporting(testResult);
if(autoPipeline) return this.autoPipeline(testResult);
// Alter to start next test
// TODO the delay should be autopopulated either by the suite, or filled in by the server
if (pipeline) return this.pipelineTrigger(pipeline);
@ -38,6 +41,22 @@ export default class TestResultsWorker extends Worker {
this.skio.to(dsi).emit(evt.PPL_TRG, pipeline);
}
async autoPipeline(testResult){
const {name} = testResult;
console.log(testResult);
const mappings = await getPipelineMappings();
const primaries = mappings.filter((m) =>
m.find((t) => t.name === name)
);
const pipelineTree = asTree(primaries);
const pipelineReq = pipelineTree[name];
delete pipelineReq.__testDelay;
for(var k of Object.keys(pipelineReq)){
console.log("Would auto start: ", k);
}
}
handleReporting(result) {
VERB("TestResults", result.name);
insertTestResult(result);

View file

@ -3,7 +3,6 @@ import {
getTests,
getPipelineMappings,
upsertTest,
truncateTests,
removeDroppedTests,
} from "../database/queries/catalog.js";
const router = Router();