summaryrefslogtreecommitdiffstats
path: root/.github/workflows/format.yaml
blob: 9415861eaa7a24bb2082578699c1c98330117f38 (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
52
name: PR Lint Format

on:
  pull_request:
    paths:
    - 'drivers/**'
    - 'lib/arm_atsam/**'
    - 'lib/lib8tion/**'
    - 'lib/python/**'
    - 'platforms/**'
    - 'quantum/**'
    - 'tests/**'
    - 'tmk_core/**'

jobs:
  lint:
    runs-on: ubuntu-latest

    container: qmkfm/qmk_cli

    steps:
    - name: Install dependencies
      run: |
        apt-get update && apt-get install -y dos2unix
        pip3 install -r requirements-dev.txt

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

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

    - name: Run qmk formatters
      shell: 'bash {0}'
      run: |
        cat ~/files_added.txt ~/files_modified.txt > ~/files_changed.txt
        qmk format-c --core-only $(< ~/files_changed.txt) || true
        qmk format-python $(< ~/files_changed.txt) || true
        qmk format-text $(< ~/files_changed.txt) || true

    - name: Fail when formatting required
      run: |
        git diff
        for file in $(git diff --name-only); do
          echo "File '${file}' Requires Formatting"
          echo "::error file=${file}::Requires Formatting"
        done
        test -z "$(git diff --name-only)"