Skip to content

Commit c4cdeaa

Browse files
authored
Update Submodules and add CI for automated code analysis, building, and releasing (#5)
* update submodules * update main after changes to submodule * add pre-commit hook and clang format for ensuring style * run pre-commit hook on all files to ensure style * add ci * fix static analysis * fix static analysis
1 parent c4643f7 commit c4cdeaa

20 files changed

+439
-219
lines changed

.clang-format

+117
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

+21
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

+48
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+

.github/workflows/static_analysis.yml

+25
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/esp-protocols --force --enable=all --inline-suppr --inconclusive --platform=mips32 --std=c++17 --suppressions-list=$GITHUB_WORKSPACE/suppressions.txt

.pre-commit-config.yaml

+17
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/esp-protocols

Submodule esp-protocols updated 275 files

components/espp

Submodule espp updated 358 files
+13-11
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
#pragma once
22

3-
#include <string>
43
#include <cstring>
4+
#include <string>
55
#include <unordered_map>
66

77
#include "window.hpp"
88

99
class GraphWindow : public Window {
1010
public:
11+
GraphWindow() = default;
12+
1113
void init(lv_obj_t *parent, size_t width, size_t height) override;
1214
void update() override;
1315

14-
void clear_plots ( void );
15-
void add_data ( const std::string& plot_name, int new_data );
16-
void remove_plot ( const std::string& plot_name );
16+
void clear_plots(void);
17+
void add_data(const std::string &plot_name, int new_data);
18+
void remove_plot(const std::string &plot_name);
1719

1820
protected:
19-
lv_chart_series_t* create_plot ( const std::string& plotName );
20-
lv_chart_series_t* get_plot ( const std::string& plotName );
21+
lv_chart_series_t *create_plot(const std::string &plotName);
22+
lv_chart_series_t *get_plot(const std::string &plotName);
2123

22-
void update_ticks ( void );
24+
void update_ticks(void);
2325

2426
private:
25-
lv_obj_t *chart_;
26-
lv_obj_t *legend_;
27-
std::string y_ticks_;
28-
std::unordered_map<std::string, lv_chart_series_t*> plot_map_;
27+
lv_obj_t *chart_{nullptr};
28+
lv_obj_t *legend_{nullptr};
29+
std::string y_ticks_{""};
30+
std::unordered_map<std::string, lv_chart_series_t *> plot_map_{};
2931
};

components/gui/include/gui.hpp

+13-15
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
#include "converter.hpp"
1111
#include "display.hpp"
12-
#include "task.hpp"
12+
#include "graph_window.hpp"
1313
#include "logger.hpp"
14+
#include "task.hpp"
1415
#include "text_window.hpp"
15-
#include "graph_window.hpp"
1616

1717
class Gui {
1818
public:
19-
const std::string delimeter_data = "::"; ///< Delimeter indicating this contains plottable data
19+
const std::string delimeter_data = "::"; ///< Delimeter indicating this contains plottable data
2020
const std::string delimeter_command = "+++"; ///< Delimeter indicating this contains a command
2121
const std::string command_remove_plot = "RP:"; ///< Command: remove plot
2222
const std::string command_clear_plots = "CP"; ///< Command: clear plots
@@ -27,17 +27,15 @@ class Gui {
2727
espp::Logger::Verbosity log_level{espp::Logger::Verbosity::WARN};
2828
};
2929

30-
explicit Gui(const Config& config)
31-
: display_(config.display)
32-
, logger_({.tag = "Gui", .level = config.log_level}) {
30+
explicit Gui(const Config &config)
31+
: display_(config.display)
32+
, logger_({.tag = "Gui", .level = config.log_level}) {
3333
init_ui();
3434
// now start the gui updater task
3535
using namespace std::placeholders;
36-
task_ = espp::Task::make_unique({
37-
.name = "Gui Task",
38-
.callback = std::bind(&Gui::update, this, _1, _2),
39-
.stack_size_bytes = 6 * 1024
40-
});
36+
task_ = espp::Task::make_unique({.name = "Gui Task",
37+
.callback = std::bind(&Gui::update, this, _1, _2),
38+
.stack_size_bytes = 6 * 1024});
4139
task_->start();
4240
}
4341

@@ -48,19 +46,19 @@ class Gui {
4846

4947
void switch_tab();
5048

51-
void push_data(const std::string& data);
49+
void push_data(const std::string &data);
5250
std::string pop_data();
5351

5452
void clear_info();
55-
void add_info(const std::string& info);
53+
void add_info(const std::string &info);
5654

5755
bool handle_data();
5856

5957
protected:
6058
void init_ui();
6159
void deinit_ui();
6260

63-
bool update(std::mutex& m, std::condition_variable& cv) {
61+
bool update(std::mutex &m, std::condition_variable &cv) {
6462
{
6563
std::lock_guard<std::recursive_mutex> lk(mutex_);
6664
lv_task_handler();
@@ -77,7 +75,7 @@ class Gui {
7775
static void event_callback(lv_event_t *e) {
7876
lv_event_code_t event_code = lv_event_get_code(e);
7977
auto user_data = lv_event_get_user_data(e);
80-
auto gui = static_cast<Gui*>(user_data);
78+
auto gui = static_cast<Gui *>(user_data);
8179
if (!gui) {
8280
return;
8381
}

components/gui/include/text_window.hpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
class TextWindow : public Window {
99
public:
10+
TextWindow() = default;
1011

11-
void init ( lv_obj_t *parent, size_t width, size_t height ) override;
12+
void init(lv_obj_t *parent, size_t width, size_t height) override;
1213

13-
void clear_logs( void );
14-
void add_log ( const std::string& log_text );
14+
void clear_logs(void);
15+
void add_log(const std::string &log_text);
1516

1617
private:
17-
std::string log_text_;
18-
lv_obj_t *log_container_;
18+
std::string log_text_{""};
19+
lv_obj_t *log_container_{nullptr};
1920
};

0 commit comments

Comments
 (0)