diff --git a/.github/workflows/automerge_plugin-only_prs.yml b/.github/workflows/automerge_plugin-only_prs.yml deleted file mode 100644 index e37d1b21..00000000 --- a/.github/workflows/automerge_plugin-only_prs.yml +++ /dev/null @@ -1,133 +0,0 @@ -name: Automatically merge plugin-only PRs - - -# Triggered on all PRs either by -# - completion of CI checks, OR -# - tagging with label -# 1) If PR is labeled "automerge" or "automerge-web" -# (all website submissions are tagged "automerge-web"), -# checks if Travis tests pass. If yes, THEN -# 2) Checks if PR modifies any code outside plugin dirs. -# If no changes are made beyond new or revised plugins -# (subdirs of /benchmarks, /data, /models, or /metrics) -# the PR is automatically approved and merged. - - -on: - pull_request: - types: [labeled] - status: - -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 - - - isautomerge: - name: Set as 'automerge' if PR is labeled with 'automerge' or 'automerge-web' - runs-on: ubuntu-latest - if: | - contains( github.event.pull_request.labels.*.name, 'automerge') || - contains( github.event.pull_request.labels.*.name, 'automerge-web') - outputs: - AUTOMERGE: ${{ steps.setautomerge.outputs.AUTOMERGE }} - steps: - - name: Set 'automerge' to 'True' # job only runs if True - id: setautomerge - run: | - echo "::set-output name=AUTOMERGE::True" - - - travis_success: - name: Check if Travis build is successful - runs-on: ubuntu-latest - needs: [isautomerge] - if: ${{ needs.isautomerge.outputs.AUTOMERGE == 'True' }} - outputs: - TRAVIS_OK: ${{ steps.istravisok.outputs.TRAVIS_OK }} - steps: - - name: Get Travis build status - id: gettravisstatus - run: | - echo ${{ github.event.pull_request.head.sha }} - echo "TRAVIS_CONCLUSION=$(python -c "import requests; r = requests.get(\"https://api.github.com/repos/brain-score/language/commits/${{ github.event.pull_request.head.sha }}/check-runs\"); print(next(run['conclusion'] for run in r.json()['check_runs'] if run['name'] == 'Travis CI - Pull Request'))")" >> $GITHUB_ENV - - name: Check if Travis was successful - id: istravisok - run: | - if [ "$TRAVIS_CONCLUSION" == "success" ] - then - travisok=True - elif [ "$TRAVIS_CONCLUSION" == "None" ] - then - travisok=Wait - else - travisok=False - fi - echo "::set-output name=TRAVIS_OK::$travisok" - - - plugin_only: - name: Ensure PR ONLY changes plugin files - runs-on: ubuntu-latest - needs: travis_success - if: ${{ needs.travis_success.outputs.TRAVIS_OK == 'True' }} - outputs: - PLUGIN_ONLY: ${{ steps.ispluginonly.outputs.PLUGIN_ONLY }} - steps: - - name: Parse plugin_only confirmation from Travis status update - id: getpluginonlyvalue - run: echo "PLUGIN_ONLY=$(python -c "import requests; r = requests.get(\"https://api.github.com/repos/brain-score/language/statuses/$github.event.pull_request.head.sha\"); print(next(status['description'].split('- ')[1] for status in r.json() if status['description'].startswith('Run automerge workflow')))")" >> $GITHUB_ENV - - name: Check if PR is plugin only - id: ispluginonly - run: | - if [ "$PLUGIN_ONLY" == "True" ] - then - pluginonly=True - else - pluginonly=False - fi - echo "::set-output name=PLUGIN_ONLY::$pluginonly" - - - automerge: - name: If plugin-only, approve and merge - runs-on: ubuntu-latest - needs: plugin_only - if: ${{ needs.plugin_only.outputs.PLUGIN_ONLY == 'True' }} - steps: - - name: Auto Approve - uses: hmarr/auto-approve-action@v3.1.0 - - - name: Auto Merge (GitHub submissions) - uses: plm9606/automerge_actions@1.2.2 - with: - github-token: ${{ secrets.WORKFLOW_TOKEN }} - label-name: "automerge" - merge-method: "squash" - auto-delete: "true" - - - name: Auto Merge (brain-score.org submissions) - uses: plm9606/automerge_actions@1.2.2 - with: - github-token: ${{ secrets.WORKFLOW_TOKEN }} - label-name: "automerge-web" - merge-method: "squash" - auto-delete: "true" diff --git a/.github/workflows/metadata_handler.yml b/.github/workflows/metadata_handler.yml index d49a2dff..f4f92920 100644 --- a/.github/workflows/metadata_handler.yml +++ b/.github/workflows/metadata_handler.yml @@ -23,6 +23,17 @@ on: required: false type: boolean default: false + secrets: + BSC_DATABASESECRET: + required: true + AWS_ACCESS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + GITHUB_TOKEN: + required: true + APPROVAL_TOKEN: + required: true workflow_dispatch: inputs: diff --git a/.github/workflows/score_new_plugins.yml b/.github/workflows/score_new_plugins.yml deleted file mode 100644 index 206fd75c..00000000 --- a/.github/workflows/score_new_plugins.yml +++ /dev/null @@ -1,131 +0,0 @@ -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@v4 - - name: Set up Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - 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~1 origin/$GITHUB_HEAD_REF | tr '\n' ' ')" >> $GITHUB_ENV - - - name: Installing package dependencies - run: | - python -m pip install --upgrade pip setuptools - python -m pip install ".[test]" - - - name: Get plugin info - id: getpluginfo - run: | - 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 - - - name: Run scoring - id: runscore - run: | - echo "RUN_SCORE=$(jq -r '.run_score' <<< ${{ steps.getpluginfo.outputs.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/get-github-email-by-username-action@v1.25 - 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 tr -d "'" | jq -c '. + {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 tr -d "'" | jq -c '. + {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 --upgrade pip setuptools - python -m pip install ".[test]" - python -c 'from brainscore_core.submission.endpoints import call_jenkins; call_jenkins('\''${{ env.PLUGIN_INFO }}'\'')'