-
-
Notifications
You must be signed in to change notification settings - Fork 45
Fix rejection handling of submissions #10127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
seanbudd
wants to merge
9
commits into
master
Choose a base branch
from
fixRejection
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+44
−29
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0bb3094
Fix rejection handling
seanbudd 48b934d
temp revert trust submitter
seanbudd 7c3aaef
fix checkout
seanbudd b1d95bc
add checkout
seanbudd 74bc563
improve docs
seanbudd 27a0a09
fix slop
seanbudd 7abbb8e
close issue first
seanbudd a1e5837
fix delete
seanbudd 7c1d157
Apply suggestion from @seanbudd
seanbudd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -201,16 +201,17 @@ jobs: | |
| vtResultsJSON: ${{ steps.setVirusTotalAnalysisStatus.outputs.vtResults }} | ||
| vtKeySet: ${{ env.VT_API_KEY != '' }} | ||
| steps: | ||
| # checkout of repo needed for posting comments to issues | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ env.branchName }} | ||
| - name: Check if VT_API_KEY is set | ||
| id: checkVTKey | ||
| if: ${{ !env.VT_API_KEY }} | ||
| run: | | ||
| echo "VT_API_KEY secret is not set. Skipping VirusTotal analysis." | ||
| exit 1 | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ env.branchName }} | ||
| - name: Install Node.js | ||
| uses: actions/setup-node@v6 | ||
| - name: Install npm dependencies | ||
|
|
@@ -333,44 +334,53 @@ jobs: | |
| if: ${{ always() && (needs.requireSecurityManualApproval.result == 'failure' || needs.requireSubmitterManualApproval.result == 'failure') }} | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| actions: read | ||
| contents: write | ||
| issues: write | ||
| pull-requests: write | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ env.branchName }} | ||
| - name: Fetch Rejection Comment | ||
| uses: actions/github-script@v9 | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| id: fetchRejectionComment | ||
| with: | ||
| script: | | ||
| // Fetch the review history for the current workflow run | ||
| const response = await github.rest.actions.getApprovedProcessorReviewedHistoriesForWorkflowRun({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| run_id: context.runId | ||
| }); | ||
| run: | | ||
| approvalsJson="$(gh api \ | ||
| -H 'Accept: application/vnd.github+json' \ | ||
| "/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/approvals" \ | ||
| 2>/dev/null || echo '[]')" | ||
|
|
||
| rejectionReasons="$( | ||
| printf '%s' "$approvalsJson" | jq -r ' | ||
| [ .[]? | select(.state == "rejected") | "- " + (.comment // "No reason provided.") ] | ||
| | if length == 0 then "- No reason provided." else join("\n") end | ||
| ' | ||
| )" | ||
|
|
||
| // Filter out the rejection entry/entries. | ||
| const rejectionEvents = response.data.filter( | ||
| review => review.state === 'rejected' | ||
| ); | ||
| reviewers="$( | ||
| printf '%s' "$approvalsJson" | jq -r ' | ||
| [ .[]? | select(.state == "rejected") | .user.login ] | ||
| | unique | ||
| | if length == 0 then "Unknown reviewer" else join(", ") end | ||
| ' | ||
| )" | ||
|
|
||
| const rejectionReasons = []; | ||
| const reviewers = []; | ||
| for (const event of rejectionEvents) { | ||
| const reason = event.comment || "No reason provided."; | ||
| const reviewer = event.user.login; | ||
| rejectionReasons.push(`- ${reason}`); | ||
| reviewers.push(reviewer); | ||
| } | ||
| core.setOutput('rejectionReasons', rejectionReasons.join('\n')); | ||
| core.setOutput('reviewers', reviewers.join(', ')); | ||
| { | ||
| echo 'rejectionReasons<<EOF' | ||
| echo "$rejectionReasons" | ||
| echo 'EOF' | ||
| echo "reviewers=$reviewers" | ||
| } >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Post manual review failure comment and close PR and issue | ||
| run: | | ||
| gh issue comment "${{ inputs.issueNumber }}" --body "${{ env.body }}" | ||
| gh pr close "${{ needs.createPullRequest.outputs.pullRequestNumber }}" | ||
| gh branch delete ${{ env.branchName }} --remote --force | ||
| gh issue close "${{ inputs.issueNumber }}" --reason "not planned" | ||
| gh pr close "${{ needs.createPullRequest.outputs.pullRequestNumber }}" | ||
| git push origin --delete "${{ env.branchName }}" | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| body: | | ||
|
|
@@ -517,6 +527,9 @@ jobs: | |
| git config user.email "github-actions@github.com" | ||
| git fetch origin master | ||
| git merge origin/master --no-edit | ||
| git push --set-upstream origin ${{ env.branchName }} | ||
| # wait for a few seconds to ensure the PR is up to date before merging | ||
| sleep 3 | ||
|
Comment on lines
+531
to
+532
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this necessary?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was hoping this would fix whatever is causing #10139 |
||
| gh pr merge --admin --squash ${{ env.branchName }} -b '[Automated] Merged ${{ needs.getAddonId.outputs.addonFileName }} into master (PR #${{ needs.createPullRequest.outputs.pullRequestNumber }})' | ||
| - name: Comment on issue confirming successful submission | ||
| env: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be more efficient to leave the checkout until after this check, and in "Warn if VT not set up correctly" do