Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 22 additions & 33 deletions .github/workflows/format_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ on:
push:
branches:
- 'main'
paths:
- '**/*.c'
- '**/*.cpp'
- '**/*.h'
- '**/*.hpp'

pull_request:
types:
Expand All @@ -18,43 +13,37 @@ on:
- synchronize
branches:
- 'main'
paths:
- '**/*.c'
- '**/*.cpp'
- '**/*.h'
- '**/*.hpp'

workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'

jobs:
format-check:
verify-format:
runs-on: ubuntu-latest
strategy:
matrix:
path:
- check: 'cores/arduino/'
exclude: 'cores/arduino/api/'
- check: 'loader/'
exclude: 'loader/llext_exports\.c$'
- check: 'libraries/'
exclude: '(examples|extras|ea_malloc)'
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: false
persist-credentials: false

- name: Get changed source files that need format check
id: changed-files

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is okay, but is running the formatter on all PRs unconditionally that bad? Most of the PRs will likely contain code changes anyway.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the original idea of limiting the execution to PRs that needed it. Not a problem right now, but PRs being blocked due to compliance on unrelated files is so much of an issue in Zephyr proper that they don't enable this kind of filters 🙂

uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
with:
files: |
cores/arduino/**/*.{c,cpp,h,hpp,ino}
loader/**/*.{c,cpp,h,hpp,ino}
libraries/**/*.{c,cpp,h,hpp,ino}
files_ignore: |
cores/arduino/api/**
loader/llext_exports.c
libraries/examples/**
libraries/extras/**
libraries/ea_malloc/**
write_output_files: true
- name: List changed files
if: steps.changed-files.outputs.any_changed == 'true'
run: cat .github/outputs/all_changed_files.txt
- name: Run clang-format check
uses: jidicula/[email protected]
if: steps.changed-files.outputs.any_changed == 'true'
uses: pillo79/clang-format-action@05f671e71f0758aba4d3c9dbb0ee81bc5f0137c6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this is now needed for the action to work with these changes? Kind of an issue if your changes don't make it upstream.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is required for the check-files-from parameter. Very odd that the original action requires a folder and then does a find to list files and runs clang-format on each, but did not support specifying the files directly 🙂
There's also a bug that prevents showing the expected changes on the error annotation as expected, so I added them back.
The project looks active and maintained so I'm pretty sure this can be merged, especially if we show it in use.

with:
clang-format-version: '19'
check-path: ${{ matrix.path['check'] }}
exclude-regex: ${{ matrix.path['exclude'] }}
check-files-from: .github/outputs/all_changed_files.txt
1 change: 0 additions & 1 deletion .github/workflows/package_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ jobs:
failOnError: false

verify-core:
name: Collect job errors
Copy link

@iabdalkader iabdalkader Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an FYI this works too: name: verify-core. I guess you could also quote the name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's the same. I hate that GH matches the actual string generated by the job and not some unmistakable ID. At least in the UI it verify-core looks clearer now as a requirement.

runs-on: ubuntu-latest
if: cancelled() || contains(needs.*.result, 'failure')
needs:
Expand Down