From 342ff5baddbccd12d605547e718cec7508a50280 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 26 Sep 2024 11:21:47 +0200 Subject: [PATCH] fix(git-node): ignore all non-gha nodes when checking for GitHub CI (#857) --- lib/pr_checker.js | 8 ++++---- test/fixtures/github-ci/both-apis-failure.json | 1 + test/fixtures/github-ci/both-apis-success.json | 1 + test/fixtures/github-ci/check-suite-failure.json | 1 + test/fixtures/github-ci/check-suite-pending.json | 1 + test/fixtures/github-ci/check-suite-skipped.json | 1 + test/fixtures/github-ci/check-suite-success.json | 1 + .../github-ci/status-failure-check-suite-succeed.json | 1 + .../github-ci/status-succeed-check-suite-failure.json | 1 + test/fixtures/github-ci/success-dependabot-queued.json | 1 + 10 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/pr_checker.js b/lib/pr_checker.js index b37314e46..754a89c29 100644 --- a/lib/pr_checker.js +++ b/lib/pr_checker.js @@ -29,7 +29,6 @@ const GITHUB_SUCCESS_CONCLUSIONS = ['SUCCESS', 'NEUTRAL', 'SKIPPED']; const FAST_TRACK_RE = /^Fast-track has been requested by @(.+?)\. Please 👍 to approve\.$/; const FAST_TRACK_MIN_APPROVALS = 2; const GIT_CONFIG_GUIDE_URL = 'https://github.com/nodejs/node/blob/99b1ada/doc/guides/contributing/pull-requests.md#step-1-fork'; -const IGNORED_CHECK_SLUGS = ['dependabot', 'codecov']; // eslint-disable-next-line no-extend-native Array.prototype.findLastIndex ??= function findLastIndex(fn) { @@ -374,9 +373,10 @@ export default class PRChecker { // GitHub new Check API for (const { status, conclusion, app } of checkSuites.nodes) { - if (app && IGNORED_CHECK_SLUGS.includes(app.slug)) { - // Ignore Dependabot and Codecov check suites. - // They are expected to show up sometimes and never complete. + if (app.slug !== 'github-actions') { + // Ignore all non-github check suites, such as Dependabot and Codecov. + // They are expected to show up on PRs whose head branch is not on a + // fork and never complete. continue; } diff --git a/test/fixtures/github-ci/both-apis-failure.json b/test/fixtures/github-ci/both-apis-failure.json index 3866f56d6..aa552ccec 100644 --- a/test/fixtures/github-ci/both-apis-failure.json +++ b/test/fixtures/github-ci/both-apis-failure.json @@ -13,6 +13,7 @@ "checkSuites": { "nodes": [ { + "app": { "slug": "github-actions" }, "status": "COMPLETED", "conclusion": "FAILURE" } diff --git a/test/fixtures/github-ci/both-apis-success.json b/test/fixtures/github-ci/both-apis-success.json index 86fb337c2..c58e7abc7 100644 --- a/test/fixtures/github-ci/both-apis-success.json +++ b/test/fixtures/github-ci/both-apis-success.json @@ -13,6 +13,7 @@ "checkSuites": { "nodes": [ { + "app": { "slug": "github-actions" }, "status": "COMPLETED", "conclusion": "SUCCESS" } diff --git a/test/fixtures/github-ci/check-suite-failure.json b/test/fixtures/github-ci/check-suite-failure.json index 9f34c1108..b299e1e7d 100644 --- a/test/fixtures/github-ci/check-suite-failure.json +++ b/test/fixtures/github-ci/check-suite-failure.json @@ -10,6 +10,7 @@ "checkSuites": { "nodes": [ { + "app": { "slug": "github-actions" }, "status": "COMPLETED", "conclusion": "FAILURE" } diff --git a/test/fixtures/github-ci/check-suite-pending.json b/test/fixtures/github-ci/check-suite-pending.json index de284a9a6..c09d11bf0 100644 --- a/test/fixtures/github-ci/check-suite-pending.json +++ b/test/fixtures/github-ci/check-suite-pending.json @@ -10,6 +10,7 @@ "checkSuites": { "nodes": [ { + "app": { "slug": "github-actions" }, "status": "IN_PROGRESS" } ] diff --git a/test/fixtures/github-ci/check-suite-skipped.json b/test/fixtures/github-ci/check-suite-skipped.json index 420125260..6a2cb7553 100644 --- a/test/fixtures/github-ci/check-suite-skipped.json +++ b/test/fixtures/github-ci/check-suite-skipped.json @@ -10,6 +10,7 @@ "checkSuites": { "nodes": [ { + "app": { "slug": "github-actions" }, "status": "COMPLETED", "conclusion": "SKIPPED" } diff --git a/test/fixtures/github-ci/check-suite-success.json b/test/fixtures/github-ci/check-suite-success.json index ed7f3d6b8..1dc5f3951 100644 --- a/test/fixtures/github-ci/check-suite-success.json +++ b/test/fixtures/github-ci/check-suite-success.json @@ -10,6 +10,7 @@ "checkSuites": { "nodes": [ { + "app": { "slug": "github-actions" }, "status": "COMPLETED", "conclusion": "SUCCESS" } diff --git a/test/fixtures/github-ci/status-failure-check-suite-succeed.json b/test/fixtures/github-ci/status-failure-check-suite-succeed.json index 98b03e690..28faa58c8 100644 --- a/test/fixtures/github-ci/status-failure-check-suite-succeed.json +++ b/test/fixtures/github-ci/status-failure-check-suite-succeed.json @@ -13,6 +13,7 @@ "checkSuites": { "nodes": [ { + "app": { "slug": "github-actions" }, "status": "COMPLETED", "conclusion": "SUCCESS" } diff --git a/test/fixtures/github-ci/status-succeed-check-suite-failure.json b/test/fixtures/github-ci/status-succeed-check-suite-failure.json index cef60ce6b..6a336cd89 100644 --- a/test/fixtures/github-ci/status-succeed-check-suite-failure.json +++ b/test/fixtures/github-ci/status-succeed-check-suite-failure.json @@ -13,6 +13,7 @@ "checkSuites": { "nodes": [ { + "app": { "slug": "github-actions" }, "status": "COMPLETED", "conclusion": "FAILURE" } diff --git a/test/fixtures/github-ci/success-dependabot-queued.json b/test/fixtures/github-ci/success-dependabot-queued.json index a798e9f90..557452f5e 100644 --- a/test/fixtures/github-ci/success-dependabot-queued.json +++ b/test/fixtures/github-ci/success-dependabot-queued.json @@ -17,6 +17,7 @@ "conclusion": null }, { + "app": { "slug": "github-actions" }, "status": "COMPLETED", "conclusion": "SUCCESS" }