Skip to content
Draft
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
12 changes: 6 additions & 6 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
Language: Cpp
AccessModifierOffset: -4
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
BinPackArguments: false
BreakBeforeBraces: Allman
ColumnLimit: 0
FixNamespaceComments: false
BreakStringLiterals: false
ColumnLimit: 120
IncludeBlocks: Regroup
IndentWidth: 4
InsertBraces: true
NamespaceIndentation: All
...
23 changes: 23 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Checks: >
bugprone-*,
clang-analyzer-*,
cppcoreguidelines-*,
modernize-*,
performance-*,
readability-*,
-bugprone-easily-swappable-parameters,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-init-variables,
-cppcoreguidelines-macro-to-enum,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-pro-bounds-constant-array-index,
-modernize-macro-to-enum,
-modernize-use-auto,
-modernize-use-trailing-return-type,
-readability-convert-member-functions-to-static,
-readability-identifier-length,
-readability-magic-numbers,
-readability-misplaced-array-index,
-readability-static-accessed-through-instance,
-readability-uppercase-literal-suffix
247 changes: 247 additions & 0 deletions .github/workflows/clang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
name: Clang

on:
pull_request:
branches:
- main

workflow_dispatch:

permissions:
contents: read
pull-requests: write

jobs:
platformio:
name: PlatformIO environments
runs-on: ubuntu-latest
outputs:
environments: ${{ steps.print.outputs.environments }}
version: ${{ steps.print.outputs.version }}

env:
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: ${{ env.python-version }}
cache: pip
cache-dependency-path: .github/platformio/requirements.txt

- name: Set up PlatformIO
run: pip install -r .github/platformio/requirements.txt

- name: PlatformIO environments
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

env:
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: ${{ env.clang-version }}
files-changed-only: false
format-review: true
passive-reviews: true
step-summary: true
style: file
tidy-checks: -*

- name: Summary
run: |
echo "Clang report:"
if [ -n "${{ github.event.pull_request.number }}" ]; then
echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}"
else
echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
fi
exit $(( ${{ steps.format.outputs.clang-format-checks-failed }} != 0 ))

tidy:
name: Tidy
needs: platformio
runs-on: ubuntu-latest

env:
clang-threshold: 358
clang-version: 21
python-version: 3.13

strategy:
matrix:
device-id:
- IKEA_FREKVENS
- IKEA_OBEGRANSAD

environment: ${{ fromJson(needs.platformio.outputs.environments) }}

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: ${{ env.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: PlatformIO compilation database
run: |
cat <<'EOL' > .env
${{ matrix.device-id }}='true'
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'
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: ${{ env.clang-version }}
files-changed-only: false
passive-reviews: true
step-summary: true
style: ""
tidy-checks: ""
tidy-review: true

- name: Summary
run: |
echo "Status: ${{ steps.tidy.outputs.clang-tidy-checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}."
echo "Clang report:"
if [ -n "${{ github.event.pull_request.number }}" ]; then
echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}"
else
echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
fi
exit $(( ${{ steps.tidy.outputs.clang-tidy-checks-failed }} > ${{ env.clang-threshold }} ))
Loading
Loading