Fixed multipipelining

This commit is contained in:
Dunemask 2022-08-12 20:10:57 +00:00
parent 82a4865404
commit 1bb588f294
13 changed files with 66 additions and 27 deletions

View file

@ -133,9 +133,21 @@ const testsMock = () => {
const mappingsMock = () => { const mappingsMock = () => {
return [ return [
["primary", "secondary1", "tertiary1"], [
["primary", "secondary1", "tertiary2"], { name: "primary", delay: 0 },
["primary", "secondary2", "tertiary3"], { name: "secondary1", delay: 1000 },
{ name: "tertiary1", delay: 0 },
],
[
{ name: "primary", delay: 0 },
{ name: "secondary1", delay: 1000 },
{ name: "tertiary2", delay: 8000 },
],
[
{ name: "primary", delay: 0 },
{ name: "secondary2", delay: 0 },
{ name: "tertiary3", delay: 3000 },
],
]; ];
}; };

View file

@ -26,7 +26,7 @@ const wrapCommand = (jobId, command) => {
JSON.stringify({ jobId, command, url: qualiteerUrl }), JSON.stringify({ jobId, command, url: qualiteerUrl }),
"utf8" "utf8"
).toString("base64"); ).toString("base64");
const curlCmd = `curl -o qltr-executor ${executorUrl} && ${bin} ${payload}`; const curlCmd = `curl -o qltr-executor ${executorUrl} || true && ${bin} ${payload}`;
return curlCmd; return curlCmd;
}; };

View file

