Skip to content

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

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

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

Workflow file for this run

name: Clang
on:
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: read
pull-requests: write
jobs:
platformio:
name: PlatformIO variable extract
runs-on: ubuntu-latest
outputs:
environments: ${{ steps.print.outputs.environments }}
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 extract
id: print
run: |
echo "environments=$(pio project config --json-output | jq -c '[.[] | .[0] | select(startswith("env:")) | sub("^env:"; "")]')" >> "$GITHUB_OUTPUT"
echo "version=$(pio --version | awk '{print $NF}')" >> "$GITHUB_OUTPUT"
format:
name: Format
runs-on: ubuntu-latest
strategy:
matrix:
include:
- clang-version: 21
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Clang format
uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7
id: format
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: ${{ matrix.clang-version }}
files-changed-only: false
format-review: true
passive-reviews: true
step-summary: true
style: file
tidy-checks: -*
- name: Clang format checks failed?
if: steps.format.outputs.clang-format-checks-failed != 0
run: exit 1
tidy:
name: Tidy
needs: platformio
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
environment: ${{ fromJson(needs.platformio.outputs.environments) }}
include:
- clang-version: 21
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
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: PlatformIO compilation database
run: |
cat <<'EOL' > .env
EXTENSION_ALEXA='true'
EXTENSION_BUTTON='true'
EXTENSION_HEAP='true'
EXTENSION_HOMEASSISTANT='true'
EXTENSION_INFRARED='true'
EXTENSION_MESSAGE='true'
EXTENSION_MICROPHONE='true'
EXTENSION_MQTT='true'
EXTENSION_OTA='true'
EXTENSION_PHOTOCELL='true'
EXTENSION_PLAYLIST='true'
EXTENSION_RESTFUL='true'
EXTENSION_RTC='true'
EXTENSION_SERVERSENTEVENTS='true'
EXTENSION_SIGNAL='true'
EXTENSION_WEBAPP='true'
EXTENSION_WEBSOCKET='true'
FONT_BRAILLE='true'
HOSTNAME='frekvens'
IKEA_FREKVENS='true'
MODE_ANIMATION='true'
MODE_ARROW='true'
MODE_BINARYCLOCK='true'
MODE_BINARYEPOCH='true'
MODE_BLINDS='true'
MODE_BLINK='true'
MODE_BREAKOUTCLOCK='true'
MODE_BRIGHT='true'
MODE_CIRCLE='true'
MODE_COUNTDOWN='true'
MODE_DRAW='true'
MODE_EQUALIZER='true'
MODE_FIREWORK='true'
MODE_FLIES='true'
MODE_GAMEOFLIFE='true'
MODE_GLITTER='true'
MODE_GOOGLEWEATHER='true'
MODE_HOMEASSISTANTWEATHER='true'
MODE_HOMETHERMOMETER='true'
MODE_JAGGEDWAVEFORM='true'
MODE_LARGECLOCK='true'
MODE_LEAFFALL='true'
MODE_LINES='true'
MODE_METABALLS='true'
MODE_NOISE='true'
MODE_OPENMETEO='true'
MODE_OPENWEATHER='true'
MODE_PINGPONG='true'
MODE_PIXELSEQUENCE='true'
MODE_RAIN='true'
MODE_RING='true'
MODE_SCAN='true'
MODE_SMALLCLOCK='true'
MODE_SMOOTHWAVEFORM='true'
MODE_SNAKE='true'
MODE_STARS='true'
MODE_STREAM='true'
MODE_TICKER='true'
MODE_WAVEFORM='true'
MODE_WORLDWEATHERONLINE='true'
MODE_WTTRIN='true'
MODE_YR='true'
NAME='Frekvens'
EOL
cat <<'EOL' > firmware/include/config/secrets.h
#pragma once
#define GOOGLEWEATHER_KEY "redacted"
#define HOMEASSISTANT_HOST "homeassistant.local"
#define HOMEASSISTANT_KEY "redacted"
#define LATITUDE "0.000"
#define LOCATION "redacted"
#define LONGITUDE "0.000"
#define MQTT_HOST "mqtt.local"
#define MQTT_USER "redacted"
#define MQTT_KEY "redacted"
#define OPENMETEO_KEY "redacted"
#define OPENWEATHER_KEY "redacted"
#define PIN_CS 1
#define PIN_INT 2
#define PIN_IR 3
#define PIN_LDR 4
#define PIN_MIC 5
#define PIN_MOSI 6
#define PIN_OE 7
#define PIN_SCL 8
#define PIN_SCLK 9
#define PIN_SDA 10
#define PIN_SW1 11
#define PIN_SW2 12
#define RTC_DS3232
#define WIFI_KEY "redacted"
#define WIFI_SSID "redacted"
#define WORLDWEATHERONLINE_KEY "redacted"
EOL
pio run -t compiledb -e ${{ matrix.environment }}
- name: Clang tidy
uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7
id: tidy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: ${{ matrix.clang-version }}
files-changed-only: false
passive-reviews: true
step-summary: true
style: ""
tidy-checks: ""