Skip to content

Commit

Permalink
update to clang-format v14; update pre-commit hooks (#6)
Browse files Browse the repository at this point in the history
- includes changes to .clang-format config
- ran clang-format on incorrectly formatted sources
- updated erroneous ignore pattern in CI workflows
- upgraded pre-commit hooks
- switch from black to to ruff for formatting python sources
- ran `ruff format` on python files
- format Arduino examples
- update CI triggers
- update all actions used in CI
  • Loading branch information
2bndy5 authored Mar 22, 2024
1 parent 9b94552 commit d33a90b
Show file tree
Hide file tree
Showing 29 changed files with 216 additions and 237 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/build_arduino.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:

jobs:
check_formatting:
uses: 2bndy5/CirquePinnacle/.github/workflows/cpp_lint.yaml@master
uses: ./.github/workflows/cpp_lint.yaml
with:
extensions: 'ino'

Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Compile examples
uses: arduino/compile-sketches@main
Expand All @@ -66,24 +66,31 @@ jobs:
- examples/anymeas_mode
- examples/relative_mode
- name: sketch reports
if: matrix.enable-deltas-report
id: delta-report-name
run: >-
echo "report-name=${{ matrix.fqbn }}" | tr : - >> "$GITHUB_OUTPUT"
# This step is needed to pass the size data to the report job
- name: Upload sketches report to workflow artifact
if: matrix.enable-deltas-report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.SKETCH_REPORTS_PATH }}
name: arduino-deltas-${{ steps.delta-report-name.outputs.report-name }}
path: ${{ env.SKETCH_REPORTS_PATH }}

report_size_deltas:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Download sketches reports artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ env.SKETCH_REPORTS_PATH }}
pattern: arduino-deltas-*
path: ${{ env.SKETCH_REPORTS_PATH }}

- uses: arduino/report-size-deltas@v1
- uses: 2bndy5/report-size-deltas@update-comment
with:
sketches-reports-source: ${{ env.SKETCH_REPORTS_PATH }}
update-comment: true
6 changes: 3 additions & 3 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install sphinx deps
run: python -m pip install -r docs/requirements.txt
Expand All @@ -39,7 +39,7 @@ jobs:
run: sphinx-build . _build/html

- name: Save sphinx docs as artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Cirque_Pinnacle_docs
path: ${{ github.workspace }}/docs/_build/html
50 changes: 23 additions & 27 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Linux

on:
pull_request_target:
pull_request:
types: [opened, reopened]
branches: [master]
paths:
- "library.properties" # CMake gets lib info from here
- "src/*.h"
Expand All @@ -19,6 +18,7 @@ on:
- "examples/linux/*"
- ".github/workflows/build_linux.yml"
push:
branches: [master]
paths:
- "library.properties" # CMake gets lib info from here
- "src/*.h"
Expand All @@ -43,9 +43,9 @@ env:

jobs:
check_formatting:
uses: 2bndy5/CirquePinnacle/.github/workflows/cpp_lint.yaml@master
uses: ./.github/workflows/cpp_lint.yaml
with:
ignore: 'examples|examples_pico|utility/bcm2xxx/bcm2835.h|utility/bcm2xxx/bcm2835.c'
ignore: 'examples|!examples/linux|src/utility/bcm2xxx/bcm2835.h|src/utility/bcm2xxx/bcm2835.c'
build:
needs: check_formatting
runs-on: ubuntu-latest
Expand Down Expand Up @@ -88,13 +88,9 @@ jobs:
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
- name: get repo info
id: lib-info
run: echo "name=$(echo ${{ github.repository }} | sed 's;.\+/;;')" >> $GITHUB_OUTPUT

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: ${{ steps.lib-info.outputs.name }}
path: ${{ github.event.repository.name }}