@ -109,6 +109,7 @@ export const JobProvider = ({ children }) => {
const onPipelineTrigger = (p) => { const onPipelineTrigger = (p) => {
const { triggers } = p; const { triggers } = p;
for (var t in triggers) { for (var t in triggers) {
if (t === "__testDelay") continue;
const delay = triggers[t].__testDelay ?? 0; const delay = triggers[t].__testDelay ?? 0;
delete triggers[t].__testDelay; delete triggers[t].__testDelay;
const jobReq = { const jobReq = {

View file

@ -10,7 +10,7 @@ const localStorage = { setItem: () => {}, getItem: () => {} };
const localSettings = localStorage.getItem("settings"); const localSettings = localStorage.getItem("settings");
const defaultSettings = { const defaultSettings = {
focusJob: true, focusJob: true,
simplifiedControls: true, simplifiedControls: false,
logAppDetails: true, logAppDetails: true,
defaultRegion: "us", defaultRegion: "us",
defaultPage: "failing", defaultPage: "failing",

View file

@ -44,12 +44,13 @@ export const usePipelineIconState = (pipeline) => {
if (jobStatuses.includes(jobStatus.PENDING)) if (jobStatuses.includes(jobStatus.PENDING))
return statusIcon(jobStatus.PENDING); return statusIcon(jobStatus.PENDING);
if (pipeline.isCanceled) return statusIcon(jobStatus.CANCELED); if (pipeline.isCanceled) return statusIcon(jobStatus.CANCELED);
if (jobStatuses.includes(jobStatus.OK)) return statusIcon(jobStatus.OK);
return statusIcon(jobStatus.QUEUED); return statusIcon(jobStatus.QUEUED);
}; };
export const selectedPipelineBranches = (pipeline) => export const selectedPipelineBranches = (pipeline) =>
pipeline.branches.map((b) => pipeline.branches.map((b) =>
b.filter((t) => pipeline.selectedBranches.includes(t)) b.filter((t) => pipeline.selectedBranches.find((b) => b.name == t.name))
); );
export const findPipelineJobByTestName = (pipeline, jobs, testName) => export const findPipelineJobByTestName = (pipeline, jobs, testName) =>

View file

@ -2,7 +2,7 @@ import _ from "lodash";
const nest = (arr) => { const nest = (arr) => {
const obj = {}; const obj = {};
arr.reduce((o, s) => (o[s] = {}), obj); arr.reduce((o, s) => (o[s.name] = { __testDelay: s.delay }), obj);
return obj; return obj;
}; };
@ -13,10 +13,10 @@ export const asTree = (branches) => {
export const asBranches = (array) => { export const asBranches = (array) => {
const merged = []; const merged = [];
array.forEach((p, i) => { array.forEach((p) => {
p.forEach((v, i) => { p.forEach((v, i) => {
if (!merged[i]) merged[i] = []; if (!merged[i]) merged[i] = [];
if (!merged[i].includes(v)) merged[i].push(v); if (!merged[i].find((t) => t.name == v.name)) merged[i].push(v);
}); });
}); });
return merged; return merged;

View file

@ -2,7 +2,7 @@ import { useQuery } from "@tanstack/react-query";
const QUALITEER_URL = "https://qualiteer.elijahparker3.repl.co/api"; const QUALITEER_URL = "https://qualiteer.elijahparker3.repl.co/api";
const useMock = true; const useMock = false;
const asMock = (data) => ({ data }); const asMock = (data) => ({ data });
@ -134,9 +134,21 @@ export const useCatalogTests = () =>
export const usePipelineMappings = () => export const usePipelineMappings = () =>
useMock useMock
? asMock([ ? asMock([
["primary", "secondary1", "tertiary1"], [
["primary", "secondary1", "tertiary2"], { name: "primary", delay: 0 },
["primary", "secondary2", "tertiary3"], { name: "secondary1", delay: 1000 },
{ name: "tertiary1", delay: 0 },
],
[
{ name: "primary", delay: 0 },
{ name: "secondary1", delay: 1000 },
{ name: "tertiary2", delay: 8000 },
],
[
{ name: "primary", delay: 0 },
{ name: "secondary2", delay: 20000 },
{ name: "tertiary3", delay: 3000 },
],
]) ])
: useQuery(["pipelineMappings"], fetchApi("/catalog/pipeline-mappings")); : useQuery(["pipelineMappings"], fetchApi("/catalog/pipeline-mappings"));

View file

@ -53,7 +53,13 @@ export default function CatalogBox(props) {
}; };
const runPipelineTest = () => { const runPipelineTest = () => {
const primaries = pipelineMappings.filter((m) => m.includes(testName)); if (isLoading) {
console.log("Pipeline mappings are loading, retrying in 5 seconds");
setTimeout(runPipelineTest, 5000);
}
const primaries = pipelineMappings.filter((m) =>
m.find((t) => t.name === testName)
);
const builderCache = { const builderCache = {
branches: asBranches(primaries), branches: asBranches(primaries),
tree: asTree(primaries), tree: asTree(primaries),

View file

@ -83,7 +83,9 @@ export default function FailingBox(props) {
} }
const retryPipelineTest = () => { const retryPipelineTest = () => {
const primaries = pipelineMappings.filter((m) => m.includes(testName)); const primaries = pipelineMappings.filter((m) =>
m.find((t) => t.name === testName)
);
const builderCache = { const builderCache = {
branches: asBranches(primaries), branches: asBranches(primaries),
tree: asTree(primaries), tree: asTree(primaries),

View file

@ -122,7 +122,7 @@ function JobPipelineDisplay(props) {
disableGutters={true} disableGutters={true}
square square
key={j} key={j}
onClick={selectJob(test)} onClick={selectJob(test.name)}
> >
<AccordionSummary <AccordionSummary
style={{ style={{
@ -134,11 +134,11 @@ function JobPipelineDisplay(props) {
component={"span"} component={"span"}
style={{ wordBreak: "break-word", margin: "auto 0" }} style={{ wordBreak: "break-word", margin: "auto 0" }}
> >
{test} {test.name}
</Typography> </Typography>
<Stack sx={{ ml: "auto" }}> <Stack sx={{ ml: "auto" }}>
<IconButton aria-label="retry" component="span"> <IconButton aria-label="retry" component="span">
{jobIcon(test)} {jobIcon(test.name)}
</IconButton> </IconButton>
</Stack> </Stack>
</AccordionSummary> </AccordionSummary>

View file

@ -35,7 +35,7 @@ export default function Jobs() {
justifyContent="center" justifyContent="center"
sx={{ flexFlow: "wrap" }} sx={{ flexFlow: "wrap" }}
> >
<Typography variant="h4">No jobs found! </Typography>{" "} <Typography variant="h4">No jobs found!</Typography>
</Box> </Box>
<Box <Box
display="flex" display="flex"
@ -49,7 +49,9 @@ export default function Jobs() {
</Box> </Box>
</React.Fragment> </React.Fragment>
) : null} ) : null}
<JobBuilder /> <JobBuilder />
{location.hash === "" && ( {location.hash === "" && (
<React.Fragment> <React.Fragment>
{jobState.jobs {jobState.jobs

View file

@ -17,8 +17,8 @@ function PipelineSelector(props) {
if (isLoading) return {}; if (isLoading) return {};
const primaryMappings = {}; const primaryMappings = {};
for (var pm of pipelineMappings) { for (var pm of pipelineMappings) {
if (!(pm[0] in primaryMappings)) primaryMappings[pm[0]] = []; if (!(pm[0].name in primaryMappings)) primaryMappings[pm[0].name] = [];
primaryMappings[pm[0]].push(pm); primaryMappings[pm[0].name].push(pm);
} }
return primaryMappings; return primaryMappings;
}; };
@ -54,8 +54,10 @@ function PipelineSelector(props) {
component={"span"} component={"span"}
style={{ wordBreak: "break-word", margin: "auto 0" }} style={{ wordBreak: "break-word", margin: "auto 0" }}
color={ color={
(cache.primarySelectedMappings ?? [[]])[0][0] === k cache.primarySelectedMappings
? "primary" ? cache.primarySelectedMappings[0][0].name === k
? "primary"
: null
: null : null
} }
> >

View file

@ -27,7 +27,7 @@ function PipelineTrackSelector(props) {
const removeTrack = (test) => { const removeTrack = (test) => {
const { tracks } = cache; const { tracks } = cache;
for (var i in tracks) { for (var i in tracks) {
const index = tracks[i].indexOf(test); const index = tracks[i].findIndex((t) => t.name === test.name);
if (index === -1) continue; if (index === -1) continue;
tracks[i] = tracks[i].slice(0, index); tracks[i] = tracks[i].slice(0, index);
} }
@ -35,12 +35,13 @@ function PipelineTrackSelector(props) {
}; };
const selectTrack = (test) => () => { const selectTrack = (test) => () => {
if (as1d(cache.tracks).includes(test)) return removeTrack(test); if (as1d(cache.tracks).find((t) => t.name === test.name))
return removeTrack(test);
addTrack(test); addTrack(test);
}; };
const getColor = (test) => const getColor = (test) =>
as1d(cache.tracks).includes(test) ? "primary" : null; as1d(cache.tracks).find((t) => t.name === test.name) ? "primary" : null;
const nextClick = () => { const nextClick = () => {
setCache({ setCache({
@ -79,7 +80,7 @@ function PipelineTrackSelector(props) {
style={{ wordBreak: "break-word", margin: "auto 0" }} style={{ wordBreak: "break-word", margin: "auto 0" }}
color={getColor(test)} color={getColor(test)}
> >
{test} {test.name}
</Typography> </Typography>
<Stack sx={{ ml: "auto" }}>I</Stack> <Stack sx={{ ml: "auto" }}>I</Stack>
</AccordionSummary> </AccordionSummary>