Skip to content

Commit d71ffad

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 d71ffad

File tree

1 file changed

+50
-14
lines changed

1 file changed

+50
-14
lines changed

.github/workflows/format_check.yml

Lines changed: 50 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,84 @@ 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:
4974
- name: Checkout code
75+
if: needs.filter-format-check.outputs[format('{0}_any_changed', matrix.path['name'])] == 'true'
5076
uses: actions/checkout@v4
5177
with:
5278
submodules: false
5379
persist-credentials: false
5480

5581
- name: Run clang-format check
82+
if: needs.filter-format-check.outputs[format('{0}_any_changed', matrix.path['name'])] == 'true'
5683
uses: jidicula/[email protected]
5784
with:
5885
clang-format-version: '19'
5986
check-path: ${{ matrix.path['check'] }}
6087
exclude-regex: ${{ matrix.path['exclude'] }}
88+
89+
verify-format:
90+
runs-on: ubuntu-latest
91+
if: cancelled() || contains(needs.*.result, 'failure')
92+
needs:
93+
- format-check
94+
steps:
95+
- name: Notify failure
96+
run: exit 1

0 commit comments

Comments
 (0)