Skip to content

Commit 491a8c6

Browse files
committed
format-check: rework to test modified files only
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. Rework the format-check workflow to first list the modified files that need to be checked, and then run the check only on those files. This way the test runs on every pull request, but has minimal impact unless one or more source files are actually modified. Requires a branched version of jidicula/clang-format-action 4.15.0 that adds the 'check-files-from' input parameter. Signed-off-by: Luca Burelli <[email protected]>
1 parent a26551e commit 491a8c6

File tree

1 file changed

+22
-33
lines changed

1 file changed

+22
-33
lines changed

.github/workflows/format_check.yml

Lines changed: 22 additions & 33 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,37 @@ on:
1813
- synchronize
1914
branches:
2015
- 'main'
21-
paths:
22-
- '**/*.c'
23-
- '**/*.cpp'
24-
- '**/*.h'
25-
- '**/*.hpp'
26-
27-
workflow_dispatch:
28-
inputs:
29-
logLevel:
30-
description: 'Log level'
31-
required: true
32-
default: 'warning'
3316

3417
jobs:
35-
format-check:
18+
verify-format:
3619
runs-on: ubuntu-latest
37-
strategy:
38-
matrix:
39-
path:
40-
- check: 'cores/arduino/'
41-
exclude: 'cores/arduino/api/'
42-
- check: 'loader/'
43-
exclude: 'loader/llext_exports\.c$'
44-
- check: 'libraries/'
45-
exclude: '(examples|extras|ea_malloc)'
46-
fail-fast: false
47-
4820
steps:
4921
- name: Checkout code
5022
uses: actions/checkout@v4
5123
with:
5224
submodules: false
5325
persist-credentials: false
54-
26+
- name: Get changed source files that need format check
27+
id: changed-files
28+
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
29+
with:
30+
files: |
31+
cores/arduino/**/*.{c,cpp,h,hpp,ino}
32+
loader/**/*.{c,cpp,h,hpp,ino}
33+
libraries/**/*.{c,cpp,h,hpp,ino}
34+
files_ignore: |
35+
cores/arduino/api/**
36+
loader/llext_exports.c
37+
libraries/examples/**
38+
libraries/extras/**
39+
libraries/ea_malloc/**
40+
write_output_files: true
41+
- name: List changed files
42+
if: steps.changed-files.outputs.any_changed == 'true'
43+
run: cat .github/outputs/all_changed_files.txt
5544
- name: Run clang-format check
56-
uses: jidicula/[email protected]
45+
if: steps.changed-files.outputs.any_changed == 'true'
46+
uses: pillo79/clang-format-action@05f671e71f0758aba4d3c9dbb0ee81bc5f0137c6
5747
with:
5848
clang-format-version: '19'
59-
check-path: ${{ matrix.path['check'] }}
60-
exclude-regex: ${{ matrix.path['exclude'] }}
49+
check-files-from: .github/outputs/all_changed_files.txt

0 commit comments

Comments
 (0)