aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTSRBerry <20988865+TSRBerry@users.noreply.github.com>2023-09-04 13:39:25 +0200
committerGitHub <noreply@github.com>2023-09-04 11:39:25 +0000
commit5f771f5661b3f6d77ae15b72727c664d45a37b96 (patch)
treee644e4a2aab6658c5f0dc3c83b6080fd6fc8aa3f
parent93cd327873bed829c3a0aad938cb8d2cca2ff806 (diff)
Update reviewers using Ryujinx-Mako command (#5635)
* Update reviewers using Ryujinx-Mako command * Fix worklflow step 'uses' path
-rw-r--r--.github/update_reviewers.py87
-rw-r--r--.github/workflows/pr_triage.yml19
2 files changed, 15 insertions, 91 deletions
diff --git a/.github/update_reviewers.py b/.github/update_reviewers.py
deleted file mode 100644
index 955d40e7..00000000
--- a/.github/update_reviewers.py
+++ /dev/null
@@ -1,87 +0,0 @@
-from pathlib import Path
-from typing import List, Set
-from github import Auth, Github
-from github.Repository import Repository
-from github.GithubException import GithubException
-
-import os
-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
-
- if pull_request.draft:
- print("Not assigning reviewers for draft PRs")
- return 0
-
- 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) != 7:
- sys.stderr.write("usage: <app_id> <private_key_env_name> <installation_id> <repo_path> <pr_id> <config_path>\n")
- sys.exit(1)
-
- app_id = int(sys.argv[1])
- private_key = os.environ[sys.argv[2]]
- installation_id = int(sys.argv[3])
- repo_path = sys.argv[4]
- pr_id = int(sys.argv[5])
- config_path = Path(sys.argv[6])
-
- auth = Auth.AppAuth(app_id, private_key).get_installation_auth(installation_id)
- g = Github(auth=auth)
- 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))
diff --git a/.github/workflows/pr_triage.yml b/.github/workflows/pr_triage.yml
index 448e2c7d..10666383 100644
--- a/.github/workflows/pr_triage.yml
+++ b/.github/workflows/pr_triage.yml
@@ -12,7 +12,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- # Grab sources to get update_reviewers.py and reviewers.yml
+ - name: Checkout Ryujinx-Mako
+ uses: actions/checkout@v3
+ with:
+ repository: Ryujinx/Ryujinx-Mako
+ ref: master
+ path: '.ryujinx-mako'
+
+ - name: Setup Ryujinx-Mako
+ uses: ./.ryujinx-mako/.github/actions/setup-mako
+
+ # Grab sources to get latest labeler.yml
- name: Fetch sources
uses: actions/checkout@v3
with:
@@ -27,11 +37,12 @@ jobs:
sync-labels: true
dot: true
- - run: pip3 install PyGithub
-
- name: Assign reviewers
run: |
- python3 .github/update_reviewers.py ${{ secrets.MAKO_APP_ID }} "MAKO_PRIVATE_KEY" ${{ secrets.MAKO_INSTALLATION_ID }} ${{ github.repository }} ${{ github.event.pull_request.number }} .github/reviewers.yml
+ poetry -C .ryujinx-mako shell
+ ryujinx-mako update-reviewers ${{ github.repository }} ${{ github.event.pull_request.number }} .github/reviewers.yml
shell: bash
env:
+ MAKO_APP_ID: ${{ secrets.MAKO_APP_ID }}
MAKO_PRIVATE_KEY: ${{ secrets.MAKO_PRIVATE_KEY }}
+ MAKO_INSTALLATION_ID: ${{ secrets.MAKO_INSTALLATION_ID }}