-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split
automerge_plugin-only_prs
into two workflows: `check_if_pr_is…
…_automergeable` and `automerge_plugin-only_prs` (#488) * generalize trigger for all workflows * split automergeable check and approval/merge into two workflows * nit (lowercase -> capital constants) --------- Co-authored-by: Katherine Fairchild <[email protected]>
- Loading branch information
1 parent
21c6b41
commit cc481da
Showing
7 changed files
with
162 additions
and
77 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Check if PR is automergeable | ||
|
||
|
||
# Triggered on all PRs either by | ||
# - completion of CI checks (status or check_run events), OR | ||
# - tagging with "automerge" or "automerge-web" labels | ||
# This workflow checks if the PR that invoked the trigger is automergeable. | ||
# A PR is automergeable iff it: | ||
# 1) is labeled "automerge" OR "automerge-web" (originates from web submission) | ||
# 2) only changes plugins (subdirs of /benchmarks, /data, /models, /metrics) | ||
# 3) passes all tests (Travis and Jenkins). | ||
# If all 3 conditions are met, the "automerge-approved" label is applied to the PR | ||
# (This label triggers the `automerge_plugin-only_prs` workflow to merge the PR.) | ||
|
||
|
||
on: | ||
pull_request: | ||
types: [labeled] | ||
check_run: | ||
types: [completed] | ||
status: | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
|
||
check_test_results: | ||
name: Check if all tests have passed and PR meets automerge conditions | ||
runs-on: ubuntu-latest | ||
outputs: | ||
ALL_TESTS_PASS: ${{ steps.gettestresults.outputs.TEST_RESULTS }} | ||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Get test results and ensure automergeable | ||
id: gettestresults | ||
run: | | ||
echo "Checking test results for PR head pr_head=$( python brainscore_vision/submission/actions_helpers.py get_pr_head )" | ||
echo "{TEST_RESULTS}={$( python brainscore_vision/submission/actions_helpers.py )}" >> $GITHUB_OUTPUT | ||
approve_automerge: | ||
name: If tests pass and PR is automergeable, apply "approve_automerge" label to PR | ||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
needs: check_test_results | ||
if: ${{ needs.check_test_results.outputs.ALL_TESTS_PASS == 'True' }} | ||
steps: | ||
- name: Get PR number from workflow context | ||
run: | | ||
echo "{PR_NUMBER}={$( python brainscore_vision/submission/actions_helpers.py get_pr_num )}" >> $GITHUB_ENV | ||
- name: Add automerge-approved label to PR | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GH_REPO: ${{ github.repository }} | ||
NUMBER: ${{ env.PR_NUMBER }} | ||
LABELS: automerge-approved | ||
run: gh issue edit "$NUMBER" --add-label "$LABELS" |
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
GH_WORKFLOW_TRIGGER=$1 | ||
PULL_REQUEST_SHA=$2 | ||
STATUS_DESCRIPTION=$3 | ||
CONTEXT=$4 | ||
|
||
curl -L -X POST \ | ||
-H "Authorization: token $GH_WORKFLOW_TRIGGER" \ | ||
-d $'{"state": "success", "description": "'"$STATUS_DESCRIPTION"'", | ||
"context": "'"$CONTEXT"'"}' \ | ||
"https://api.github.com/repos/brain-score/brain-score/statuses/$PULL_REQUEST_SHA" |
This file contains 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
This file contains 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
This file contains 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