Skip to content

Commit 9cff1f3

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 9cff1f3

File tree

1 file changed

+45
-14
lines changed

1 file changed

+45
-14
lines changed

.github/workflows/format_check.yml

Lines changed: 45 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,79 @@ 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+
3549
format-check:
3650
runs-on: ubuntu-latest
51+
needs:
52+
- filter-format-check
3753
strategy:
3854
matrix:
3955
path:
40-
- check: 'cores/arduino/'
56+
- name: 'core'
57+
check: 'cores/arduino/'
4158
exclude: 'cores/arduino/api/'
42-
- check: 'loader/'
59+
- name: 'loader'
60+
check: 'loader/'
4361
exclude: 'loader/llext_exports\.c$'
44-
- check: 'libraries/'
62+
- name: 'libraries'
63+
check: 'libraries/'
4564
exclude: '(examples|extras|ea_malloc)'
4665
fail-fast: false
4766

4867
steps:
4968
- name: Checkout code
69+
if: needs.filter-format-check.outputs.${{ matrix.path['name'] }}_any_changed == 'true'
5070
uses: actions/checkout@v4
5171
with:
5272
submodules: false
5373
persist-credentials: false
5474

5575
- name: Run clang-format check
76+
if: needs.filter-format-check.outputs.${{ matrix.path['name'] }}_any_changed == 'true'
5677
uses: jidicula/[email protected]
5778
with:
5879
clang-format-version: '19'
5980
check-path: ${{ matrix.path['check'] }}
6081
exclude-regex: ${{ matrix.path['exclude'] }}
82+
83+
verify-format:
84+
name: Collect job errors
85+
runs-on: ubuntu-latest
86+
if: cancelled() || contains(needs.*.result, 'failure')
87+
needs:
88+
- format-check
89+
steps:
90+
- name: Notify failure
91+
run: exit 1

0 commit comments

Comments
 (0)