clang-format: add lint job and update run script

Update clang-format script to only run on files that are passing the
formatter, that way the clang-format script is useable by CI and
contributors.
This commit is contained in:
Ryan Turner 2025-09-10 13:24:49 -05:00 committed by Silvano Seva
parent 28fe4eb9e1
commit 74e89450b7
4 changed files with 80 additions and 9 deletions

20
.github/workflows/format.yml vendored Normal file
View File

@ -0,0 +1,20 @@
name: "Format sources"
on:
workflow_dispatch:
push:
pull_request:
jobs:
clang-format:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: install-deps
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Check if there are format errors
run: ./scripts/clang_format.sh --check

View File

@ -11,22 +11,29 @@ on:
jobs: jobs:
check-symbol-generation: check-symbol-generation:
runs-on: ubuntu-22.04 runs-on: ubuntu-24.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
submodules: recursive submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: install-deps - name: install-deps
run: | run: |
sudo apt update sudo apt update
sudo apt install python3 python3-pip sudo apt install ffmpeg clang-format
- name: Setup symbols script dependencies - name: Setup symbols script dependencies
run: | run: |
cd ${{github.workspace}} cd ${{github.workspace}}
pip3 install --upgrade pip
pip3 install -r requirements.txt pip3 install -r requirements.txt
- name: Run symbols script - name: Run symbols script and then format the output
run: ./scripts/generate_symbols.py run: |
./scripts/generate_symbols.py
./scripts/clang_format.sh
- name: Fail the build if there are changes generated - name: Fail the build if there are changes generated
run: | run: |
git --no-pager diff git --no-pager diff

View File

@ -1,5 +1,6 @@
pyusb setuptools>=68.0.0
meson pyusb>=1.2.1
meson>=1.2.0
ffmpeg ffmpeg
cairosvg==2.7.1 cairosvg>=2.7.1
numpy==1.25.2 numpy>=1.25.2

View File

@ -42,7 +42,50 @@ if [ $# -eq 1 ]; then
fi fi
fi fi
FILE_LIST=$(git ls-files | egrep '\.(c|cpp|h)$' | egrep -v 'lib/|subprojects/|platform/mcu') # FILE_LIST=$(git ls-files | egrep '\.(c|cpp|h)$' | egrep -v 'lib/|subprojects/|platform/mcu')
# TODO: This is temporarily running on a subset of the repo while we "ratchet up"
# the codebase; see https://github.com/OpenRTX/OpenRTX/issues/346
#
# Hey you! Have a new source file, or one that you've made changes to? Add it to
# the list below to enforce the new formatting.
FILE_LIST=$(cat <<-EOF
openrtx/include/core/audio_codec.h
openrtx/include/core/battery.h
openrtx/include/core/beeps.h
openrtx/include/core/crc.h
openrtx/include/core/data_conversion.h
openrtx/include/core/datatypes.h
openrtx/include/core/memory_profiling.h
openrtx/include/core/openrtx.h
openrtx/include/core/ui.h
openrtx/include/core/utils.h
openrtx/include/core/xmodem.h
openrtx/include/fonts/symbols/symbols.h
openrtx/include/interfaces/cps_io.h
openrtx/include/interfaces/delays.h
openrtx/include/interfaces/display.h
openrtx/include/interfaces/radio.h
openrtx/include/peripherals/gps.h
openrtx/include/peripherals/rng.h
openrtx/include/peripherals/rtc.h
openrtx/src/core/memory_profiling.cpp
platform/drivers/ADC/ADC0_GDx.h
platform/drivers/audio/MAX9814.h
platform/drivers/baseband/MCP4551.h
platform/drivers/baseband/SA8x8.h
platform/drivers/chSelector/chSelector.h
platform/drivers/display/SH110x_Mod17.h
platform/drivers/display/SSD1306_Mod17.h
platform/drivers/display/SSD1309_Mod17.h
platform/drivers/GPIO/gpio-native.h
platform/drivers/GPS/gps_stm32.h
platform/drivers/GPS/gps_zephyr.h
platform/drivers/USB/usb.h
platform/targets/GDx/hwconfig.h
platform/targets/linux/emulator/sdl_engine.h
platform/targets/ttwrplus/pmu.h
EOF
)
CHECK_ARGS="" CHECK_ARGS=""
if [ "$1" == "--check" ]; then if [ "$1" == "--check" ]; then