mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-12-23 07:25:45 +00:00
infra: Fix PR triage once and for all (#5442)
Switch to a custom made python script that query GitHub API to grab latest state of the PR after label assign.
This commit is contained in:
parent
ac2444f908
commit
e61c09bc85
10 changed files with 125 additions and 98 deletions
8
.github/assign/audio.yml
vendored
8
.github/assign/audio.yml
vendored
|
@ -1,8 +0,0 @@
|
||||||
addReviewers: true
|
|
||||||
|
|
||||||
reviewers:
|
|
||||||
- marysaka
|
|
||||||
|
|
||||||
filterLabels:
|
|
||||||
include:
|
|
||||||
- audio
|
|
11
.github/assign/cpu.yml
vendored
11
.github/assign/cpu.yml
vendored
|
@ -1,11 +0,0 @@
|
||||||
addReviewers: true
|
|
||||||
|
|
||||||
reviewers:
|
|
||||||
- gdkchan
|
|
||||||
- riperiperi
|
|
||||||
- marysaka
|
|
||||||
- LDj3SNuD
|
|
||||||
|
|
||||||
filterLabels:
|
|
||||||
include:
|
|
||||||
- cpu
|
|
4
.github/assign/global.yml
vendored
4
.github/assign/global.yml
vendored
|
@ -1,4 +0,0 @@
|
||||||
addReviewers: true
|
|
||||||
|
|
||||||
reviewers:
|
|
||||||
- Ryujinx/developers
|
|
10
.github/assign/gpu.yml
vendored
10
.github/assign/gpu.yml
vendored
|
@ -1,10 +0,0 @@
|
||||||
addReviewers: true
|
|
||||||
|
|
||||||
reviewers:
|
|
||||||
- gdkchan
|
|
||||||
- riperiperi
|
|
||||||
- marysaka
|
|
||||||
|
|
||||||
filterLabels:
|
|
||||||
include:
|
|
||||||
- gpu
|
|
11
.github/assign/gui.yml
vendored
11
.github/assign/gui.yml
vendored
|
@ -1,11 +0,0 @@
|
||||||
addReviewers: true
|
|
||||||
|
|
||||||
reviewers:
|
|
||||||
- Ack77
|
|
||||||
- emmauss
|
|
||||||
- TSRBerry
|
|
||||||
- marysaka
|
|
||||||
|
|
||||||
filterLabels:
|
|
||||||
include:
|
|
||||||
- gui
|
|
11
.github/assign/horizon.yml
vendored
11
.github/assign/horizon.yml
vendored
|
@ -1,11 +0,0 @@
|
||||||
addReviewers: true
|
|
||||||
|
|
||||||
reviewers:
|
|
||||||
- gdkchan
|
|
||||||
- Ack77
|
|
||||||
- marysaka
|
|
||||||
- TSRBerry
|
|
||||||
|
|
||||||
filterLabels:
|
|
||||||
include:
|
|
||||||
- horizon
|
|
9
.github/assign/infra.yml
vendored
9
.github/assign/infra.yml
vendored
|
@ -1,9 +0,0 @@
|
||||||
addReviewers: true
|
|
||||||
|
|
||||||
reviewers:
|
|
||||||
- marysaka
|
|
||||||
- TSRBerry
|
|
||||||
|
|
||||||
filterLabels:
|
|
||||||
include:
|
|
||||||
- infra
|
|
32
.github/reviewers.yml
vendored
Normal file
32
.github/reviewers.yml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
audio:
|
||||||
|
- marysaka
|
||||||
|
|
||||||
|
cpu:
|
||||||
|
- gdkchan
|
||||||
|
- riperiperi
|
||||||
|
- marysaka
|
||||||
|
- LDj3SNuD
|
||||||
|
|
||||||
|
gpu:
|
||||||
|
- gdkchan
|
||||||
|
- riperiperi
|
||||||
|
- marysaka
|
||||||
|
|
||||||
|
gui:
|
||||||
|
- Ack77
|
||||||
|
- emmauss
|
||||||
|
- TSRBerry
|
||||||
|
- marysaka
|
||||||
|
|
||||||
|
horizon:
|
||||||
|
- gdkchan
|
||||||
|
- Ack77
|
||||||
|
- marysaka
|
||||||
|
- TSRBerry
|
||||||
|
|
||||||
|
infra:
|
||||||
|
- marysaka
|
||||||
|
- TSRBerry
|
||||||
|
|
||||||
|
default:
|
||||||
|
- "@Ryujinx/developers"
|
79
.github/update_reviewers.py
vendored
Normal file
79
.github/update_reviewers.py
vendored
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import List, Set
|
||||||
|
from github import Github
|
||||||
|
from github.Repository import Repository
|
||||||
|
from github.GithubException import GithubException
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
|
def add_reviewers(
|
||||||
|
reviewers: Set[str], team_reviewers: Set[str], new_entries: List[str]
|
||||||
|
):
|
||||||
|
for reviewer in new_entries:
|
||||||
|
if reviewer.startswith("@"):
|
||||||
|
team_reviewers.add(reviewer[1:])
|
||||||
|
else:
|
||||||
|
reviewers.add(reviewer)
|
||||||
|
|
||||||
|
|
||||||
|
def update_reviewers(config, repo: Repository, pr_id: int) -> int:
|
||||||
|
pull_request = repo.get_pull(pr_id)
|
||||||
|
|
||||||
|
if not pull_request:
|
||||||
|
sys.stderr.writable(f"Unknown PR #{pr_id}\n")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
pull_request_author = pull_request.user.login
|
||||||
|
reviewers = set()
|
||||||
|
team_reviewers = set()
|
||||||
|
|
||||||
|
for label in pull_request.labels:
|
||||||
|
if label.name in config:
|
||||||
|
add_reviewers(reviewers, team_reviewers, config[label.name])
|
||||||
|
|
||||||
|
if "default" in config:
|
||||||
|
add_reviewers(reviewers, team_reviewers, config["default"])
|
||||||
|
|
||||||
|
if pull_request_author in reviewers:
|
||||||
|
reviewers.remove(pull_request_author)
|
||||||
|
|
||||||
|
try:
|
||||||
|
reviewers = list(reviewers)
|
||||||
|
team_reviewers = list(team_reviewers)
|
||||||
|
print(
|
||||||
|
f"Attempting to assign reviewers ({reviewers}) and team_reviewers ({team_reviewers})"
|
||||||
|
)
|
||||||
|
pull_request.create_review_request(reviewers, team_reviewers)
|
||||||
|
return 0
|
||||||
|
except GithubException as e:
|
||||||
|
sys.stderr.write(f"Cannot assign review request for PR #{pr_id}: {e}\n")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if len(sys.argv) != 5:
|
||||||
|
sys.stderr.write("usage: <token> <repo_path> <pr_id> <config_path>\n")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
token = sys.argv[1]
|
||||||
|
repo_path = sys.argv[2]
|
||||||
|
pr_id = int(sys.argv[3])
|
||||||
|
config_path = Path(sys.argv[4])
|
||||||
|
|
||||||
|
g = Github(token)
|
||||||
|
repo = g.get_repo(repo_path)
|
||||||
|
|
||||||
|
if not repo:
|
||||||
|
sys.stderr.write("Repository not found!\n")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if not config_path.exists():
|
||||||
|
sys.stderr.write(f'Config "{config_path}" not found!\n')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
with open(config_path, "r") as f:
|
||||||
|
config = yaml.safe_load(f)
|
||||||
|
|
||||||
|
sys.exit(update_reviewers(config, repo, pr_id))
|
48
.github/workflows/pr_triage.yml
vendored
48
.github/workflows/pr_triage.yml
vendored
|
@ -12,43 +12,23 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
# Grab sources to get update_reviewers.py and reviewers.yml
|
||||||
|
- name: Fetch sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
# Ensure we pin the source origin as pull_request_target run under forks.
|
||||||
|
fetch-depth: 0
|
||||||
|
repository: Ryujinx/Ryujinx
|
||||||
|
ref: master
|
||||||
|
|
||||||
- name: Update labels based on changes
|
- name: Update labels based on changes
|
||||||
uses: actions/labeler@v4
|
uses: actions/labeler@v4
|
||||||
with:
|
with:
|
||||||
sync-labels: true
|
sync-labels: true
|
||||||
dot: true
|
dot: true
|
||||||
|
|
||||||
- name: Auto Assign [Audio]
|
- name: Assign reviewers
|
||||||
uses: kentaro-m/auto-assign-action@v1.2.5
|
run: |
|
||||||
with:
|
pip3 install PyGithub
|
||||||
configuration-path: '.github/assign/audio.yml'
|
python3 .github/update_reviewers.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ github.event.pull_request.number }} .github/reviewers.yml
|
||||||
|
shell: bash
|
||||||
- name: Auto Assign [CPU]
|
|
||||||
uses: kentaro-m/auto-assign-action@v1.2.5
|
|
||||||
with:
|
|
||||||
configuration-path: '.github/assign/cpu.yml'
|
|
||||||
|
|
||||||
- name: Auto Assign [GPU]
|
|
||||||
uses: kentaro-m/auto-assign-action@v1.2.5
|
|
||||||
with:
|
|
||||||
configuration-path: '.github/assign/gpu.yml'
|
|
||||||
|
|
||||||
- name: Auto Assign [GUI]
|
|
||||||
uses: kentaro-m/auto-assign-action@v1.2.5
|
|
||||||
with:
|
|
||||||
configuration-path: '.github/assign/gui.yml'
|
|
||||||
|
|
||||||
- name: Auto Assign [Horizon]
|
|
||||||
uses: kentaro-m/auto-assign-action@v1.2.5
|
|
||||||
with:
|
|
||||||
configuration-path: '.github/assign/horizon.yml'
|
|
||||||
|
|
||||||
- name: Auto Assign [Infra]
|
|
||||||
uses: kentaro-m/auto-assign-action@v1.2.5
|
|
||||||
with:
|
|
||||||
configuration-path: '.github/assign/infra.yml'
|
|
||||||
|
|
||||||
- name: Auto Assign [Global]
|
|
||||||
uses: kentaro-m/auto-assign-action@v1.2.5
|
|
||||||
with:
|
|
||||||
configuration-path: '.github/assign/global.yml'
|
|
||||||
|
|
Loading…
Reference in a new issue