Skip to content

Commit 772fde1

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 772fde1

File tree

1 file changed

+48
-14
lines changed

1 file changed

+48
-14
lines changed

.github/workflows/format_check.yml

Lines changed: 48 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,82 @@ 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+
any_changed: ${{ steps.changed-files.outputs.core_any_changed == 'true' ||
32+
steps.changed-files.outputs.loader_any_changed == 'true' ||
33+
steps.changed-files.outputs.libraries_any_changed == 'true' }}
34+
steps:
35+
- name: Get changed source files
36+
id: changed-files
37+
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
38+
with:
39+
files_yaml: |
40+
core:
41+
- cores/arduino/**/*.{c,cpp,h,hpp}
42+
- '!cores/arduino/api/**'
43+
loader:
44+
- loader/**/*.{c,cpp,h,hpp}
45+
- '!loader/llext_exports.c'
46+
libraries:
47+
- libraries/**/*.{c,cpp,h,hpp}
48+
- '!libraries/examples/**'
49+
- '!libraries/extras/**'
50+
- '!libraries/ea_malloc/**'
51+
3552
format-check:
3653
runs-on: ubuntu-latest
54+
needs:
55+
- filter-format-check
56+
if: needs.filter-format-check.outputs.any_changed
3757
strategy:
3858
matrix:
3959
path:
40-
- check: 'cores/arduino/'
60+
- name: 'core'
61+
check: 'cores/arduino/'
4162
exclude: 'cores/arduino/api/'
42-
- check: 'loader/'
63+
- name: 'loader'
64+
check: 'loader/'
4365
exclude: 'loader/llext_exports\.c$'
44-
- check: 'libraries/'
66+
- name: 'libraries'
67+
check: 'libraries/'
4568
exclude: '(examples|extras|ea_malloc)'
4669
fail-fast: false
4770

4871
steps:
4972
- name: Checkout code
73+
if: needs.filter-format-check.outputs[format('{0}_any_changed', matrix.path['name'])] == 'true'
5074
uses: actions/checkout@v4
5175
with:
5276
submodules: false
5377
persist-credentials: false
5478

5579
- name: Run clang-format check
80+
if: needs.filter-format-check.outputs[format('{0}_any_changed', matrix.path['name'])] == 'true'
5681
uses: jidicula/[email protected]
5782
with:
5883
clang-format-version: '19'
5984
check-path: ${{ matrix.path['check'] }}
6085
exclude-regex: ${{ matrix.path['exclude'] }}
86+
87+
verify-format:
88+
runs-on: ubuntu-latest
89+
if: cancelled() || contains(needs.*.result, 'failure')
90+
needs:
91+
- format-check
92+
steps:
93+
- name: Notify failure
94+
run: exit 1

0 commit comments

Comments
 (0)