Skip to content

Optimize fetch

Optimize fetch #62

Workflow file for this run

## @file
# Run PatchCheck on all commits in a pull request
#
# Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
name: PatchCheck
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]
branches:
- CiEnabled
env:
RunPatchCheck: True
PatchCheckOptions: ''
jobs:
patchcheck:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: IsLabel
if: ${{ contains(fromJSON('["labeled", "unlabeled"]'), github.event.action) && (github.event.label.name != 'ignore-multi-package') }}
run: echo "RunPatchCheck=False" >> $GITHUB_ENV
- name: IsIgnoreMultiPackage
if: ${{ env.RunPatchCheck == 'True' && contains(github.event.pull_request.labels.*.name, 'ignore-multi-package')}}
run: echo "PatchCheckOptions=--ignore-multi-package" >> $GITHUB_ENV
- name: Install Python
if: ${{ env.RunPatchCheck == 'True' }}
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Fetch Depth
if: ${{ env.RunPatchCheck == 'True' }}
run: echo "FetchDepth=$((${{ github.event.pull_request.commits }} + 1))" >> $GITHUB_ENV
- name: Fetch PR
if: ${{ env.RunPatchCheck == 'True' }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.FetchDepth }}
sparse-checkout: |
pip-requirements.txt
BaseTools/Scripts/PatchCheck.py
- name: Checkout Base
if: ${{ env.RunPatchCheck == 'True' }}
run: git checkout ${{ github.event.pull_request.base.sha }}
- name: Install Python Dependencies
if: ${{ env.RunPatchCheck == 'True' }}
run: pip install -r pip-requirements.txt
- name: PatchCheck
if: ${{ env.RunPatchCheck == 'True' }}
run: python BaseTools/Scripts/PatchCheck.py ${{ env.PatchCheckOptions }} ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }}..