xref: /freebsd/.github/workflows/style.yml (revision b64c5a0ace59af62eff52bfe110a521dc73c937b)
1name: Style Checker
2
3# Runs my simple style(9) checker on pull requests.
4
5on:
6  pull_request: # maybe pull_request_target
7    branches: [ main ]
8    types: [ opened, reopened, edited, synchronize ]
9    paths: [ '**.S', '**.c', '**.cc', '**.cpp', '**.h', '**.hh', '**.hpp' ]
10
11permissions:
12  contents: read
13
14jobs:
15  build:
16    name: Style Checker
17    runs-on: ubuntu-latest
18    steps:
19      # Unfortunately there doesn't seem to be a way to
20      # do this without an extra step.
21      - name: Get depth
22        run: |
23          echo "DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> $GITHUB_ENV
24      - name: checkout
25        uses: actions/checkout@v4
26        with:
27          fetch-depth: ${{ env.DEPTH }}
28          ref: ${{ github.event.pull_request.head.sha }}
29      - name: Install packages
30        run: |
31          sudo apt-get update --quiet || true
32          sudo apt-get -yq --no-install-suggests --no-install-recommends install perl
33      - name: Run checker
34        run: |
35          sha=$(git rev-parse HEAD~${{ github.event.pull_request.commits }})
36          tools/build/checkstyle9.pl --github ${sha}..${{ github.event.pull_request.head.sha }}
37