If PR ONLY changes plugin files, ONLY run tests for respective plugin(s) #43
Workflow file for this run
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
name: Trigger scoring run | |
# Triggered on all PRs on merge to main | |
# If changes are made to a subdir of /benchmarks or /models, | |
# a Jenkins scoring run is triggered for the corresponding plugin | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- closed | |
permissions: write-all | |
jobs: | |
setup: | |
name: setup | |
runs-on: ubuntu-latest | |
outputs: | |
BSC_DATABASESECRET: ${{ steps.setenvvars.outputs.BSC_DATABASESECRET }} | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v2 | |
- name: Check if main & set dev/prod vars | |
id: setenvvars | |
run: | | |
if [ ${{ github.ref }} != 'refs/heads/main' ]; then | |
echo "is NOT main branch" | |
echo "::set-output name=BSC_DATABASESECRET:: ${{ secrets.BSC_DATABASESECRET_DEV }}" | |
else | |
echo "is main branch" | |
echo "::set-output name=BSC_DATABASESECRET:: ${{ secrets.BSC_DATABASESECRET_PROD }}" | |
fi | |
changes_models_or_benchmarks: | |
name: Check if PR makes changes to /models or /benchmarks | |
runs-on: ubuntu-latest | |
outputs: | |
PLUGIN_INFO: ${{ steps.getpluginfo.outputs.PLUGIN_INFO }} | |
RUN_SCORE: ${{ steps.runscore.outputs.RUN_SCORE }} | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Save changed files to env var | |
run: echo "CHANGED_FILES=$(git diff --name-only origin/main origin/$GITHUB_HEAD_REF | tr '\n' ' ')" >> $GITHUB_ENV | |
- name: Get scoring info | |
run: | | |
python -m pip install . | |
echo "PLUGIN_INFO=$(python -c "from brainscore_core.plugin_management.parse_plugin_changes import get_scoring_info; get_scoring_info('${{ env.CHANGED_FILES }}', 'brainscore_language')" >> $GITHUB_OUTPUT | |
echo "RUN_SCORE=$(jq -r '.run_score' <<< "$PLUGIN_INFO")" >> $GITHUB_OUTPUT | |
get_submitter_info: | |
name: Get PR author email and (if web submission) Brain-Score user ID | |
runs-on: ubuntu-latest | |
needs: [setup, changes_models_or_benchmarks] | |
if: ${{ needs.changes_models_or_benchmarks.outputs.RUN_SCORE == 'True' }} | |
env: | |
BSC_DATABASESECRET: ${{ needs.setup.outputs.BSC_DATABASESECRET }} | |
PLUGIN_INFO: ${{ needs.changes_models_or_benchmarks.outputs.PLUGIN_INFO }} | |
outputs: | |
PLUGIN_INFO: ${{ steps.add_email_to_pluginfo.outputs.PLUGIN_INFO }} | |
steps: | |
- name: Parse user ID from PR title (WEB ONLY where we don't have access to the GitHub user) | |
id: getuid | |
if: ${{ github.event.pull_request.labels.*.name == 'automerge-web' }} | |
run: | | |
echo "BS_UID="$(<<<${{ github.event.pull_request.title }} | sed -E 's/.*\(user:([^)]+)\).*/\1/'"" >> $GITHUB_ENV | |
- name: Add user ID to PLUGIN_INFO (WEB ONLY) | |
id: add_uid_to_pluginfo | |
if: ${{ github.event.pull_request.labels.*.name == 'automerge-web' }} | |
run: | | |
echo "The Brain-Score user ID is ${{ steps.getuid.outputs.BS_UID }}" | |
echo "PLUGIN_INFO="$(<<<$PLUGIN_INFO jq '. + {user_id: ${{ steps.getuid.outputs.UID }} }')"" >> $GITHUB_ENV | |
- name: Get PR author email from GitHub username | |
id: getemail | |
uses: evvanErb/[email protected] | |
with: | |
github-username: ${{github.event.pull_request.user.login}} # PR author's username | |
token: ${{ secrets.GITHUB_TOKEN }} # Including token enables most reliable way to get a user's email | |
- name: Add PR author email to PLUGIN_INFO | |
id: add_email_to_pluginfo | |
run: | | |
echo "The PR author email is ${{ steps.getemail.outputs.email }}" | |
echo "PLUGIN_INFO="$(<<<$PLUGIN_INFO jq '. + {author_email: "'${{ steps.getemail.outputs.email }}'"}')"" >> $GITHUB_OUTPUT | |
runscore: | |
name: Score plugins | |
runs-on: ubuntu-latest | |
needs: [changes_models_or_benchmarks, get_submitter_info] | |
if: ${{ needs.changes_models_or_benchmarks.outputs.RUN_SCORE == 'True' }} | |
env: | |
PLUGIN_INFO: ${{ needs.get_submitter_info.outputs.PLUGIN_INFO }} | |
JENKINS_USER: ${{ secrets.JENKINS_USR }} | |
JENKINS_TOKEN: ${{ secrets.JENKINS_TOKEN }} | |
JENKINS_TRIGGER: ${{ secrets.JENKINS_TRIGGER }} | |
steps: | |
- name: Add public, competition, and model_type to PLUGIN_INFO | |
run: | | |
echo "PLUGIN_INFO="$(<<<$PLUGIN_INFO jq '. + {domain: "language", public: "True", competition: "None", model_type: "artificialsubject"}')"" >> $GITHUB_ENV | |
- name: Check out repository code | |
uses: actions/checkout@v2 | |
- name: Build project and run scoring | |
run: | | |
python -m pip install "." | |
python -c "from brainscore_language.submission.endpoints import call_jenkins; call_jenkins('$env.PLUGIN_INFO')" |