Skip to content

Commit 9963f86

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 9963f86

File tree

1 file changed

+46
-14
lines changed

1 file changed

+46
-14
lines changed

.github/workflows/format_check.yml

Lines changed: 46 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,80 @@ 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+
any_changed: ${{ steps.changed-files.outputs.any_changed }}
29+
core_any_changed: ${{ steps.changed-files.outputs.core_any_changed }}
30+
loader_any_changed: ${{ steps.changed-files.outputs.loader_any_changed }}
31+
libraries_any_changed: ${{ steps.changed-files.outputs.libraries_any_changed }}
32+
steps:
33+
- name: Get changed source files
34+
id: changed-files
35+
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
36+
with:
37+
files_yaml: |
38+
core:
39+
- cores/arduino/**/*.{c,cpp,h,hpp}
40+
- '!cores/arduino/api/**'
41+
loader:
42+
- loader/**/*.{c,cpp,h,hpp}
43+
- '!loader/llext_exports.c'
44+
libraries:
45+
- libraries/**/*.{c,cpp,h,hpp}
46+
- '!libraries/examples/**'
47+
- '!libraries/extras/**'
48+
- '!libraries/ea_malloc/**'
49+
3550
format-check:
3651
runs-on: ubuntu-latest
52+
needs:
53+
- filter-format-check
54+
if: needs.filter-format-check.outputs.any_changed == 'true'
3755
strategy:
3856
matrix:
3957
path:
40-
- check: 'cores/arduino/'
58+
- name: 'core'
59+
check: 'cores/arduino/'
4160
exclude: 'cores/arduino/api/'
42-
- check: 'loader/'
61+
- name: 'loader'
62+
check: 'loader/'
4363
exclude: 'loader/llext_exports\.c$'
44-
- check: 'libraries/'
64+
- name: 'libraries'
65+
check: 'libraries/'
4566
exclude: '(examples|extras|ea_malloc)'
4667
fail-fast: false
4768

4869
steps:
4970
- name: Checkout code
71+
if: needs.filter-format-check.outputs[format('{0}_any_changed', matrix.path['name'])] == 'true'
5072
uses: actions/checkout@v4
5173
with:
5274
submodules: false
5375
persist-credentials: false
5476

5577
- name: Run clang-format check
78+
if: needs.filter-format-check.outputs[format('{0}_any_changed', matrix.path['name'])] == 'true'
5679
uses: jidicula/[email protected]
5780
with:
5881
clang-format-version: '19'
5982
check-path: ${{ matrix.path['check'] }}
6083
exclude-regex: ${{ matrix.path['exclude'] }}
84+
85+
verify-format:
86+
runs-on: ubuntu-latest
87+
if: cancelled() || contains(needs.*.result, 'failure')
88+
needs:
89+
- format-check
90+
steps:
91+
- name: Notify failure
92+
run: exit 1

0 commit comments

Comments
 (0)