mirror of
https://github.com/Dasharo/edk2.git
synced 2026-06-13 10:16:24 -07:00
edb5331f78
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>
78 lines
2.4 KiB
YAML
78 lines
2.4 KiB
YAML
# This workflow validates basic pull request formatting requirements are met.
|
|
#
|
|
# Copyright (c) Microsoft Corporation.
|
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
#
|
|
|
|
name: Validate Pull Request Formatting
|
|
|
|
on:
|
|
pull_request_target:
|
|
branches:
|
|
- master
|
|
types:
|
|
- edited
|
|
- opened
|
|
- reopened
|
|
- synchronize
|
|
|
|
concurrency:
|
|
group: pr-validation-${{ github.event.number }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
validate_pr:
|
|
name: Validate Pull Request Formatting
|
|
# Do not run on draft PRs and only run on PRs in the tianocore org
|
|
if: ${{ github.event.pull_request.draft == false && github.repository_owner == 'tianocore' }}
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Generate Token
|
|
id: app-token
|
|
uses: actions/create-github-app-token@v2
|
|
with:
|
|
app-id: ${{ secrets.TIANOCORE_PR_AUTOMATION_APPLICATION_ID }}
|
|
private-key: ${{ secrets.TIANOCORE_PR_AUTOMATION_APPLICATION_PRIVATE_KEY }}
|
|
|
|
# Reduce checkout time with sparse-checkout
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
sparse-checkout: |
|
|
.github/scripts/
|
|
|
|
- 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
|
|
|
|
- name: Validate PR Format
|
|
id: validate
|
|
run: python .github/scripts/validate_pr_formatting.py
|
|
env:
|
|
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
|
|
OWNER: ${{ github.repository_owner }}
|
|
PR_NUMBER: ${{ github.event.number }}
|
|
REPO: ${{ github.event.pull_request.base.repo.name }}
|
|
|
|
- name: Post Validation Comment
|
|
if: steps.validate.outputs.validation_error == 'true'
|
|
run: python .github/scripts/validate_pr_formatting.py --post-comment
|
|
env:
|
|
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
|
|
PR_NUMBER: ${{ github.event.number }}
|
|
|
|
- name: Check for Validation Errors
|
|
if: steps.validate.outputs.validation_error == 'true'
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
core.setFailed('PR Formatting Validation Check Failed!')
|