- name: provide mraa
if: matrix.driver == 'mraa'
Expand All @@ -105,7 +101,7 @@ jobs:
cd build
cmake .. -D BUILDSWIGNODE=OFF \
-D CMAKE_INSTALL_PREFIX=/usr/${{ matrix.toolchain.usr_dir }} \
-D CMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/${{ steps.lib-info.outputs.name }}/src/cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake
-D CMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/${{ github.event.repository.name }}/src/cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake
sudo make install
- name: provide pigpio
Expand All @@ -119,58 +115,58 @@ jobs:
mkdir build
cd build
cmake .. -D CMAKE_INSTALL_PREFIX=/usr/${{ matrix.toolchain.usr_dir }} \
-D CMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/${{ steps.lib-info.outputs.name }}/src/cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake
-D CMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/${{ github.event.repository.name }}/src/cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake
make
sudo make install
- name: create CMake build environment
run: cmake -E make_directory ${{ github.workspace }}/${{ steps.lib-info.outputs.name }}/build
run: cmake -E make_directory ${{ github.workspace }}/${{ github.event.repository.name }}/build

- name: configure lib
working-directory: ${{ github.workspace }}/${{ steps.lib-info.outputs.name }}/build
working-directory: ${{ github.workspace }}/${{ github.event.repository.name }}/build
run: |
cmake ../src -D CMAKE_BUILD_TYPE=$BUILD_TYPE \
-D CMAKE_INSTALL_PREFIX=/usr/${{ matrix.toolchain.usr_dir }} \
-D CMAKE_TOOLCHAIN_FILE=cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake
- name: build lib
working-directory: ${{ github.workspace }}/${{ steps.lib-info.outputs.name }}/build
working-directory: ${{ github.workspace }}/${{ github.event.repository.name }}/build
run: cmake --build .

- name: install lib
working-directory: ${{ github.workspace }}/${{ steps.lib-info.outputs.name }}/build
working-directory: ${{ github.workspace }}/${{ github.event.repository.name }}/build
run: sudo cmake --install .

- name: package lib
if: endsWith(matrix.i2c-bus, 'OFF') && endsWith(matrix.dr-pin, 'OFF')
working-directory: ${{ github.workspace }}/${{ steps.lib-info.outputs.name }}/build
working-directory: ${{ github.workspace }}/${{ github.event.repository.name }}/build
run: sudo cpack

