Skip to content

Commit

Permalink
.sync/workflows/leaf: Add PR formatting validator workflow (#118)
Browse files Browse the repository at this point in the history
Adds a new workflow to validate pull request formatting.

Signed-off-by: Michael Kubacki <[email protected]>
  • Loading branch information
makubacki authored Feb 6, 2023
1 parent fe730bb commit bcace84
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .sync/Files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,28 @@ group:
repos: |
microsoft/mu_devops
# Leaf Workflow - Pull Request Validator
- files:
- source: .sync/workflows/leaf/pull-request-formatting-validator.yml
dest: .github/workflows/pull-request-formatting-validator.yml
repos: |
microsoft/mu
microsoft/mu_basecore
microsoft/mu_common_intel_min_platform
microsoft/mu_crypto_release
microsoft/mu_devops
microsoft/mu_feature_config
microsoft/mu_feature_dfci
microsoft/mu_feature_ipmi
microsoft/mu_feature_mm_supv
microsoft/mu_feature_uefi_variable
microsoft/mu_oem_sample
microsoft/mu_plus
microsoft/mu_silicon_arm_tiano
microsoft/mu_silicon_intel_tiano
microsoft/mu_tiano_platforms
microsoft/mu_tiano_plus
# Leaf Workflow - Release Draft
# Note: The branch name used to draft releases on in this group is
# set to the value "main"
Expand Down
54 changes: 54 additions & 0 deletions .sync/workflows/leaf/pull-request-formatting-validator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This workflow validates basic pull request formatting requirements are met.
#
# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there
# instead of the file in this repo.
#
# - Mu DevOps Repo: https://github.com/microsoft/mu_devops
# - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml
#
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#

name: Validate Pull Request Formatting

on:
pull_request_target:
types:
- edited
- opened
- reopened
- synchronize

jobs:
validate_pr:
runs-on: ubuntu-latest
steps:
- run: |
prTitle="$(gh api graphql -F owner=$OWNER -F name=$REPO -F pr_number=$PR_NUMBER -f query='
query($name: String!, $owner: String!, $pr_number: Int!) {
repository(owner: $owner, name: $name) {
pullRequest(number: $pr_number) {
title
}
}
}')"
if [[ "${prTitle}" == *"Personal/"* ]]; then
gh pr comment $PR_URL --body "⚠️ Please add a meaningful PR title (remove the 'Personal/' prefix from the title)."
echo 'VALIDATION_ERROR=true' >> $GITHUB_ENV
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
PR_NUMBER: ${{ github.event.number }}
PR_URL: ${{ github.event.pull_request.html_url }}
REPO: ${{ github.event.repository.name }}
- name: Check for Validation Errors
if: env.VALIDATION_ERROR
uses: actions/github-script@v6
with:
script: |
core.setFailed('PR Formatting Validation Check Failed!')
10 changes: 10 additions & 0 deletions ReadMe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,16 @@ To see more about this flow look in these files:
A Project Mu repo simply needs to sync `.sync/workflows/leaf/auto-merge.yml` to their repo in `Files.yml` and the
auto merge workflow will run in the repo.

Pull Request Validator
----------------------

Validates pull request formatting against requirements defined in the workflow. This workflow is not intended to
strictly validate exact formatting details but provide hints when simple, broad changes are needed to enhance the
quality of pull request verbiage.

- The leaf workflow
- `.sync/workflows/leaf/pull-request-formatting-validator.yml`

Links
=====
- `Basic Azure Landing Site <https://docs.microsoft.com/en-us/azure/devops/pipelines/?view=azure-devops>`_
Expand Down

0 comments on commit bcace84

Please sign in to comment.