mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 04:05:40 +03:00
workflows/eval: split reviewers job into re-usable workflow
This allows us to trigger only the reviewers job when undrafting a PR in the next step. Split for ease of review. The code is copied 1:1 to reviewers.yml.
This commit is contained in:
parent
ecf95fa458
commit
4c2e23826c
2 changed files with 84 additions and 69 deletions
73
.github/workflows/eval.yml
vendored
73
.github/workflows/eval.yml
vendored
|
@ -264,77 +264,12 @@ jobs:
|
||||||
"/repos/$GITHUB_REPOSITORY/statuses/$PR_HEAD_SHA" \
|
"/repos/$GITHUB_REPOSITORY/statuses/$PR_HEAD_SHA" \
|
||||||
-f "context=Eval / Summary" -f "state=success" -f "description=$description" -f "target_url=$target_url"
|
-f "context=Eval / Summary" -f "state=success" -f "description=$description" -f "target_url=$target_url"
|
||||||
|
|
||||||
reviews:
|
reviewers:
|
||||||
name: Request Reviews
|
name: Reviewers
|
||||||
runs-on: ubuntu-24.04-arm
|
|
||||||
# No dependency on "compare", so that it can start at the same time.
|
# No dependency on "compare", so that it can start at the same time.
|
||||||
# We only wait for the "comparison" artifact to be available, which makes the start-to-finish time
|
# We only wait for the "comparison" artifact to be available, which makes the start-to-finish time
|
||||||
# for the eval workflow considerably faster.
|
# for the eval workflow considerably faster.
|
||||||
needs: [ prepare, outpaths ]
|
needs: [ prepare, outpaths ]
|
||||||
if: needs.prepare.outputs.targetSha
|
if: needs.prepare.outputs.targetSha
|
||||||
steps:
|
uses: ./.github/workflows/reviewers.yml
|
||||||
- name: Check out the PR at the base commit
|
secrets: inherit
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
||||||
with:
|
|
||||||
path: trusted
|
|
||||||
sparse-checkout: ci
|
|
||||||
|
|
||||||
- name: Install Nix
|
|
||||||
uses: cachix/install-nix-action@526118121621777ccd86f79b04685a9319637641 # v31
|
|
||||||
with:
|
|
||||||
extra_nix_config: sandbox = true
|
|
||||||
|
|
||||||
- name: Build the requestReviews derivation
|
|
||||||
run: nix-build trusted/ci -A requestReviews
|
|
||||||
|
|
||||||
# See ./codeowners-v2.yml, reuse the same App because we need the same permissions
|
|
||||||
# Can't use the token received from permissions above, because it can't get enough permissions
|
|
||||||
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
|
|
||||||
if: vars.OWNER_APP_ID
|
|
||||||
id: app-token
|
|
||||||
with:
|
|
||||||
app-id: ${{ vars.OWNER_APP_ID }}
|
|
||||||
private-key: ${{ secrets.OWNER_APP_PRIVATE_KEY }}
|
|
||||||
permission-administration: read
|
|
||||||
permission-members: read
|
|
||||||
permission-pull-requests: write
|
|
||||||
|
|
||||||
- name: Wait for comparison to be done
|
|
||||||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
// Waiting 24 * 5 sec = 2 min. max.
|
|
||||||
for (let i = 0; i < 24; i++) {
|
|
||||||
const result = await github.rest.actions.listWorkflowRunArtifacts({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
run_id: context.runId,
|
|
||||||
name: 'comparison'
|
|
||||||
})
|
|
||||||
if (result.data.total_count > 0) return
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 5000))
|
|
||||||
}
|
|
||||||
throw new Error("No comparison artifact found.")
|
|
||||||
|
|
||||||
- name: Download the comparison results
|
|
||||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
|
||||||
with:
|
|
||||||
pattern: comparison
|
|
||||||
path: comparison
|
|
||||||
merge-multiple: true
|
|
||||||
|
|
||||||
- name: Requesting maintainer reviews
|
|
||||||
if: ${{ steps.app-token.outputs.token }}
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ github.token }}
|
|
||||||
REPOSITORY: ${{ github.repository }}
|
|
||||||
NUMBER: ${{ github.event.number }}
|
|
||||||
AUTHOR: ${{ github.event.pull_request.user.login }}
|
|
||||||
# Don't request reviewers on draft PRs
|
|
||||||
DRY_MODE: ${{ github.event.pull_request.draft && '1' || '' }}
|
|
||||||
run: |
|
|
||||||
# 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" --jq .login; done \
|
|
||||||
| GH_TOKEN=${{ steps.app-token.outputs.token }} result/bin/request-reviewers.sh "$REPOSITORY" "$NUMBER" "$AUTHOR"
|
|
||||||
|
|
80
.github/workflows/reviewers.yml
vendored
Normal file
80
.github/workflows/reviewers.yml
vendored
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
# This workflow will request reviews from the maintainers of each package
|
||||||
|
# listed in the PR's most recent eval comparison artifact.
|
||||||
|
|
||||||
|
name: Reviewers
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
request:
|
||||||
|
name: Request
|
||||||
|
runs-on: ubuntu-24.04-arm
|
||||||
|
steps:
|
||||||
|
- name: Check out the PR at the base commit
|
||||||
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
with:
|
||||||
|
path: trusted
|
||||||
|
sparse-checkout: ci
|
||||||
|
|
||||||
|
- name: Install Nix
|
||||||
|
uses: cachix/install-nix-action@526118121621777ccd86f79b04685a9319637641 # v31
|
||||||
|
with:
|
||||||
|
extra_nix_config: sandbox = true
|
||||||
|
|
||||||
|
- name: Build the requestReviews derivation
|
||||||
|
run: nix-build trusted/ci -A requestReviews
|
||||||
|
|
||||||
|
# See ./codeowners-v2.yml, reuse the same App because we need the same permissions
|
||||||
|
# Can't use the token received from permissions above, because it can't get enough permissions
|
||||||
|
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
|
||||||
|
if: vars.OWNER_APP_ID
|
||||||
|
id: app-token
|
||||||
|
with:
|
||||||
|
app-id: ${{ vars.OWNER_APP_ID }}
|
||||||
|
private-key: ${{ secrets.OWNER_APP_PRIVATE_KEY }}
|
||||||
|
permission-administration: read
|
||||||
|
permission-members: read
|
||||||
|
permission-pull-requests: write
|
||||||
|
|
||||||
|
- name: Wait for comparison to be done
|
||||||
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
// Waiting 24 * 5 sec = 2 min. max.
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
const result = await github.rest.actions.listWorkflowRunArtifacts({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
run_id: context.runId,
|
||||||
|
name: 'comparison'
|
||||||
|
})
|
||||||
|
if (result.data.total_count > 0) return
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 5000))
|
||||||
|
}
|
||||||
|
throw new Error("No comparison artifact found.")
|
||||||
|
|
||||||
|
- name: Download the comparison results
|
||||||
|
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
||||||
|
with:
|
||||||
|
pattern: comparison
|
||||||
|
path: comparison
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Requesting maintainer reviews
|
||||||
|
if: ${{ steps.app-token.outputs.token }}
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
REPOSITORY: ${{ github.repository }}
|
||||||
|
NUMBER: ${{ github.event.number }}
|
||||||
|
AUTHOR: ${{ github.event.pull_request.user.login }}
|
||||||
|
# Don't request reviewers on draft PRs
|
||||||
|
DRY_MODE: ${{ github.event.pull_request.draft && '1' || '' }}
|
||||||
|
run: |
|
||||||
|
# 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" --jq .login; done \
|
||||||
|
| GH_TOKEN=${{ steps.app-token.outputs.token }} result/bin/request-reviewers.sh "$REPOSITORY" "$NUMBER" "$AUTHOR"
|
Loading…
Add table
Add a link
Reference in a new issue