From 3e89f06714cf084a09c0296643f95eb13d9bcd21 Mon Sep 17 00:00:00 2001 From: Alex Ross <38270282+alexr00@users.noreply.github.com> Date: Wed, 11 Mar 2026 13:37:38 +0100 Subject: [PATCH] Re-enable API proposal version check (#300716) * Revert "Merge pull request #300495 from mjbvz/dev/mjbvz/fierce-hawk" This reverts commit 2eefd9e554fe847a8041aa79598a10020ef58817, reversing changes made to 34bfd71aeac1598fe87bbd37163f345ca49dffaa. * Add lots of logging * Update .github/workflows/api-proposal-version-check.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../workflows/api-proposal-version-check.yml | 64 +++++++++++++------ 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/.github/workflows/api-proposal-version-check.yml b/.github/workflows/api-proposal-version-check.yml index 23f6e052f9f..80b14950656 100644 --- a/.github/workflows/api-proposal-version-check.yml +++ b/.github/workflows/api-proposal-version-check.yml @@ -23,11 +23,14 @@ jobs: check-version-changes: name: Check API Proposal Version Changes # Run on PR events, or on issue_comment if it's on a PR and contains the override command - if: false # temporarily disabled - # github.event_name == 'pull_request' || - # (github.event_name == 'issue_comment' && - # github.event.issue.pull_request && - # contains(github.event.comment.body, '/api-proposal-change-required')) + if: | + github.event_name == 'pull_request' || + (github.event_name == 'issue_comment' && + github.event.issue.pull_request && + contains(github.event.comment.body, '/api-proposal-change-required') && + (github.event.comment.author_association == 'OWNER' || + github.event.comment.author_association == 'MEMBER' || + github.event.comment.author_association == 'COLLABORATOR')) runs-on: ubuntu-latest steps: - name: Get PR info @@ -71,25 +74,50 @@ jobs: // Only accept overrides from trusted users (repo members/collaborators) const trustedAssociations = ['OWNER', 'MEMBER', 'COLLABORATOR']; - const overrideComment = comments.find(comment => - comment.body.includes('/api-proposal-change-required') && - trustedAssociations.includes(comment.author_association) - ); + let overrideComment = null; + const untrustedOverrides = []; + + comments.forEach((comment, index) => { + const hasOverrideText = comment.body.includes('/api-proposal-change-required'); + const isTrusted = trustedAssociations.includes(comment.author_association); + console.log(`Comment ${index + 1}:`); + console.log(` Author: ${comment.user.login}`); + console.log(` Author association: ${comment.author_association}`); + console.log(` Created at: ${comment.created_at}`); + console.log(` Contains override command: ${hasOverrideText}`); + console.log(` Author is trusted: ${isTrusted}`); + console.log(` Would be valid override: ${hasOverrideText && isTrusted}`); + + if (hasOverrideText) { + if (isTrusted && !overrideComment) { + overrideComment = comment; + } else if (!isTrusted) { + untrustedOverrides.push(comment); + } + } + }); if (overrideComment) { - console.log(`Override comment found by ${overrideComment.user.login} (${overrideComment.author_association})`); + console.log(`✅ Override comment FOUND`); + console.log(` Comment ID: ${overrideComment.id}`); + console.log(` Author: ${overrideComment.user.login}`); + console.log(` Association: ${overrideComment.author_association}`); + console.log(` Created at: ${overrideComment.created_at}`); core.setOutput('override_found', 'true'); core.setOutput('override_user', overrideComment.user.login); } else { - // Check if there's an override from an untrusted user - const untrustedOverride = comments.find(comment => - comment.body.includes('/api-proposal-change-required') && - !trustedAssociations.includes(comment.author_association) - ); - if (untrustedOverride) { - console.log(`Override comment by ${untrustedOverride.user.login} ignored (${untrustedOverride.author_association} is not trusted)`); + if (untrustedOverrides.length > 0) { + console.log(`⚠️ Found ${untrustedOverrides.length} override comment(s) from UNTRUSTED user(s):`); + untrustedOverrides.forEach((comment, index) => { + console.log(` Untrusted override ${index + 1}:`); + console.log(` Author: ${comment.user.login}`); + console.log(` Association: ${comment.author_association}`); + console.log(` Created at: ${comment.created_at}`); + console.log(` Comment ID: ${comment.id}`); + }); + console.log(` Trusted associations are: ${trustedAssociations.join(', ')}`); } - console.log('No valid override comment found'); + console.log('❌ No valid override comment found'); core.setOutput('override_found', 'false'); }