aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows
diff options
context:
space:
mode:
authorAhmad Khalifa <ahmadkhalifa570@gmail.com>2024-12-01 13:42:53 +0000
committerWarner Losh <imp@FreeBSD.org>2024-12-06 00:59:51 +0000
commite0231d3cd363bb33142270315aa817977b632910 (patch)
tree65ae269f7298d000fc977c45309c00828c6fd128 /.github/workflows
parentdb512bb30314326a0b2cfad3f9094dd830744777 (diff)
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
Diffstat (limited to '.github/workflows')
-rw-r--r--.github/workflows/style.yml15
1 files changed, 8 insertions, 7 deletions
diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml
index 08d4242df5ed..0e7c1d8ca6d8 100644
--- a/.github/workflows/style.yml
+++ b/.github/workflows/style.yml
@@ -1,10 +1,6 @@
name: Style Checker
-# Runs my simple style(9) checker on any pushes or pull requests. It could be
-# 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.
+# Runs my simple style(9) checker on pull requests.
on:
pull_request: # maybe pull_request_target
@@ -19,10 +15,15 @@ jobs:
name: Style Checker
runs-on: ubuntu-latest
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
uses: actions/checkout@v4
with:
- fetch-depth: 0
+ fetch-depth: ${{ env.DEPTH }}
ref: ${{ github.event.pull_request.head.sha }}
- name: Install packages
run: |
@@ -30,5 +31,5 @@ jobs:
sudo apt-get -yq --no-install-suggests --no-install-recommends install perl
- name: Run checker
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 }}