Skip to content

Commit

Permalink
Merge pull request #264 from fschrempf/feature/code-formatting
Browse files Browse the repository at this point in the history
Code Formatting via `clang-format`
  • Loading branch information
biologist79 authored Oct 31, 2023
2 parents baee74f + b0ea7b9 commit 0253bc7
Show file tree
Hide file tree
Showing 64 changed files with 4,946 additions and 4,780 deletions.
41 changes: 41 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
BasedOnStyle: WebKit
AlignArrayOfStructures: Right
AlignConsecutiveBitFields:
Enabled: true
AlignConsecutiveMacros:
Enabled: true
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: InlineOnly
BreakBeforeBraces: Attach
Cpp11BracedListStyle: true
FixNamespaceComments: true
IncludeBlocks: Regroup
IncludeCategories:
- Regex: Arduino.h
Priority: -1
SortPriority: -2
CaseSensitive: true
- Regex: settings.h
Priority: -1
SortPriority: -1
CaseSensitive: true
- Regex: ^"
Priority: 1
SortPriority: 0
CaseSensitive: false
- Regex: .*
Priority: 4
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: (_test)?$
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
InsertBraces: true
InsertNewlineAtEOF: true
NamespaceIndentation: None
PointerAlignment: Right
SpaceAfterCStyleCast: true
Standard: Auto
TabWidth: 4
UseTab: Always
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# This file lists commit hashes for commits that should be ignored when
# using "git blame". This allows to hide major code reworks like formatting
# changes from the "git blame" history.
#
2 changes: 2 additions & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[blame]
ignoreRevsFile = .git-blame-ignore-revs
20 changes: 0 additions & 20 deletions .github/workflows/build.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: clang-format-check
run-name: Clang-format Check
on: [workflow_dispatch, push, pull_request]
jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/[email protected]
with:
clang-format-version: '16'
check-path: 'src'
fallback-style: 'LLVM' # optional
58 changes: 58 additions & 0 deletions .github/workflows/test-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: build-all
run-name: Build all boards
on:
workflow_dispatch:
push:
pull_request:
paths:
- 'src/*'
- 'html/*'
- 'test/*'
- '**.ini'
- '**.py'
- '**.csv'

jobs:
test_builds:
name: Run all Tests
runs-on: ubuntu-latest
strategy:
matrix:
variant:
- esp32-a1s
- lolin32
- lolin_d32
- lolin_d32_pro
- lolin_d32_pro_sdmmc_pe
- nodemcu-32s
- az-delivery-devkit-v4
- ttgo_t8
- complete

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

- name: Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install PlatformIO Core
run: |
pip install -U setuptools platformio
pio upgrade --dev
pio pkg update --global
- name: Build ${{ matrix.variant }}
run: platformio run -e ${{ matrix.variant }}
8 changes: 6 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"cmake.configureOnOpen": false
}
"cmake.configureOnOpen": false,
"editor.tabSize": 4,
"gitlens.advanced.blame.customArguments": [
"--ignore-revs-file", ".git-blame-ignore-revs"
]
}
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ to (re-)enable/disable WiFi:
ESPuino can be used as Bluetooth sink (A2DP sink). In this mode you can stream audio (e.g. from a
mobile device) via Bluetooth to your ESPuino. This mode can be enabled/disabled via a RFID
modification card or by assigning action `CMD_TOGGLE_BLUETOOTH_MODE` to a button (or multi-button).
Applying this will restart ESPuino immediately. Activated Bluetooth is indicated by four
Applying this will restart ESPuino immediately. Activated Bluetooth is indicated by four
slow rotating _blue-violet_ LEDs. After the Bluetooth device is paired the LEDs turn to blue.

### ESPuino as A2DP source (stream from ESPuino)
Expand Down Expand Up @@ -486,3 +486,26 @@ described as follows.
| topicBatterySOC | float | Current battery charge in percent (e.g. 83.0) |
| topicWiFiRssiState | int | Numeric WiFi signal-strength (dBm) |
| topicSRevisionState | String | Software-revision |

## Development and Contributions

### Code Formatting

Automatic code formatting via `clang-format` is used. The configuration/rules can be found in
`.clang-format`. If you use Visual Studio Code as IDE, the support for this is automatically
available through the C++ extension.

When editing source code, use Ctrl+Shift+I to run the auto-formatting on the file or Ctrl+K Ctrl+F
for the selected code.

See the [documentation](https://code.visualstudio.com/docs/cpp/cpp-ide#_code-formatting) for more
options like run auto-formatting on saving or editing the file.

The CI (via "GitHub Actions") checks changes when they are pushed in order to keep the source code
clean and provide feedback to the developers and maintainers.

To keep the output of `git blame` clean despite the massive changes when introducing new formatting
rules, we have a `.git-blame-ignore-revs` that lists the commits to ignore. In VSCode this should be
used automatically if you use the "GitLens" extension. Otherwise make sure you apply the config
fragment for git by running `git config --local include.path ../.gitconfig` once in your local
clone.
Loading

0 comments on commit 0253bc7

Please sign in to comment.