Skip to content

Commit 9701d86

Browse files
committed
format-check: add collect errors job
The Github UI for required checks does not integrate with the workflows described in the .github directory. Currently jobs that are never started due to conditional execution are not even reported, so the UI shows "expected" and locks up merges. Collect format errors so that the Github UI can be happy to track one job that is always executed. This job will fail if any of the format-check jobs failed or were cancelled, and will be ignored (but reported) otherwise. Signed-off-by: Luca Burelli <[email protected]>
1 parent a26551e commit 9701d86

File tree

1 file changed

+56
-14
lines changed

1 file changed

+56
-14
lines changed

.github/workflows/format_check.yml

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ on:
44
push:
55
branches:
66
- 'main'
7-
paths:
8-
- '**/*.c'
9-
- '**/*.cpp'
10-
- '**/*.h'
11-
- '**/*.hpp'
127

138
pull_request:
149
types:
@@ -18,43 +13,90 @@ on:
1813
- synchronize
1914
branches:
2015
- 'main'
21-
paths:
22-
- '**/*.c'
23-
- '**/*.cpp'
24-
- '**/*.h'
25-
- '**/*.hpp'
2616

2717
workflow_dispatch:
2818
inputs:
2919
logLevel:
30-
description: 'Log level'
20+
description: 'Log level'
3121
required: true
3222
default: 'warning'
3323

3424
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+
3555
format-check:
3656
runs-on: ubuntu-latest
57+
needs:
58+
- filter-format-check
3759
strategy:
3860
matrix:
3961
path:
40-
- check: 'cores/arduino/'
62+
- name: 'core'
63+
check: 'cores/arduino/'
4164
exclude: 'cores/arduino/api/'
42-
- check: 'loader/'
65+
- name: 'loader'
66+
check: 'loader/'
4367
exclude: 'loader/llext_exports\.c$'
44-
- check: 'libraries/'
68+
- name: 'libraries'
69+
check: 'libraries/'
4570
exclude: '(examples|extras|ea_malloc)'
4671
fail-fast: false
4772

4873
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+
4980
- name: Checkout code
81+
if: needs.filter-format-check.outputs.${{ matrix.path['name'] }}_any_changed == 'true'
5082
uses: actions/checkout@v4
5183
with:
5284
submodules: false
5385
persist-credentials: false
5486

5587
- name: Run clang-format check
88+
if: needs.filter-format-check.outputs.${{ matrix.path['name'] }}_any_changed == 'true'
5689
uses: jidicula/[email protected]
5790
with:
5891
clang-format-version: '19'
5992
check-path: ${{ matrix.path['check'] }}
6093
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

Comments
 (0)