summaryrefslogtreecommitdiff
path: root/.github/workflows/lint.yml
blob: b459973afa8c0d0ab6c66845198d0c4285581416 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: PR Lint keyboards

on:
  pull_request:
    paths:
    - 'keyboards/**'

jobs:
  lint:
    runs-on: ubuntu-latest

    container: qmkfm/base_container

    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0

    - uses: trilom/file-changes-action@v1.2.4
      id: file_changes
      with:
        output: '\n'

    - name: Print info
      run: |
        git rev-parse --short HEAD
        echo ${{ github.event.pull_request.base.sha }}
        echo '${{ steps.file_changes.outputs.files}}'

    - name: Run qmk lint
      shell: 'bash {0}'
      run: |
        QMK_CHANGES=$(echo -e '${{ steps.file_changes.outputs.files}}')
        QMK_KEYBOARDS=$(qmk list-keyboards)

        exit_code=0
        for KB in $QMK_KEYBOARDS; do
          KEYBOARD_CHANGES=$(echo "$QMK_CHANGES" | grep -E '^(keyboards/'${KB}'/)')
          if [[ -z "$KEYBOARD_CHANGES" ]]; then
            # skip as no changes for this keyboard
            continue
          fi

          KEYMAP_ONLY=$(echo "$KEYBOARD_CHANGES" | grep -cv /keymaps/)
          if [[ $KEYMAP_ONLY -gt 0 ]]; then
            echo "linting ${KB}"

            qmk lint --keyboard ${KB} && qmk info -l --keyboard ${KB}
          fi
        done
        exit $exit_code