xref: /freebsd/.github/workflows/style.yml (revision 3fb8f1272b50cb87cb624b321f7b81e76627c437)
1name: Style Checker
2
3# Runs my simple style(9) checker on any pushes or pull requests.  It could be
4# optimized by fetching the pull request head branch back to main revisions and
5# running on that. That would reduce the run time from 3-4 minutes down to 30-40
6# seconds. Getting the right series of clone + fetches to get that iteratively
7# is proving elusive, so optimizations welcome.
8
9on:
10  pull_request: # maybe pull_request_target
11    branches: [ main ]
12    types: [ opened, reopened, edited, synchronize ]
13
14permissions:
15  contents: read
16
17jobs:
18  build:
19    name: Style Checker
20    runs-on: ubuntu-latest
21    steps:
22      - name: checkout
23        uses: actions/checkout@v4
24        with:
25          fetch-depth: 0
26          ref: ${{ github.event.pull_request.head.sha }}
27      - name: Install packages
28        run: |
29          sudo apt-get update --quiet || true
30          sudo apt-get -yq --no-install-suggests --no-install-recommends install perl
31      - name: Run checker
32        run: |
33          sha=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
34          tools/build/checkstyle9.pl --github ${sha}..${{ github.event.pull_request.head.sha }}
35