Skip to content

[WIP] C++ linter and formatter (experimental) #207

[WIP] C++ linter and formatter (experimental)

[WIP] C++ linter and formatter (experimental) #207

Workflow file for this run

name: Generate
on:
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: read
jobs:
platformio:
name: PlatformIO version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.print.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: 3.13
cache: pip
cache-dependency-path: .github/platformio/requirements.txt
- name: Set up PlatformIO
run: pip install -r .github/platformio/requirements.txt
- name: PlatformIO version
id: print
run: echo "version=$(pio --version | awk '{print $NF}')" >> "$GITHUB_OUTPUT"
font-dejavusans:
name: DejaVuSans font
needs: platformio
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- python-version: 3.11
- clang-version: 21
python-version: 3.13
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.toolchain.python-version }}
cache: pip
cache-dependency-path: |
.github/platformio/requirements.txt
extra/Python/requirements.txt
scripts/requirements.txt
- name: Set up PlatformIO
run: pip install -r .github/platformio/requirements.txt
- name: Set up Frekvens extra
run: pip install -r extra/Python/requirements.txt
- name: Set up Cache
continue-on-error: true
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
key: platformio-cache-${{ runner.os }}-${{ runner.arch }}-${{ needs.platformio.outputs.version }}-${{ hashFiles('platformio.ini') }}
path: |
.platformio/.cache/downloads
.platformio/.cache/http
- name: Font generator
run: |
python extra/Python/FontGenerator.py -i DejaVuSans --size 8
mv DejaVuSansFont.cpp firmware/src/fonts
mv DejaVuSansFont.h firmware/include/fonts
sed -i '/^#pragma once$/a\#include "fonts/DejaVuSansFont.h"' firmware/include/services/FontsService.h
sed -i '/^ const std::vector<FontModule \*> modules = {$/a\ new DejaVuSansFont(),' firmware/include/services/FontsService.h
- name: Remove platformio.ini lib_deps
continue-on-error: true
run: |
sed -i '/(?:arduino-irremote\/IRremote)|(?:Arduino-IRremote\/Arduino-IRremote)/d' platformio.ini
sed -i '/bertmelis\/espMqttClient/d' platformio.ini
sed -i '/(?:makuna\/RTC)|(?:Makuna\/Rtc)/d' platformio.ini
sed -i '/vintlabs\/FauxmoESP/d' platformio.ini
- name: PlatformIO build
run: |
cat <<'EOL' > .env
EXTENSION_MESSAGE='true'
HOSTNAME='frekvens'
IKEA_FREKVENS='true'
MODE_TICKER='true'
NAME='Frekvens'
EOL
cat <<'EOL' > firmware/include/config/secrets.h
#pragma once
#define PIN_CS 1
#define PIN_MOSI 2
#define PIN_OE 3
#define PIN_SCLK 4
#define WIFI_KEY "redacted"
#define WIFI_SSID "redacted"
EOL
pio run -e esp32dev
- name: PlatformIO compilation database
if: matrix.toolchain.clang-version
run: pio run -e esp32dev -t compiledb
- name: Clang
if: matrix.toolchain.clang-version
uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7
id: clang
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: ${{ matrix.toolchain.clang-version }}
files-changed-only: false
format-review: true
ignore: "*|!firmware/src/fonts/DejaVuSansFont.cpp|!firmware/include/fonts/DejaVuSansFont.h"
passive-reviews: true
step-summary: true
style: file
tidy-checks: ""
tidy-review: true
- name: Clang checks failed
if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed != 0
run: exit 1
mode-dynamic:
name: Dynamic mode
needs: platformio
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- python-version: 3.11
- clang-version: 21
python-version: 3.13
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.toolchain.python-version }}
cache: pip
cache-dependency-path: |
.github/platformio/requirements.txt
scripts/requirements.txt
- name: Set up PlatformIO
run: pip install -r .github/platformio/requirements.txt
- name: Set up Cache
continue-on-error: true
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
key: platformio-cache-${{ runner.os }}-${{ runner.arch }}-${{ needs.platformio.outputs.version }}-${{ hashFiles('platformio.ini') }}
path: |
.platformio/.cache/downloads
.platformio/.cache/http
- name: Generate mode
run: |
cat <<EOL > Dynamic.csv
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,255,0,0,0,0,0,255,0,0,255,0,0,0
0,0,0,255,0,0,0,0,0,0,0,0,255,0,0,0
0,0,0,255,255,255,0,0,0,255,0,0,255,0,0,0
0,0,0,255,0,0,255,0,0,255,0,0,255,0,0,0
0,0,0,255,0,0,255,0,0,255,0,0,0,0,0,0
0,0,0,255,0,0,255,0,0,255,0,0,255,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,255,255,0,0,0,0,255,255,0,0,0,0
0,0,0,0,255,255,0,0,0,0,255,255,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,255,255,0,0,0,0,255,255,0,0,0,0
0,0,0,0,0,255,255,255,255,255,255,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
EOL
python extra/Python/ModeGenerator.py -i Dynamic.csv
mv DynamicMode.cpp firmware/src/modes
mv DynamicMode.h firmware/include/modes
sed -i '/^#pragma once$/a\#include "modes/DynamicMode.h"' firmware/include/services/ModesService.h
sed -i '/^ const std::vector<ModeModule \*> modes = {$/a\ new DynamicMode(),' firmware/include/services/ModesService.h
- name: Remove platformio.ini lib_deps
continue-on-error: true
run: |
sed -i '/(?:arduino-irremote\/IRremote)|(?:Arduino-IRremote\/Arduino-IRremote)/d' platformio.ini
sed -i '/bertmelis\/espMqttClient/d' platformio.ini
sed -i '/(?:makuna\/RTC)|(?:Makuna\/Rtc)/d' platformio.ini
sed -i '/vintlabs\/FauxmoESP/d' platformio.ini
- name: PlatformIO build
run: |
cat <<'EOL' > .env
HOSTNAME='frekvens'
IKEA_FREKVENS='true'
MODE_ANIMATION='true'
NAME='Frekvens'
EOL
cat <<'EOL' > firmware/include/config/secrets.h
#pragma once
#define PIN_CS 1
#define PIN_MOSI 2
#define PIN_OE 3
#define PIN_SCLK 4
#define WIFI_KEY "redacted"
#define WIFI_SSID "redacted"
EOL
pio run -e esp32dev
- name: PlatformIO compilation database
if: matrix.toolchain.clang-version
run: pio run -e esp32dev -t compiledb
- name: Clang
if: matrix.toolchain.clang-version
uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7
id: clang
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: ${{ matrix.toolchain.clang-version }}
files-changed-only: false
format-review: true
ignore: "*|!firmware/src/modes/DynamicMode.cpp|!firmware/include/modes/DynamicMode.h"
passive-reviews: true
step-summary: true
style: file
tidy-checks: ""
tidy-review: true
- name: Clang checks failed
if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed != 0
run: exit 1
mode-static:
name: Static mode
needs: platformio
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- python-version: 3.11
- clang-version: 21
python-version: 3.13
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.toolchain.python-version }}
cache: pip
cache-dependency-path: |
.github/platformio/requirements.txt
scripts/requirements.txt
- name: Set up PlatformIO
run: pip install -r .github/platformio/requirements.txt
- name: Set up Cache
continue-on-error: true
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
key: platformio-cache-${{ runner.os }}-${{ runner.arch }}-${{ needs.platformio.outputs.version }}-${{ hashFiles('platformio.ini') }}
path: |
.platformio/.cache/downloads
.platformio/.cache/http
- name: Generate mode
run: |
cat <<EOL > Static.csv
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,255,0,0,0,0,0,255,0,0,255,0,0,0
0,0,0,255,0,0,0,0,0,0,0,0,255,0,0,0
0,0,0,255,255,255,0,0,0,255,0,0,255,0,0,0
0,0,0,255,0,0,255,0,0,255,0,0,255,0,0,0
0,0,0,255,0,0,255,0,0,255,0,0,0,0,0,0
0,0,0,255,0,0,255,0,0,255,0,0,255,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,255,255,0,0,0,0,255,255,0,0,0,0
0,0,0,0,255,255,0,0,0,0,255,255,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,255,255,0,0,0,0,255,255,0,0,0,0
0,0,0,0,0,255,255,255,255,255,255,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
EOL
python extra/Python/ModeGenerator.py -i Static.csv
mv StaticMode.cpp firmware/src/modes
mv StaticMode.h firmware/include/modes
sed -i '/^#pragma once$/a\#include "modes/StaticMode.h"' firmware/include/services/ModesService.h
sed -i '/^ const std::vector<ModeModule \*> modes = {$/a\ new StaticMode(),' firmware/include/services/ModesService.h
- name: Remove platformio.ini lib_deps
continue-on-error: true
run: |
sed -i '/(?:arduino-irremote\/IRremote)|(?:Arduino-IRremote\/Arduino-IRremote)/d' platformio.ini
sed -i '/bertmelis\/espMqttClient/d' platformio.ini
sed -i '/(?:makuna\/RTC)|(?:Makuna\/Rtc)/d' platformio.ini
sed -i '/vintlabs\/FauxmoESP/d' platformio.ini
- name: PlatformIO build
run: |
cat <<'EOL' > .env
HOSTNAME='frekvens'
IKEA_FREKVENS='true'
MODE_DRAW='true'
NAME='Frekvens'
EOL
cat <<'EOL' > firmware/include/config/secrets.h
#pragma once
#define PIN_CS 1
#define PIN_MOSI 2
#define PIN_OE 3
#define PIN_SCLK 4
#define WIFI_KEY "redacted"
#define WIFI_SSID "redacted"
EOL
pio run -e esp32dev
- name: PlatformIO compilation database
if: matrix.toolchain.clang-version
run: pio run -e esp32dev -t compiledb
- name: Clang
if: matrix.toolchain.clang-version
uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7
id: clang
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: ${{ matrix.toolchain.clang-version }}
files-changed-only: false
format-review: true
ignore: "*|!firmware/src/modes/StaticMode.cpp|!firmware/include/modes/StaticMode.h"
passive-reviews: true
step-summary: true
style: file
tidy-checks: ""
tidy-review: true
- name: Clang checks failed
if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed != 0
run: exit 1