Skip to content

Commit

Permalink
fix: run code fmt
Browse files Browse the repository at this point in the history
Signed-off-by: Rui Chen <rui@chenrui.dev>
  • Loading branch information
chenrui333 committed Jun 19, 2024
1 parent e78ff5c commit f635b38
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
10 changes: 5 additions & 5 deletions __tests__/input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("input", () => {
abortAfterSeconds: undefined,
pollIntervalSeconds: 5,
sameBranchOnly: false,
}
},
);
});

Expand All @@ -53,7 +53,7 @@ describe("input", () => {
abortAfterSeconds: 10,
pollIntervalSeconds: 5,
sameBranchOnly: false,
}
},
);
});

Expand All @@ -67,7 +67,7 @@ describe("input", () => {
GITHUB_RUN_ID: "1",
"INPUT_CONTINUE-AFTER-SECONDS": "10",
"INPUT_ABORT-AFTER-SECONDS": "2",
})
}),
);
});

Expand All @@ -94,7 +94,7 @@ describe("input", () => {
abortAfterSeconds: undefined,
pollIntervalSeconds: 60,
sameBranchOnly: true,
}
},
);
});

Expand All @@ -119,7 +119,7 @@ describe("input", () => {
abortAfterSeconds: undefined,
pollIntervalSeconds: 60,
sameBranchOnly: true,
}
},
);
});
});
Expand Down
16 changes: 8 additions & 8 deletions __tests__/wait.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("wait", () => {
owner: string,
repo: string,
branch: string | undefined,
workflowId: number
workflowId: number,
) => Promise.resolve([inProgressRun]),
workflows: async (owner: string, repo: string) =>
Promise.resolve([workflow]),
Expand All @@ -54,7 +54,7 @@ describe("wait", () => {
(message: string) => {
messages.push(message);
},
() => {}
() => {},
);
assert.equal(await waiter.wait(), 1);
assert.deepEqual(messages, [
Expand All @@ -75,7 +75,7 @@ describe("wait", () => {
owner: string,
repo: string,
branch: string | undefined,
workflowId: number
workflowId: number,
) => Promise.resolve([inProgressRun]),
workflows: async (owner: string, repo: string) =>
Promise.resolve([workflow]),
Expand All @@ -90,7 +90,7 @@ describe("wait", () => {
(message: string) => {
messages.push(message);
},
() => {}
() => {},
);
await assert.rejects(waiter.wait(), {
name: "Error",
Expand Down Expand Up @@ -128,7 +128,7 @@ describe("wait", () => {
(message: string) => {
messages.push(message);
},
() => {}
() => {},
);
await waiter.wait();
assert.deepEqual(messages, ["✋Awaiting run 1 ..."]);
Expand Down Expand Up @@ -169,7 +169,7 @@ describe("wait", () => {
.mockReturnValueOnce(Promise.resolve(inProgressRuns))
// Finally return just the run that was queued _after_ the "input" run.
.mockReturnValue(
Promise.resolve(inProgressRuns.slice(inProgressRuns.length - 1))
Promise.resolve(inProgressRuns.slice(inProgressRuns.length - 1)),
);

const githubClient = {
Expand All @@ -188,15 +188,15 @@ describe("wait", () => {
(message: string) => {
messages.push(message);
},
() => {}
() => {},
);
await waiter.wait();
// Verify that the last message printed is that the latest previous run
// is complete and not the oldest one.
const latestPreviousRun = inProgressRuns[inProgressRuns.length - 1];
assert.deepEqual(
messages[messages.length - 1],
`✋Awaiting run ${input.runId - 1} ...`
`✋Awaiting run ${input.runId - 1} ...`,
);
});
});
Expand Down
6 changes: 3 additions & 3 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class OctokitGitHub {
throttle: {
onRateLimit: (retryAfter, options) => {
warning(
`Request quota exhausted for request ${options.method} ${options.url}`
`Request quota exhausted for request ${options.method} ${options.url}`,
);

if (options.request.retryCount === 0) {
Expand All @@ -38,7 +38,7 @@ export class OctokitGitHub {
owner: string,
repo: string,
branch: string | undefined,
workflow_id: number
workflow_id: number,
) => {
const options: Endpoints["GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs"]["parameters"] =
{
Expand All @@ -54,7 +54,7 @@ export class OctokitGitHub {

return this.octokit.paginate(
this.octokit.actions.listWorkflowRuns,
options
options,
);
};
}
2 changes: 1 addition & 1 deletion src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const parseInput = (env: Record<string, string | undefined>): Input => {
: undefined;
if (continueAfterSeconds !== undefined && abortAfterSeconds !== undefined) {
throw new Error(
"Only one of continue-after-seconds and abort-after-seconds may be defined"
"Only one of continue-after-seconds and abort-after-seconds may be defined",
);
}
const sameBranchOnly =
Expand Down
8 changes: 4 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ async function run() {
const input = parseInput(env);
debug(
`Parsed inputs (w/o token): ${(({ githubToken, ...inputs }) => inputs)(
input
)}`
input,
)}`,
);
const github = new OctokitGitHub(input.githubToken);
debug(`Fetching workflows for ${input.owner}/${input.repo}...`);
const workflows = await github.workflows(input.owner, input.repo);
debug(
`Found ${workflows.length} workflows in ${input.owner}/${input.repo}`
`Found ${workflows.length} workflows in ${input.owner}/${input.repo}`,
);
const workflow_id = workflows.find(
(workflow) => workflow.name == input.workflowName
(workflow) => workflow.name == input.workflowName,
)?.id;
if (workflow_id) {
await new Waiter(workflow_id, github, input, info, debug).wait();
Expand Down
6 changes: 3 additions & 3 deletions src/wait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class Waiter implements Wait {
githubClient: GitHub,
input: Input,
info: (msg: string) => void,
debug: (msg: string) => void
debug: (msg: string) => void,
) {
this.workflowId = workflowId;
this.input = input;
Expand Down Expand Up @@ -51,7 +51,7 @@ export class Waiter implements Wait {
this.input.owner,
this.input.repo,
this.input.sameBranchOnly ? this.input.branch : undefined,
this.workflowId
this.workflowId,
);

this.debug(`Found ${runs.length} ${this.workflowId} runs`);
Expand All @@ -68,7 +68,7 @@ export class Waiter implements Wait {
const previousRun = previousRuns[0];
this.info(`✋Awaiting run ${previousRun.html_url} ...`);
await new Promise((resolve) =>
setTimeout(resolve, this.input.pollIntervalSeconds * 1000)
setTimeout(resolve, this.input.pollIntervalSeconds * 1000),
);
return this.wait((secondsSoFar || 0) + this.input.pollIntervalSeconds);
};
Expand Down

0 comments on commit f635b38

Please sign in to comment.