Skip to content

Format check #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
31 changes: 0 additions & 31 deletions .github/workflows/checkpatch.yml

This file was deleted.

69 changes: 69 additions & 0 deletions .github/workflows/format_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: 'Format Check'

on:
push:
branches:
- 'main'
paths:
- '**/*.{c,cpp,cc,cxx,h,hpp}'

pull_request:
types:
- opened
- edited
- reopened
- synchronize
branches:
- 'main'
paths:
- '**/*.{c,cpp,cc,cxx,h,hpp}'

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

jobs:
format-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: false
persist-credentials: false

- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v46
with:
files: |
cores/arduino/**/*.{c,cpp,cc,cxx,h,hpp}
!cores/arduino/api/**
loader/**/*.{c,cpp,cc,cxx,h,hpp}
!loader/llext_exports.c
libraries/**/*.{c,cpp,cc,cxx,h,hpp}

- name: Run clang-format check
if: steps.changed-files.outputs.any_changed == 'true'
run: |
exit_code=0

for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
file_fmt="${file}.tmp"
clang-format ${file} > ${file_fmt}
diff -q -u ${file} ${file_fmt} >> /dev/null 2>&1 || {
echo "❌ Formatting issues found in: $file"
colordiff -u ${file} ${file_fmt} || true
exit_code=1
}
done

exit $exit_code