From 77ddea493d67589fad1d3f21f75d8a332f029b60 Mon Sep 17 00:00:00 2001 From: Cameron Dunn Date: Wed, 27 Dec 2023 16:54:32 -0800 Subject: [PATCH] Build/etc --- __tests__/poll.test.ts | 3 ++- dist/index.js | 12 ++++++++++-- src/main.ts | 9 +++++++-- src/poll.ts | 4 +++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/__tests__/poll.test.ts b/__tests__/poll.test.ts index f5f6dff..5da980f 100644 --- a/__tests__/poll.test.ts +++ b/__tests__/poll.test.ts @@ -17,7 +17,8 @@ const run = () => repo: 'testRepo', ref: 'abcd', timeoutSeconds: 3, - intervalSeconds: 0.1 + intervalSeconds: 0.1, + ignoreIDs: [] }) test('returns conclusion of completed check', async () => { diff --git a/dist/index.js b/dist/index.js index e39a76c..388b4ca 100644 --- a/dist/index.js +++ b/dist/index.js @@ -42,6 +42,11 @@ function run() { return __awaiter(this, void 0, void 0, function* () { try { const token = core.getInput('token', { required: true }); + core.info(`ignoreIDs: ${core.getInput('ignoreIDs')}`); + const ignoreIDs = (core.getInput('ignoreIDs') || '') + .split(',') + .map(s => s.trim()); + core.info(`parsed ignoreIDs: ${ignoreIDs}`); const result = yield (0, poll_1.poll)({ client: (0, github_1.getOctokit)(token), log: msg => core.info(msg), @@ -49,6 +54,7 @@ function run() { owner: core.getInput('owner') || github_1.context.repo.owner, repo: core.getInput('repo') || github_1.context.repo.repo, ref: core.getInput('ref') || github_1.context.sha, + ignoreIDs, timeoutSeconds: parseInt(core.getInput('timeoutSeconds') || '600'), intervalSeconds: parseInt(core.getInput('intervalSeconds') || '10') }); @@ -82,7 +88,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.poll = void 0; const wait_1 = __nccwpck_require__(5817); const poll = (options) => __awaiter(void 0, void 0, void 0, function* () { - const { client, log, checkName, timeoutSeconds, intervalSeconds, owner, repo, ref } = options; + const { client, log, checkName, timeoutSeconds, intervalSeconds, owner, repo, ref, ignoreIDs } = options; let now = new Date().getTime(); const deadline = now + timeoutSeconds * 1000; while (now <= deadline) { @@ -94,7 +100,9 @@ const poll = (options) => __awaiter(void 0, void 0, void 0, function* () { ref }); log(`Retrieved ${result.data.check_runs.length} check runs named ${checkName}`); - const completedCheck = result.data.check_runs.find(checkRun => checkRun.status === 'completed'); + let checkRuns = result.data.check_runs; + checkRuns = checkRuns.filter(checkRun => !ignoreIDs.includes(`${checkRun.id}`)); + const completedCheck = checkRuns.find(checkRun => checkRun.status === 'completed'); if (completedCheck) { log(`Found a completed check with id ${completedCheck.id} and conclusion ${completedCheck.conclusion}`); // conclusion is only `null` if status is not `completed`. diff --git a/src/main.ts b/src/main.ts index 5b836f1..6ce52b4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,12 @@ async function run(): Promise { try { const token = core.getInput('token', {required: true}) - core.info("ignoreIDs: '" + core.getInput('ignoreIDs') + "'") + core.info(`ignoreIDs: ${core.getInput('ignoreIDs')}`) + const ignoreIDs = (core.getInput('ignoreIDs') || '') + .split(',') + .map(s => s.trim()) + core.info(`parsed ignoreIDs: ${ignoreIDs}`) + const result = await poll({ client: getOctokit(token), log: msg => core.info(msg), @@ -15,7 +20,7 @@ async function run(): Promise { owner: core.getInput('owner') || context.repo.owner, repo: core.getInput('repo') || context.repo.repo, ref: core.getInput('ref') || context.sha, - ignoreIDs: (core.getInput('ignoreIDs') || "").split(",").map((s) => s.trim()), + ignoreIDs, timeoutSeconds: parseInt(core.getInput('timeoutSeconds') || '600'), intervalSeconds: parseInt(core.getInput('intervalSeconds') || '10') diff --git a/src/poll.ts b/src/poll.ts index 436a32b..8ec0d53 100644 --- a/src/poll.ts +++ b/src/poll.ts @@ -46,7 +46,9 @@ export const poll = async (options: Options): Promise => { ) let checkRuns = result.data.check_runs - checkRuns = checkRuns.filter((checkRun) => !ignoreIDs.includes(checkRun.id)) + checkRuns = checkRuns.filter( + checkRun => !ignoreIDs.includes(`${checkRun.id}`) + ) const completedCheck = checkRuns.find( checkRun => checkRun.status === 'completed'