1name: Verify code formatting
2on:
3  push:
4  pull_request:
5
6jobs:
7  verify-formatting:
8    if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
9    runs-on: ubuntu-latest
10    steps:
11      - name: Checkout
12        uses: actions/checkout@v4
13        with:
14          persist-credentials: false
15          fetch-depth: 0
16      - name: Checkout astyle
17        uses: actions/checkout@v4
18        with:
19          repository: szepeviktor/astyle
20          path: astyle
21          ref: v3.4.12
22      - name: Install astyle
23        run: |
24          cd astyle/build/gcc/
25          make
26          sudo make install
27          astyle --version
28      - name: Format code
29        run: python code-format.py
30        working-directory: scripts
31      - name: Check that repository is clean
32        shell: bash
33        run: |
34          set -o pipefail
35          if ! (git diff --exit-code --color=always | tee /tmp/lvgl_diff.patch); then
36            echo "Please apply the preceding diff to your code or run scripts/code-format.py"
37            exit 1
38          fi
39