github: optimize style workflow
Only fetch the commits we need instead of fetching the entire history. Unfortunately there doesn't seem to be a way to add 1 to the number of commits without an extra step, so do it in a new step and pass the information onto $GITHUB_ENV so it can be used later. Signed-off-by: Ahmad Khalifa <ahmadkhalifa570@gmail.com> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1538
This commit is contained in:
committed by
Warner Losh
parent
db512bb303
commit
e0231d3cd3
@@ -1,10 +1,6 @@
|
|||||||
name: Style Checker
|
name: Style Checker
|
||||||
|
|
||||||
# Runs my simple style(9) checker on any pushes or pull requests. It could be
|
# Runs my simple style(9) checker on pull requests.
|
||||||
# optimized by fetching the pull request head branch back to main revisions and
|
|
||||||
# running on that. That would reduce the run time from 3-4 minutes down to 30-40
|
|
||||||
# seconds. Getting the right series of clone + fetches to get that iteratively
|
|
||||||
# is proving elusive, so optimizations welcome.
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request: # maybe pull_request_target
|
pull_request: # maybe pull_request_target
|
||||||
@@ -19,10 +15,15 @@ jobs:
|
|||||||
name: Style Checker
|
name: Style Checker
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
# Unfortunately there doesn't seem to be a way to
|
||||||
|
# do this without an extra step.
|
||||||
|
- name: Get depth
|
||||||
|
run: |
|
||||||
|
echo "DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> $GITHUB_ENV
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: ${{ env.DEPTH }}
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
- name: Install packages
|
- name: Install packages
|
||||||
run: |
|
run: |
|
||||||
@@ -30,5 +31,5 @@ jobs:
|
|||||||
sudo apt-get -yq --no-install-suggests --no-install-recommends install perl
|
sudo apt-get -yq --no-install-suggests --no-install-recommends install perl
|
||||||
- name: Run checker
|
- name: Run checker
|
||||||
run: |
|
run: |
|
||||||
sha=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
|
sha=$(git rev-parse HEAD~${{ github.event.pull_request.commits }})
|
||||||
tools/build/checkstyle9.pl --github ${sha}..${{ github.event.pull_request.head.sha }}
|
tools/build/checkstyle9.pl --github ${sha}..${{ github.event.pull_request.head.sha }}
|
||||||
|
|||||||
Reference in New Issue
Block a user