@@ -29928,6 +29928,16 @@ function wrappy (fn, cb) {
2992829928const core = __nccwpck_require__(7484);
2992929929const github = __nccwpck_require__(3228);
2993029930
29931+ const CONCLUSION_STATES = {
29932+ SUCCESS: 'success',
29933+ FAILURE: 'failure',
29934+ MIXED: 'mixed',
29935+ ACTION_REQUIRED: 'action_required',
29936+ TIMED_OUT: 'timed_out',
29937+ CANCELLED: 'cancelled',
29938+ COMPLETED: 'completed'
29939+ };
29940+
2993129941/**
2993229942 * Wait for multiple checks to complete
2993329943 * @param {Object} octokit - GitHub API client
@@ -29950,23 +29960,22 @@ async function waitForChecks(octokit, owner, repo, ref, checkNames, waitInterval
2995029960 const checkResults = {};
2995129961 const pendingChecks = new Set(checkNames);
2995229962
29953- while ((Date.now() - startTime < timeoutMs) && ( pendingChecks.size > 0) ) {
29963+ while ((Date.now() - startTime < timeoutMs) && pendingChecks.size) {
2995429964 try {
2995529965 // Get all check runs for the specific commit
29956- const { data: checkRuns } = await octokit.rest.checks.listForRef( {
29966+ const allCheckRuns = await octokit.paginate(octokit. rest.checks.listForRef, {
2995729967 owner,
2995829968 repo,
2995929969 ref,
2996029970 per_page: 100
2996129971 });
2996229972
29963- core.info(`Found ${checkRuns.check_runs .length} total check runs`);
29973+ core.info(`Found ${allCheckRuns .length} total check runs`);
2996429974
2996529975 // Process each pending check
29966- for (const checkName of Array.from(pendingChecks)) {
29967- const matchingRuns = checkRuns.check_runs.filter(run => run.name === checkName);
29968-
29969- if (matchingRuns.length === 0) {
29976+ for (const checkName of pendingChecks) {
29977+ const matchingRuns = allCheckRuns.filter(run => run.name === checkName);
29978+ if (!matchingRuns.length) {
2997029979 core.info(`No check runs found for "${checkName}" yet, waiting...`);
2997129980 continue;
2997229981 }
@@ -29992,12 +30001,14 @@ async function waitForChecks(octokit, owner, repo, ref, checkNames, waitInterval
2999230001 core.info(`Check "${checkName}" is queued...`);
2999330002 }
2999430003 }
29995-
29996- if (pendingChecks.size === 0) {
30004+
30005+ if (pendingChecks.size) {
30006+ core.info(`Still waiting for [${Array.from(pendingChecks).join(', ')}]. Waiting ${waitInterval} seconds before next check...`);
30007+ await new Promise(resolve => setTimeout(resolve, waitIntervalMs));
30008+ } else {
2999730009 core.info('All checks completed, parsing conclusions...');
2999830010 break;
2999930011 }
30000-
3000130012 } catch (error) {
3000230013 core.warning(`Error fetching check runs: ${error.message}`);
3000330014
@@ -30009,14 +30020,9 @@ async function waitForChecks(octokit, owner, repo, ref, checkNames, waitInterval
3000930020 core.error(`API error: ${error.message}`);
3001030021 }
3001130022 }
30012-
30013- if (pendingChecks.size > 0) {
30014- core.info(`Still waiting for [${Array.from(pendingChecks).join(', ')}]. Waiting ${waitInterval} seconds before next check...`);
30015- await new Promise(resolve => setTimeout(resolve, waitIntervalMs));
30016- }
3001730023 }
3001830024
30019- if (pendingChecks.size > 0 ) {
30025+ if (pendingChecks.size) {
3002030026 const pendingChecksList = Array.from(pendingChecks).join(', ');
3002130027 throw new Error(`Timeout: Checks [${pendingChecksList}] did not complete within ${timeout} seconds`);
3002230028 }
@@ -30071,37 +30077,37 @@ async function run() {
3007130077
3007230078 // Determine overall conclusion
3007330079 let overallConclusion;
30074- if (allConclusions.every(c => c === 'success' )) {
30075- overallConclusion = 'success' ;
30076- } else if (allConclusions.some(c => ['failure', 'cancelled', 'timed_out' ].includes(c))) {
30077- overallConclusion = 'failure' ;
30078- } else if (allConclusions.some(c => c === 'action_required' )) {
30079- overallConclusion = 'action_required' ;
30080+ if (allConclusions.every(c => c === CONCLUSION_STATES.SUCCESS )) {
30081+ overallConclusion = CONCLUSION_STATES.SUCCESS ;
30082+ } else if (allConclusions.some(c => [CONCLUSION_STATES.FAILURE, CONCLUSION_STATES.CANCELLED, CONCLUSION_STATES.TIMED_OUT ].includes(c))) {
30083+ overallConclusion = CONCLUSION_STATES.FAILURE ;
30084+ } else if (allConclusions.some(c => c === CONCLUSION_STATES.ACTION_REQUIRED )) {
30085+ overallConclusion = CONCLUSION_STATES.ACTION_REQUIRED ;
3008030086 } else {
30081- overallConclusion = 'mixed' ;
30087+ overallConclusion = CONCLUSION_STATES.MIXED ;
3008230088 }
3008330089
3008430090 // Set outputs
30085- core.setOutput('status', allStatuses.every(s => s === 'completed' ) ? 'completed' : 'mixed' );
30091+ core.setOutput('status', allStatuses.every(s => s === CONCLUSION_STATES.COMPLETED ) ? CONCLUSION_STATES.COMPLETED : CONCLUSION_STATES.MIXED );
3008630092 core.setOutput('conclusion', overallConclusion);
3008730093 core.setOutput('results', JSON.stringify(results));
3008830094
3008930095 // Log results
3009030096 for (const [checkName, result] of Object.entries(results)) {
30091- core.info(`${checkName}: ${result.status} ( ${result.conclusion}) `);
30097+ core.info(`${checkName}: Status is " ${result.status}", Conclusion is " ${result.conclusion}" `);
3009230098 }
3009330099
3009430100 // Exit with appropriate code based on overall conclusion
30095- if (overallConclusion === 'success' ) {
30101+ if (overallConclusion === CONCLUSION_STATES.SUCCESS ) {
3009630102 core.info('All checks completed with successful conclusions');
30097- } else if (overallConclusion === 'failure' ) {
30103+ } else if (overallConclusion === CONCLUSION_STATES.FAILURE ) {
3009830104 const failedChecks = Object.entries(results)
30099- .filter(([_, result]) => ['failure', 'cancelled', 'timed_out' ].includes(result.conclusion))
30105+ .filter(([_, result]) => [CONCLUSION_STATES.FAILURE, CONCLUSION_STATES.CANCELLED, CONCLUSION_STATES.TIMED_OUT ].includes(result.conclusion))
3010030106 .map(([name, _]) => name);
3010130107 core.setFailed(`Some checks failed: [${failedChecks.join(', ')}]`);
30102- } else if (overallConclusion === 'action_required' ) {
30108+ } else if (overallConclusion === CONCLUSION_STATES.ACTION_REQUIRED ) {
3010330109 const actionRequiredChecks = Object.entries(results)
30104- .filter(([_, result]) => result.conclusion === 'action_required' )
30110+ .filter(([_, result]) => result.conclusion === CONCLUSION_STATES.ACTION_REQUIRED )
3010530111 .map(([name, _]) => name);
3010630112 core.setFailed(`Some checks require action: [${actionRequiredChecks.join(', ')}]`);
3010730113 } else {
0 commit comments