Commit Graph
18 Commits
Author SHA1 Message Date
Michael Kubackiandmergify[bot] 43e86ce5d5 .github/scripts: Make reviewer filtering case insensitive
The `add_reviewers_to_pr()` function in GitHub.py did not compare
all usernames without case sensitivity which could cause a reviewer
that has already reviewed a pull request to be re-requested.

The occurred under the following conditions:

- GetMaintainer.py returns usernames from Maintainers.txt
  (e.g. "user")
- GitHub API returns usernames in their actual case (e.g. "User")
- The exclusion filter used case-sensitive comparison so the match
  is not detected

Fixed by converting the exclusion set to lowercase and performing
case-insensitive comparison when filtering for new reviewers.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2025-12-01 23:57:09 +00:00
Michael Kubackiandmergify[bot] edb5331f78 .github/workflows: Add PR formatting validator
This workflow runs when GitHub PRs are modified (edited, opened,
reopened, and synchronized) to perform basic validation of the PR
title and description.

Right now, this includes:

- Checking that the PR title is not empty
- Checking that the PR body is not empty
- Checking that the PR body meets the minimum text length.
  Where the minimum text length is defined to be the number of
  characters in the PR template with empty sections
- Checking that PR template placeholder do not remain in the PR
  description

If a check fails, a GitHub comment will be left on the PR and a PR
status check failure will be present on the PR until the issue is
resolved. Upon future runs of the workflow, existing PR validation
message contents are hashed and compared to a new message that may
potentially be posted. If the same comment is already posted in the
PR, it is not posted again.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2025-10-01 23:46:51 +00:00
Michael Kubackiandmergify[bot] bfbd5d70e8 .github/GitHub.py: Add output and env helpers
Adds GitHub helper functions so other Python code can more cleanly
set output and environment variables.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2025-10-01 23:46:51 +00:00
Michael Kubackiandmergify[bot] 607c58ef01 .github: Compare collaborator GitHub ID's in single case
Since case of a GitHub user name may by specified differently in the
`Maintainers.txt` file versus what is actually returned by the GitHub
API (actual case), convert both to lowercase for comparison.

Other GitHub user name inputs are directly from APIs and maintain
consistent casing.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2025-05-13 12:44:57 +00:00
Michael Kubackiandmergify[bot] a4c50dd3e8 .github: Handle deleted GitHub accounts
If a GitHub account has been deleted entirely, a `None` user will
be returrned from the GitHub API. This change accounts for a `None`
user when querying GitHub APIs for user information.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-11-26 18:08:26 +00:00
Michael Kubackiandmergify[bot] 4f4673846f .github/GitHub.py: Update bot in redundant comment check
The project moved from using the `github-actions[bot]` bot account to
the `tianocore-assign-reviewers[bot]` account. A check is in place to
prevent the "`WARNING: Cannot add some reviewers`" from appearing
more than once if nothing has changed in the content it would post.

This change updates the bot account to the current one so the check
can work again.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-10-01 01:19:00 +00:00
Michael Kubackiandmergify[bot] 51ada84cd5 .github/request-reviews.yml: Move workflow Py code to file
To make the Python code used within the action more mantainable over
time, it is moved to a standalone script in .github/scripts.

No functional changes are made to the workflow itself.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-08-05 19:30:26 +00:00
Michael Kubackiandmergify[bot] 59ad8aeda6 .github/request-reviews.yml: Formatting (non-functional)
Updates code for PEP8 formatting by using the Black code formatter.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-08-05 19:30:26 +00:00
Michael Kubackiandmergify[bot] 32a099c358 .github/request-reviews.yml: Improve doc and dbg messages
Adds additional documentation and cleans up debug messages printed
to GitHub workflow output (available in the GitHub Actions pane).

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-08-05 19:30:26 +00:00
Michael Kubackiandmergify[bot] f617b6ee0e .github/request-reviews.yml: Only post non-collab message once
Enhances the flow that adds a comment on a PR if a non-collaborator
is in the reviewer list by checking if a comment was previously left
on the PR. If it was for the same set of non-collaborators, another
comment is not created. If a new non-collaborator is discovered, the
message will be left identifying that new user account.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-08-05 19:30:26 +00:00
Michael Kubackiandmergify[bot] 09ad1a0072 .github/request-reviews.yml: Add non-collab admin notification
If a non-collaborator is part of the reviewer list, an admin needs
to be notified so they can be removed.

