Skip to content

Commit

Permalink
Introduced checks-watch-interval input (#589)
Browse files Browse the repository at this point in the history
  • Loading branch information
CatChen authored Aug 28, 2022
1 parent d6a9250 commit d609ecc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ inputs:
required: false
default: "merge"
timeout:
description: "The time allowance for waiting the checks to pass in seconds."
description: "The time allowance in seconds for waiting the checks to pass."
required: false
default: 600
checks-watch-interval:
description: "Refresh interval in seconds when using waiting for checks."
required: false
default: 10
runs:
using: "node16"
main: "dist/index.js"
Expand Down
8 changes: 4 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const SUCCESS = "success";
const NEUTRAL = "neutral";
const SKIPPED = "skipped";

const SLEEP_INTERVAL = 10 * 1000; // 10 seconds

const LOCALE = Intl.NumberFormat().resolvedOptions().locale;
const FORMATTER = new Intl.NumberFormat(LOCALE, {
style: "unit",
Expand Down Expand Up @@ -158,6 +156,7 @@ async function run(): Promise<void> {

const job = context.job;
const timeout = parseInt(getInput("timeout"), 10);
const interval = parseInt(getInput("checks-watch-interval"), 10);
info(`Current job: ${job}`);
let checksCompleted = false;
while (!checksCompleted) {
Expand Down Expand Up @@ -198,13 +197,13 @@ async function run(): Promise<void> {
const executionTime = Math.round(performance.now() / 1000);
if (executionTime <= timeout) {
info(`Execution time: ${FORMATTER.format(executionTime)}`);
info(`Sleeping: ${SLEEP_INTERVAL}`);
await sleep(SLEEP_INTERVAL);
info(`Sleeping: ${FORMATTER.format(interval)}`);
await sleep(interval * 1000);
} else {
error(`Execution time: ${FORMATTER.format(executionTime)}`);
setFailed(
`Timeout: ${FORMATTER.format(executionTime)} > ${FORMATTER.format(
SLEEP_INTERVAL / 1000
timeout
)}`
);
return;
Expand Down

0 comments on commit d609ecc

Please sign in to comment.