Skip to content

Commit

Permalink
split dispatch and find workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tpikachu committed Feb 27, 2024
1 parent 63ca1b3 commit a6aff03
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 4 deletions.
39 changes: 37 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38848,8 +38848,10 @@ const waitFor = (ms) => new Promise((r) => setTimeout(r, ms));

console.log("inputs", { repo, branch, prompt });

console.log('TestDriver: "Dispatching testdriver..."'.green);

const {
data: { workflowId },
data: { dispatchId },
} = await axios.post(
`${baseUrl}/testdriver-dispatch`,
{
Expand All @@ -38863,7 +38865,40 @@ const waitFor = (ms) => new Promise((r) => setTimeout(r, ms));
}
);

console.log("workflow id:", workflowId);
console.log("dispatch id:", dispatchId);

console.log('TestDriver: "Finding the dispatched workflow..."'.green);

const checkWorkflow = async () => {
const {
data: { workflowId },
} = await axios.post(
`${baseUrl}/testdriver-workflow`,
{
dispatchId,
},
{
Accept: "application/json",
"Content-Type": "application/json",
}
);

return workflowId;
};

const waitUntilWorkflowAvailable = async () => {
let workflowId;
while (!workflowId) {
await waitFor(1000 * 60);
workflowId = await checkWorkflow();
}

return workflowId;
};

const workflowId = await waitUntilWorkflowAvailable();

console.log("Found workflow id:", workflowId);

const checkStatus = async () => {
const {
Expand Down
39 changes: 37 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ const waitFor = (ms) => new Promise((r) => setTimeout(r, ms));

console.log("inputs", { repo, branch, prompt });

console.log('TestDriver: "Dispatching testdriver..."'.green);

const {
data: { workflowId },
data: { dispatchId },
} = await axios.post(
`${baseUrl}/testdriver-dispatch`,
{
Expand All @@ -51,7 +53,40 @@ const waitFor = (ms) => new Promise((r) => setTimeout(r, ms));
}
);

console.log("workflow id:", workflowId);
console.log("dispatch id:", dispatchId);

console.log('TestDriver: "Finding the dispatched workflow..."'.green);

const checkWorkflow = async () => {
const {
data: { workflowId },
} = await axios.post(
`${baseUrl}/testdriver-workflow`,
{
dispatchId,
},
{
Accept: "application/json",
"Content-Type": "application/json",
}
);

return workflowId;
};

const waitUntilWorkflowAvailable = async () => {
let workflowId;
while (!workflowId) {
await waitFor(1000 * 60);
workflowId = await checkWorkflow();
}

return workflowId;
};

const workflowId = await waitUntilWorkflowAvailable();

console.log("Found workflow id:", workflowId);

const checkStatus = async () => {
const {
Expand Down

0 comments on commit a6aff03

Please sign in to comment.