This change finds the list of admins for the repo and notifies them
in the comment left on the PR describing the list of non-collaborator
users. The message itself is cleaned up to show only the
non-collaborator users for ease of identification.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-08-05 19:30:26 +00:00
Michael Kubackiandmergify[bot] e86647decd .github/request-reviews.yml: Update PR reviewer exclusion
Updates logic to:

- Not request reviews from reviewers that have already left a review
  on the PR. Previously, the reviewers review (e.g. approval) would
  remain on the PR, but they would be notified on each change to the
  PR. This approach follows the expected notification process for
  requesting reviews which is one time. Maintainers and reviewers can
  set up their own notifications for more granular updates on PR
  activity separately.

- Add the collaborator reviewers if a reviewer(s) is found to not be
  a collaborator. This is an improvement to today's behavior which is
  to not add any reviewers if a single reviewer is not a collaborator
  of the repo.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-08-05 19:30:26 +00:00
Michael Kubackiandmergify[bot] eaf2b82eda .github/request-reviews.yml: Removed unused functionality
Removed the `download_gh_file()` function which is no longer needed
with sparse checkout.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-08-05 19:30:26 +00:00
Michael Kubackiandmergify[bot] d3e9e10770 .github/request-reviews.yml: Switch to PyGithub
Uses PyGithub for GitHub interactions instead of the GitHub REST API
directly.

This simplifies the code, improves error handling and robustness, and
lets the PyGithub project abstract GitHub REST API changes that may
occur over time.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-08-05 19:30:26 +00:00
Michael Kubackiandmergify[bot] 98f17cdcf4 .github/request-reviews.yml: Switch to GitPython
Uses `GitPython` instead of invoking the git executable directly.

This has the benefit of improving code readability and less support
code for binary interaction.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-08-05 19:30:26 +00:00
Michael Kubackiandmergify[bot] 057c26710a .github/request-reviews.yml: Cache PIP modules
- Optimizes and makes the PIP module installation process for the
workflow more robust by caching the pip modules used so the only
time the workflow needs to reach to PyPi is when new PIP modules
are published.

- Improves long term stability by locking the major versions for PIP
modules in the workflow. This is to reduce overall maintenance over
time to automatically pick up new versions while also not being
broken in the process.

- Removes edk2-pytool-extensions as it is not used.

The new "requirements.txt" file is used to lock versions and support
the caching step which depends on a requirements file.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-08-05 19:30:26 +00:00
Michael Kubackiandmergify[bot] 0343e75233 .github/request-reviews.yml: Switch to pull_request_target
This change simply moves the trigger to `pull_request_target`. The
rest of this message contains verbose details related to that.

`pull_request_target` is used instead of `pull_request` since the
default GitHub token cannot pick up write permissions with the
`pull_request` type on PRs from public forks. Write permission is
needed to add reviewrs. This was previously tested on an edk2 fork
where PRs were not from other public forks into the fork being used
for testing but directly on the fork itself.

Because `pull_request_target` runs the pull request in the context
of the base branch (not the PR branch) some logic needs slightly
modified. The main change is that the GitHub context will no longer
give the PR branch HEAD as the PR commit SHA (i.e.
`github.event.pull_request.head.sha`). The SHA will be the base
branch (`master`) SHA as that is what is checked out for the
workflow run. SO, the actual PR SHA is now fetched separately.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-07-27 05:59:14 +00:00
Michael Kubackiandmergify[bot] 89a06a245b .github: Add GitHub helper python script
Adds a script that provides GitHub API helpers for workflows and
other GitHub automation in the repository.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-07-25 02:28:49 +00:00