Skip to content

Commit 3ef7e1d

Browse files
authored
Ci/update (#7)
* added precommit hook for applying code style * run precommit hook to update code style * add ci for static analysis, building, and releasing * fix static analysis
1 parent ec7d453 commit 3ef7e1d

File tree

10 files changed

+342
-112
lines changed

10 files changed

+342
-112
lines changed

.clang-format

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: LLVM
4+
AccessModifierOffset: -2
5+
AlignAfterOpenBracket: Align
6+
AlignConsecutiveAssignments: false
7+
AlignConsecutiveDeclarations: false
8+
AlignEscapedNewlines: Right
9+
AlignOperands: true
10+
AlignTrailingComments: true
11+
AllowAllParametersOfDeclarationOnNextLine: true
12+
AllowShortBlocksOnASingleLine: false
13+
AllowShortCaseLabelsOnASingleLine: false
14+
AllowShortFunctionsOnASingleLine: All
15+
AllowShortIfStatementsOnASingleLine: false
16+
AllowShortLoopsOnASingleLine: false
17+
AlwaysBreakAfterDefinitionReturnType: None
18+
AlwaysBreakAfterReturnType: None
19+
AlwaysBreakBeforeMultilineStrings: false
20+
AlwaysBreakTemplateDeclarations: false
21+
BinPackArguments: true
22+
BinPackParameters: true
23+
BraceWrapping:
24+
AfterClass: false
25+
AfterControlStatement: false
26+
AfterEnum: false
27+
AfterFunction: false
28+
AfterNamespace: false
29+
AfterObjCDeclaration: false
30+
AfterStruct: false
31+
AfterUnion: false
32+
AfterExternBlock: false
33+
BeforeCatch: false
34+
BeforeElse: false
35+
IndentBraces: false
36+
SplitEmptyFunction: true
37+
SplitEmptyRecord: true
38+
SplitEmptyNamespace: true
39+
BreakBeforeBinaryOperators: None
40+
BreakBeforeBraces: Attach
41+
BreakBeforeInheritanceComma: false
42+
BreakBeforeTernaryOperators: true
43+
BreakConstructorInitializersBeforeComma: true
44+
BreakConstructorInitializers: BeforeColon
45+
BreakAfterJavaFieldAnnotations: false
46+
BreakStringLiterals: true
47+
ColumnLimit: 100
48+
CommentPragmas: '^ IWYU pragma:'
49+
CompactNamespaces: false
50+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
51+
ConstructorInitializerIndentWidth: 4
52+
ContinuationIndentWidth: 4
53+
Cpp11BracedListStyle: true
54+
DerivePointerAlignment: false
55+
DisableFormat: false
56+
ExperimentalAutoDetectBinPacking: false
57+
FixNamespaceComments: true
58+
ForEachMacros:
59+
- foreach
60+
- Q_FOREACH
61+
- BOOST_FOREACH
62+
IncludeBlocks: Preserve
63+
IncludeCategories:
64+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
65+
Priority: 2
66+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
67+
Priority: 3
68+
- Regex: '.*'
69+
Priority: 1
70+
IncludeIsMainRegex: '(Test)?$'
71+
IndentCaseLabels: false
72+
IndentPPDirectives: None
73+
IndentWidth: 2
74+
IndentWrappedFunctionNames: false
75+
JavaScriptQuotes: Leave
76+
JavaScriptWrapImports: true
77+
KeepEmptyLinesAtTheStartOfBlocks: true
78+
MacroBlockBegin: ''
79+
MacroBlockEnd: ''
80+
MaxEmptyLinesToKeep: 1
81+
NamespaceIndentation: None
82+
ObjCBlockIndentWidth: 2
83+
ObjCSpaceAfterProperty: false
84+
ObjCSpaceBeforeProtocolList: true
85+
PenaltyBreakAssignment: 2
86+
PenaltyBreakBeforeFirstCallParameter: 19
87+
PenaltyBreakComment: 300
88+
PenaltyBreakFirstLessLess: 120
89+
PenaltyBreakString: 1000
90+
PenaltyExcessCharacter: 1000000
91+
PenaltyReturnTypeOnItsOwnLine: 60
92+
PointerAlignment: Right
93+
RawStringFormats:
94+
- Language: TextProto
95+
Delimiters:
96+
- 'pb'
97+
- 'proto'
98+
BasedOnStyle: google
99+
ReflowComments: true
100+
SortIncludes: true
101+
SortUsingDeclarations: true
102+
SpaceAfterCStyleCast: false
103+
SpaceAfterTemplateKeyword: true
104+
SpaceBeforeAssignmentOperators: true
105+
SpaceBeforeParens: ControlStatements
106+
SpaceInEmptyParentheses: false
107+
SpacesBeforeTrailingComments: 1
108+
SpacesInAngles: false
109+
SpacesInContainerLiterals: true
110+
SpacesInCStyleCastParentheses: false
111+
SpacesInParentheses: false
112+
SpacesInSquareBrackets: false
113+
Standard: Cpp11
114+
TabWidth: 8
115+
UseTab: Never
116+
...
117+

.github/workflows/build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout repo
12+
uses: actions/checkout@v2
13+
with:
14+
submodules: 'recursive'
15+
16+
- name: Build Examples
17+
uses: espressif/esp-idf-ci-action@v1
18+
with:
19+
esp_idf_version: release-v5.2
20+
target: esp32s3
21+
path: '.'

.github/workflows/package_main.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build and Package Main
2+
3+
on:
4+
push:
5+
branches: [main]
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
continue-on-error: false
14+
15+
steps:
16+
- name: Checkout repo
17+
uses: actions/checkout@v2
18+
with:
19+
submodules: 'recursive'
20+
21+
- name: Build Main Code
22+
uses: espressif/esp-idf-ci-action@v1
23+
with:
24+
esp_idf_version: release-v5.2
25+
target: esp32s3
26+
path: '.'
27+
command: 'idf.py build'
28+
29+
- name: Upload Build Outputs
30+
uses: actions/upload-artifact@v3
31+
with:
32+
name: build-artifacts
33+
path: |
34+
build/bootloader/bootloader.bin
35+
build/partition_table/partition-table.bin
36+
build/*.bin
37+
build/flash_args
38+
39+
- name: Attach files to release
40+
uses: softprops/action-gh-release@v1
41+
if: ${{ github.event.release && github.event.action == 'published' }}
42+
with:
43+
files: |
44+
build/*.bin
45+
build/bootloader/bootloader.bin
46+
build/partition_table/partition-table.bin
47+
build/flash_args
48+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Static analysis
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
static_analysis:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout repo
11+
uses: actions/checkout@v2
12+
with:
13+
submodules: 'recursive'
14+
15+
- name: Run static analysis
16+
uses: esp-cpp/StaticAnalysis@master
17+
with:
18+
# Do not build the project and do not use cmake to generate compile_commands.json
19+
use_cmake: false
20+
21+
# Use the 5.2 release version since it's what we build with
22+
esp_idf_version: release/v5.2
23+
24+
# (Optional) cppcheck args
25+
cppcheck_args: -i$GITHUB_WORKSPACE/components/espp -i$GITHUB_WORKSPACE/components/esp32-camera -i$GITHUB_WORKSPACE/components/esp-protocols --force --enable=all --inline-suppr --inconclusive --platform=mips32 --std=c++17 --suppressions-list=$GITHUB_WORKSPACE/suppressions.txt

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/mirrors-clang-format
3+
rev: v14.0.6
4+
hooks:
5+
- id: clang-format
6+
exclude: |
7+
(?x)(
8+
^components/esp-dsp/|
9+
^components/esp_littlefs/|
10+
^components/lvgl/|
11+
^components/state_machine/include/magic_enum.hpp|
12+
^external/alpaca/|
13+
^external/cli/|
14+
^external/csv2/|
15+
^external/fmt/
16+
)
17+
types_or: [c++, c]

components/battery/include/battery.hpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class Battery {
1616
espp::Logger::Verbosity log_level{espp::Logger::Verbosity::WARN};
1717
};
1818

19-
Battery(const Config& config)
20-
: read_(config.read),
21-
hold_gpio_(config.hold_gpio),
22-
logger_({.tag = "Battery", .level = config.log_level}) {
19+
explicit Battery(const Config &config)
20+
: read_(config.read)
21+
, hold_gpio_(config.hold_gpio)
22+
, logger_({.tag = "Battery", .level = config.log_level}) {
2323
init();
2424
}
2525

@@ -54,13 +54,12 @@ class Battery {
5454
return;
5555
}
5656
logger_.info("Initializing hold GPIO {}", hold_gpio_);
57-
uint64_t pin_mask = (1 << hold_gpio_);
5857
gpio_config_t io_config = {
59-
.pin_bit_mask = pin_mask,
60-
.mode = GPIO_MODE_OUTPUT,
61-
.pull_up_en = GPIO_PULLUP_DISABLE,
62-
.pull_down_en = GPIO_PULLDOWN_DISABLE,
63-
.intr_type = GPIO_INTR_DISABLE,
58+
.pin_bit_mask = ((uint64_t)1 << hold_gpio_),
59+
.mode = GPIO_MODE_OUTPUT,
60+
.pull_up_en = GPIO_PULLUP_DISABLE,
61+
.pull_down_en = GPIO_PULLDOWN_DISABLE,
62+
.intr_type = GPIO_INTR_DISABLE,
6463
};
6564
ESP_ERROR_CHECK(gpio_config(&io_config));
6665
hold_output();

main/fs_init.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#include "format.hpp"
44

55
static esp_vfs_littlefs_conf_t conf = {
6-
.base_path = "/littlefs",
7-
.partition_label = "littlefs",
8-
.format_if_mount_failed = true,
9-
.dont_mount = false,
6+
.base_path = "/littlefs",
7+
.partition_label = "littlefs",
8+
.format_if_mount_failed = true,
9+
.dont_mount = false,
1010
};
1111

1212
void fs_init() {
@@ -28,8 +28,7 @@ void fs_init() {
2828
size_t total = 0, used = 0;
2929
ret = esp_littlefs_info(conf.partition_label, &total, &used);
3030
if (ret != ESP_OK) {
31-
fmt::print("Failed to get LittleFS partition information ({})\n",
32-
esp_err_to_name(ret));
31+
fmt::print("Failed to get LittleFS partition information ({})\n", esp_err_to_name(ret));
3332
} else {
3433
fmt::print("Partition size: total: {}, used: {}\n", total, used);
3534
}

main/fs_init.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

3-
#include <esp_err.h>
43
#include "esp_littlefs.h"
4+
#include <esp_err.h>
55
#include <sys/stat.h>
66

77
void fs_init();

0 commit comments

Comments
 (0)