|
4 | 4 | push:
|
5 | 5 | branches:
|
6 | 6 | - 'main'
|
7 |
| - paths: |
8 |
| - - '**/*.c' |
9 |
| - - '**/*.cpp' |
10 |
| - - '**/*.h' |
11 |
| - - '**/*.hpp' |
12 | 7 |
|
13 | 8 | pull_request:
|
14 | 9 | types:
|
|
18 | 13 | - synchronize
|
19 | 14 | branches:
|
20 | 15 | - 'main'
|
21 |
| - paths: |
22 |
| - - '**/*.c' |
23 |
| - - '**/*.cpp' |
24 |
| - - '**/*.h' |
25 |
| - - '**/*.hpp' |
26 | 16 |
|
27 | 17 | workflow_dispatch:
|
28 | 18 | inputs:
|
29 | 19 | logLevel:
|
30 |
| - description: 'Log level' |
| 20 | + description: 'Log level' |
31 | 21 | required: true
|
32 | 22 | default: 'warning'
|
33 | 23 |
|
34 | 24 | jobs:
|
| 25 | + filter-format-check: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + outputs: |
| 28 | + core_any_changed: ${{ steps.changed-files.outputs.core_any_changed }} |
| 29 | + loader_any_changed: ${{ steps.changed-files.outputs.loader_any_changed }} |
| 30 | + libraries_any_changed: ${{ steps.changed-files.outputs.libraries_any_changed }} |
| 31 | + steps: |
| 32 | + - name: Get changed source files |
| 33 | + id: changed-files |
| 34 | + uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5 |
| 35 | + with: |
| 36 | + files_yaml: | |
| 37 | + core: |
| 38 | + - cores/arduino/**/*.{c,cpp,h,hpp} |
| 39 | + - '!cores/arduino/api/**' |
| 40 | + loader: |
| 41 | + - loader/**/*.{c,cpp,h,hpp} |
| 42 | + - '!loader/llext_exports.c' |
| 43 | + libraries: |
| 44 | + - libraries/**/*.{c,cpp,h,hpp} |
| 45 | + - '!libraries/examples/**' |
| 46 | + - '!libraries/extras/**' |
| 47 | + - '!libraries/ea_malloc/**' |
| 48 | +
|
| 49 | + - name: Output changed files |
| 50 | + run: | |
| 51 | + echo "Core changed: ${{ steps.changed-files.outputs.core_any_changed }}" |
| 52 | + echo "Loader changed: ${{ steps.changed-files.outputs.loader_any_changed }}" |
| 53 | + echo "Libraries changed: ${{ steps.changed-files.outputs.libraries_any_changed }}" |
| 54 | +
|
35 | 55 | format-check:
|
36 | 56 | runs-on: ubuntu-latest
|
| 57 | + needs: |
| 58 | + - filter-format-check |
37 | 59 | strategy:
|
38 | 60 | matrix:
|
39 | 61 | path:
|
40 |
| - - check: 'cores/arduino/' |
| 62 | + - name: 'core' |
| 63 | + check: 'cores/arduino/' |
41 | 64 | exclude: 'cores/arduino/api/'
|
42 |
| - - check: 'loader/' |
| 65 | + - name: 'loader' |
| 66 | + check: 'loader/' |
43 | 67 | exclude: 'loader/llext_exports\.c$'
|
44 |
| - - check: 'libraries/' |
| 68 | + - name: 'libraries' |
| 69 | + check: 'libraries/' |
45 | 70 | exclude: '(examples|extras|ea_malloc)'
|
46 | 71 | fail-fast: false
|
47 | 72 |
|
48 | 73 | steps:
|
| 74 | + - name: Print conditions |
| 75 | + run: | |
| 76 | + echo "Matrix path name: ${{ matrix.path['name'] }}" |
| 77 | + echo "Any changes: ${{ needs.filter-format-check.outputs[format('{0}_any_changed', matrix.path['name'])] }}" |
| 78 | + echo "Schifo: ${{ needs.filter-format-check.outputs.${{ matrix.path['name'] }}_any_changed }}" |
| 79 | +
|
49 | 80 | - name: Checkout code
|
| 81 | + if: needs.filter-format-check.outputs.${{ matrix.path['name'] }}_any_changed == 'true' |
50 | 82 | uses: actions/checkout@v4
|
51 | 83 | with:
|
52 | 84 | submodules: false
|
53 | 85 | persist-credentials: false
|
54 | 86 |
|
55 | 87 | - name: Run clang-format check
|
| 88 | + if: needs.filter-format-check.outputs.${{ matrix.path['name'] }}_any_changed == 'true' |
56 | 89 |
|
57 | 90 | with:
|
58 | 91 | clang-format-version: '19'
|
59 | 92 | check-path: ${{ matrix.path['check'] }}
|
60 | 93 | exclude-regex: ${{ matrix.path['exclude'] }}
|
| 94 | + |
| 95 | + verify-format: |
| 96 | + runs-on: ubuntu-latest |
| 97 | + if: cancelled() || contains(needs.*.result, 'failure') |
| 98 | + needs: |
| 99 | + - format-check |
| 100 | + steps: |
| 101 | + - name: Notify failure |
| 102 | + run: exit 1 |
0 commit comments