pip: bump edk2-basetools from 0.1.51 to 0.1.52 #69
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow automatically adds the appropriate reviewers to a pull request. | |
# | |
# The workflow directly reuses logic in the BaseTools/Scripts/GetMaintainer.py script | |
# to determine the appropriate reviewers, so it matches what a user would see running | |
# the script locally. | |
# | |
# Copyright (c) Microsoft Corporation. | |
# SPDX-License-Identifier: BSD-2-Clause-Patent | |
name: Add Pull Request Reviewers | |
on: | |
pull_request_target: | |
branches: | |
- master | |
types: [opened, ready_for_review, reopened, synchronize] | |
env: | |
GET_MAINTAINER_REL_PATH: "BaseTools/Scripts/GetMaintainer.py" | |
jobs: | |
auto-request-review: | |
name: Add Pull Request Reviewers | |
# Do not run on draft PRs and only run on PRs in the tianocore organization | |
if: ${{ github.event.pull_request.draft == false && github.repository_owner == 'makubacki' }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
issues: write | |
pull-requests: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
sparse-checkout: | | |
.github | |
BaseTools/Scripts | |
Maintainers.txt | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
cache: 'pip' | |
cache-dependency-path: '.github/scripts/requirements.txt' | |
- name: Install PIP Modules | |
run: pip install -r .github/scripts/requirements.txt --upgrade | |
- name: Add Reviewers to Pull Request | |
shell: python | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
ORG_NAME: ${{ github.repository_owner }} | |
PR_NUMBER: ${{ github.event.number}} | |
REPO_NAME: ${{ github.event.pull_request.base.repo.name }} | |
TARGET_BRANCH: ${{ github.event.pull_request.base.ref }} | |
WORKSPACE_PATH: ${{ github.workspace }} | |
run: | | |
import git | |
import os | |
import sys | |
sys.path.append(os.path.join(os.environ["WORKSPACE_PATH"], ".github")) | |
from scripts import GitHub | |
WORKSPACE_PATH = os.environ["WORKSPACE_PATH"] | |
GET_MAINTAINER_LOCAL_PATH = os.path.join(WORKSPACE_PATH, os.environ["GET_MAINTAINER_REL_PATH"]) | |
# Step 1: Get the GitHub created PR commit SHA (contains all changes in a single commit) | |
pr_commit_sha = GitHub.get_pr_sha( | |
os.environ["GH_TOKEN"], | |
os.environ["ORG_NAME"], | |
os.environ["REPO_NAME"], | |
int(os.environ["PR_NUMBER"]), | |
) | |
if not pr_commit_sha: | |
sys.exit(1) | |
print(f"::notice title=PR Commit SHA::Looking at files in consolidated PR commit: {pr_commit_sha}") | |
# Step 2: Fetch only the PR commit to get the files changed in the PR | |
git.Repo(WORKSPACE_PATH).remotes.origin.fetch(pr_commit_sha, depth=1) | |
# Step 3: Get the list of reviewers for the PR | |
reviewers = GitHub.get_reviewers_for_range( | |
WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH, pr_commit_sha, pr_commit_sha | |
) | |
if not reviewers: | |
print("::notice title=No New Reviewers Found!::No reviewers found for this PR.") | |
sys.exit(0) | |
print( | |
f"::notice title=Preliminary Reviewer List::Total reviewer candidates for " | |
f"PR {os.environ['PR_NUMBER']}: {', '.join(reviewers)}" | |
) | |
# Step 4: Add the reviewers to the PR | |
# Note the final requested reviewer list in the workflow run for reference | |
new_reviewers = GitHub.add_reviewers_to_pr( | |
os.environ["GH_TOKEN"], | |
os.environ["ORG_NAME"], | |
os.environ["REPO_NAME"], | |
int(os.environ["PR_NUMBER"]), | |
reviewers, | |
) | |
if new_reviewers: | |
print( | |
f"::notice title=New Reviewers Added::New reviewers requested for PR " | |
f"{os.environ['PR_NUMBER']}: {', '.join(new_reviewers)}" | |
) | |
else: | |
print( | |
"::notice title=No New Reviewers Added::No reviewers were found that " | |
"should be newly requested." | |
) |