- name: Save artifact
if: endsWith(matrix.i2c-bus, 'OFF') && endsWith(matrix.dr-pin, 'OFF')
uses: actions/upload-artifact@v3
if: endsWith(matrix.i2c-bus, 'OFF') && endsWith(matrix.dr-pin, 'OFF') && startsWith(matrix.toolchain.compiler, 'arm')
uses: actions/upload-artifact@v4
with:
name: pkg_${{ steps.lib-info.outputs.name }}
name: pkg_${{ github.event.repository.name }}_${{ matrix.driver }}_${{ matrix.toolchain.compiler }}
path: |
${{ github.workspace }}/${{ steps.lib-info.outputs.name }}/build/pkgs/*.deb
${{ github.workspace }}/${{ steps.lib-info.outputs.name }}/build/pkgs/*.rpm
${{ github.workspace }}/${{ github.event.repository.name }}/build/pkgs/*.deb
${{ github.workspace }}/${{ github.event.repository.name }}/build/pkgs/*.rpm
- name: Upload Release assets
if: github.event_name == 'release' && (matrix.toolchain.compiler == 'armhf' || matrix.toolchain.compiler == 'arm64') && (matrix.driver =='bcm2xxx' || matrix.driver =='linux_kernel') && (endsWith(matrix.i2c-bus, 'OFF') && endsWith(matrix.dr-pin, 'OFF'))
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: "${{ github.workspace }}/${{ steps.lib-info.outputs.name }}/build/pkgs/lib*"
asset_path: "${{ github.workspace }}/${{ github.event.repository.name }}/build/pkgs/lib*"

- name: clean build environment
working-directory: ${{ github.workspace }}/${{ steps.lib-info.outputs.name }}/build
working-directory: ${{ github.workspace }}/${{ github.event.repository.name }}/build
run: sudo rm -r ./*

- name: provide ncurses
# This script assumes that any examples using ncurses reside in a 'ncurses' subdirectory
# as is the case w/ RF24Mesh, RF24Gateway, and any new ncurses examples going forward.
run: |
if [[ -d ${{ github.workspace }}/${{ steps.lib-info.outputs.name }}/examples/linux/ncurses ]]; then
if [[ -d ${{ github.workspace }}/${{ github.event.repository.name }}/examples/linux/ncurses ]]; then
if [[ ${{ matrix.toolchain.compiler }} == 'default' ]]; then
sudo apt-get install libncurses5-dev
else
Expand All @@ -190,12 +186,12 @@ jobs:
fi
- name: configure examples
working-directory: ${{ github.workspace }}/${{ steps.lib-info.outputs.name }}/build
working-directory: ${{ github.workspace }}/${{ github.event.repository.name }}/build
run: |
cmake ../examples/linux \
-D CMAKE_TOOLCHAIN_FILE=../src/cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake \
${{ matrix.i2c-bus }} ${{ matrix.dr-pin }}
- name: build examples
working-directory: ${{ github.workspace }}/${{ steps.lib-info.outputs.name }}/build
working-directory: ${{ github.workspace }}/${{ github.event.repository.name }}/build
run: cmake --build .
13 changes: 7 additions & 6 deletions .github/workflows/build_pico_sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Pico SDK

on:
pull_request:
types: [opened, reopened]
branches: [master]
paths:
- "src/*.cpp"
- "!src/py_bindings.cpp"
Expand All @@ -12,6 +12,7 @@ on:
- "examples/pico_sdk/**"
- ".github/workflows/build_pico_sdk.yml"
push:
branches: [master]
paths:
- "src/*.cpp"
- "!src/py_bindings.cpp"
Expand All @@ -23,9 +24,9 @@ on:

jobs:
check_formatting:
uses: 2bndy5/CirquePinnacle/.github/workflows/cpp_lint.yaml@master
uses: ./.github/workflows/cpp_lint.yaml
with:
ignore: 'examples/pico_sdk|'
ignore: '!examples/pico_sdk|'
build:
needs: check_formatting
runs-on: ubuntu-latest
Expand All @@ -52,15 +53,15 @@ jobs:
id: lib-info
run: echo "name=$(echo ${{ github.repository }} | sed 's;.\+/;;')" >> $GITHUB_OUTPUT

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: ${{ steps.lib-info.outputs.name }}

- name: Install toolchain
run: sudo apt update && sudo apt install gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential

- name: Clone pico-sdk
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: raspberrypi/pico-sdk
# master branch is latest stable release
Expand Down Expand Up @@ -88,7 +89,7 @@ jobs:
run: cmake --build . --config $BUILD_TYPE

- name: Save artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: examples_pico_${{ matrix.board }}_${{ matrix.i2c-bus }}_${{ matrix.dr-pin }}
path: |
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/build_platformio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ name: PlatformIO

on:
pull_request:
types: [opened, reopened]
branches: [master]
paths:
- ".github/workflows/build_platformio.yml"
- "library.json"
- "examples/**/*.ino"
push:
branches: [master]
paths:
- ".github/workflows/build_platformio.yml"
- "library.json"
Expand All @@ -20,7 +21,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: get lib info
id: lib-info
Expand All @@ -29,7 +30,7 @@ jobs:
echo "release=$(awk -F "=" '/version/ {print $2}' library.properties)" >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.x

Expand All @@ -42,7 +43,7 @@ jobs:
run: pio package pack -o PlatformIO-${{ steps.lib-info.outputs.name }}-${{ steps.lib-info.outputs.release }}.tar.gz

- name: Save artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: PIO_pkg_${{ steps.lib-info.outputs.name }}
path: PlatformIO*.tar.gz
Expand All @@ -62,7 +63,7 @@ jobs:
run: pio package publish --owner 2bndy5 --non-interactive

check_formatting:
uses: 2bndy5/CirquePinnacle/.github/workflows/cpp_lint.yaml@master
uses: ./.github/workflows/cpp_lint.yaml
with:
extensions: ino

Expand Down Expand Up @@ -90,25 +91,25 @@ jobs:

steps:
- name: Cache pip
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ matrix.board }}

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.x

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install PlatformIO
run: |
Expand Down
Loading

0 comments on commit d33a90b

Please sign in to comment.