Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/src/summarize-checks/summarize-checks.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// @ts-check

/*
Expand Down Expand Up @@ -592,6 +592,26 @@
* @returns {Promise<any>} Complete GraphQL response with all check suites
*/
async function getAllCheckSuites(github, core, owner, repo, sha, prNumber) {
// First, get the total count using REST API to avoid expensive GraphQL if there are too many suites
const { data: checkSuitesResponse } = await github.rest.checks.listSuitesForRef({
owner,
repo,
ref: sha,
per_page: 1, // We only need the count, not the actual data
});

const totalCheckSuites = checkSuitesResponse.total_count;

// Bail if too many check suites to avoid burning GraphQL rate limits
if (totalCheckSuites > 500) {
throw new Error(
`Too many check suites (${totalCheckSuites}) for ${owner}/${repo}#${prNumber}@${sha}. Summarize-Checks ending with error to avoid exhausting graphQL resources.`,
);
} else {
core.info(`Found ${totalCheckSuites} total check suites`);
}

// Now proceed with GraphQL pagination
const resourceUrl = `https://github.com/${owner}/${repo}/commit/${sha}`;
let allCheckSuites = [];
let hasNextPage = true;
Expand Down
Loading