From 0ebab0bccadbd38d9bc0aae3e53e9493afa9ec0b Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 3 Jan 2025 03:07:38 +0100 Subject: [PATCH] workflows/eval: Reuse process-reviewers.sh Filters out the PR author and avoids rerequesting reviews from people that already left a review. In a future commit, this can be expanded to also avoid requesting reviews from people not in the org --- .github/workflows/eval.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/eval.yml b/.github/workflows/eval.yml index ab62551ce468..a813c7297288 100644 --- a/.github/workflows/eval.yml +++ b/.github/workflows/eval.yml @@ -219,7 +219,7 @@ jobs: tag: name: Tag runs-on: ubuntu-latest - needs: process + needs: [ attrs, process ] if: needs.process.outputs.baseRunId permissions: pull-requests: write @@ -239,6 +239,21 @@ jobs: name: comparison path: comparison + - name: Install Nix + uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 # v30 + + # Important: This workflow job runs with extra permissions, + # so we need to make sure to not run untrusted code from PRs + - name: Check out Nixpkgs at the base commit + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + ref: ${{ needs.attrs.outputs.baseSha }} + path: base + sparse-checkout: ci + + - name: Build the requestReviews derivation + run: nix-build base/ci -A requestReviews + - name: Tagging pull request run: | # Get all currently set rebuild labels @@ -271,8 +286,8 @@ jobs: # maintainers.json contains GitHub IDs. Look up handles to request reviews from. # There appears to be no API to request reviews based on GitHub IDs jq -r 'keys[]' comparison/maintainers.json \ - | while read -r id; do gh api /user/"$id"; done \ - | jq -s '{ reviewers: map(.login) }' \ + | while read -r id; do gh api /user/"$id" --jq .login; done \ + | GH_TOKEN=${{ steps.app-token.outputs.token }} result/bin/process-reviewers.sh "$REPOSITORY" "$NUMBER" "$AUTHOR" \ > reviewers.json # Request reviewers from maintainers of changed output paths @@ -285,6 +300,7 @@ jobs: GH_TOKEN: ${{ github.token }} REPOSITORY: ${{ github.repository }} NUMBER: ${{ github.event.number }} + AUTHOR: ${{ github.event.pull_request.user.login }} - name: Add eval summary to commit statuses if: ${{ github.event_name == 'pull_request_target' }}