-
Notifications
You must be signed in to change notification settings - Fork 4
Refatora quase tudo #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 95 commits
bd10771
0050396
f93583d
aa33fbb
b0b8248
281e42c
2b08065
693fe59
345a274
545a38e
fd43d6c
6689168
42f102d
c6497cd
b84c4e1
28c3444
7b63f56
127c0e5
e969f47
e82cafa
95d5d61
7c7f99f
34d1f55
ffd8dca
523b026
800bc6d
23fbab4
af15935
99fd511
a6838dc
156c5e4
f1bc47d
c4c2131
260d470
a224f94
438b87b
0102bdb
342a1c3
221672a
2345177
7732f61
686d0ea
0b72d38
faf2e7b
41fc369
6fe6569
4b681be
7d2c7a8
1cc2e06
eb07819
4daf74f
13e17b6
7c1924b
fbde763
168ef8f
81c2918
7794ef6
8db7e91
7a53420
a5ed64d
0a86681
3708c99
2d38cb0
6915d17
5917056
4aa7bee
ad95f09
2e656c6
4c64dd2
3a06571
7555c90
8b7d584
b0892a6
8f2c9ec
23c5e43
20c9261
6e581fd
27404d1
d87cf74
852f770
2d6137d
1394dfe
4ca3db8
4204ab0
a6d880a
ebde7d4
20f7740
398e932
625323f
07ab85b
3510d44
30676f7
36abad5
dd4ba09
98ecbc9
0120c51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
Language: Cpp | ||
AccessModifierOffset: -4 | ||
AlignAfterOpenBracket: BlockIndent | ||
AlignConsecutiveBitFields: | ||
Enabled: true | ||
PadOperators: true | ||
AlignConsecutiveDeclarations: | ||
Enabled: true | ||
PadOperators: true | ||
AlignConsecutiveMacros: | ||
PadOperators: true | ||
AlignEscapedNewlines: Left | ||
AllowShortBlocksOnASingleLine: Empty | ||
AllowShortEnumsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: Inline | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BreakBeforeTernaryOperators: false | ||
BreakConstructorInitializers: AfterColon | ||
BreakInheritanceList: AfterColon | ||
ColumnLimit: 120 | ||
EmptyLineBeforeAccessModifier: Always | ||
IncludeCategories: | ||
- Regex: '^<.*>' | ||
Priority: 1 | ||
SortPriority: 1 | ||
- Regex: '^".*"' | ||
SortPriority: 2 | ||
IncludeIsMainRegex: '$' | ||
IndentCaseLabels: true | ||
IndentExternBlock: NoIndent | ||
IndentPPDirectives: BeforeHash | ||
IndentRequiresClause: false | ||
IndentWidth: 4 | ||
IndentWrappedFunctionNames: true | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
PackConstructorInitializers: NextLine | ||
PointerAlignment: Left | ||
SeparateDefinitionBlocks: Always | ||
ShortNamespaceLines: 0 | ||
SortIncludes: Never | ||
SpaceInEmptyBlock: true | ||
SpacesBeforeTrailingComments: 2 | ||
TabWidth: 4 | ||
... | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
Checks: | ||
-*, | ||
bugprone-*, | ||
-bugprone-easily-swappable-parameters, | ||
-bugprone-narrowing-conversions, | ||
-bugprone-dynamic-static-initializers, | ||
clang-*, | ||
-clang-diagnostic-unused-command-line-argument, | ||
cppcoreguidelines-*, | ||
-cppcoreguidelines-avoid-magic-numbers, | ||
-cppcoreguidelines-pro-bounds-pointer-arithmetic, | ||
-cppcoreguidelines-avoid-do-while, | ||
-cppcoreguidelines-pro-type-union-access, | ||
google-*, | ||
llvm-*, | ||
-llvm-header-guard, | ||
misc-*, | ||
-misc-include-cleaner, | ||
-misc-const-correctness, | ||
-misc-use-anonymous-namespace, | ||
modernize-*, | ||
-modernize-use-nodiscard, | ||
-modernize-use-trailing-return-type, | ||
performance-*, | ||
readability-*, | ||
-readability-duplicate-include, | ||
-readability-magic-numbers, | ||
WarningsAsErrors: '*' | ||
HeaderFileExtensions: | ||
- '' | ||
- h | ||
- hh | ||
- hpp | ||
- hxx | ||
ImplementationFileExtensions: | ||
- c | ||
- cc | ||
- cpp | ||
- cxx | ||
HeaderFilterRegex: '(include|config)/.*.hpp' | ||
FormatStyle: none | ||
CheckOptions: | ||
readability-magic-numbers.IgnorePowersOf2IntegerValues: true | ||
readability-magic-numbers.IgnoreBitFieldsWidths: true | ||
readability-magic-numbers.IgnoreUserDefinedLiterals: true | ||
readability-identifier-length.MinimumVariableNameLength: 2 | ||
readability-identifier-length.IgnoredVariableNames: ^[nxyz]$ | ||
readability-identifier-length.MinimumParameterNameLength: 2 | ||
readability-identifier-length.IgnoredParameterNames: ^[nxyz]$ | ||
misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: true | ||
cppcoreguidelines-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: false | ||
readability-function-cognitive-complexity.Threshold: 30 | ||
SystemHeaders: false | ||
ExtraArgsBefore: | ||
- '--target=arm-none-eabi' | ||
- '--sysroot=/usr/lib/arm-none-eabi/' | ||
- '-I/usr/lib/arm-none-eabi/include/c++/13.2.1/' | ||
- '-I/usr/lib/arm-none-eabi/include/c++/13.2.1/arm-none-eabi/' | ||
... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "STM32 Template Container", | ||
"dockerComposeFile": "compose.yaml", | ||
"service": "dev", | ||
"shutdownAction": "stopCompose", | ||
"workspaceFolder": "/project", | ||
"overrideCommand": true, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-vscode.cpptools", | ||
"cschlosser.doxdocgen", | ||
"davidanson.vscode-markdownlint", | ||
"marus25.Cortex-Debug", | ||
"dan-c-underwood.arm", | ||
"streetsidesoftware.code-spell-checker", | ||
"streetsidesoftware.code-spell-checker-portuguese-brazilian", | ||
"twxs.cmake", | ||
"ms-vscode.cmake-tools", | ||
"seatonjiang.gitmoji-vscode", | ||
"mhutchie.git-graph", | ||
"xaver.clang-format", | ||
] | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.git/ | ||
.github/ | ||
.vscode/ | ||
.cache/ | ||
.idea/ | ||
build/ | ||
cube/ | ||
!**.ioc | ||
|
||
.devcontainer | ||
.gitignore | ||
.gitmodules | ||
Doxyfile | ||
LICENSE | ||
|
||
*.yaml | ||
*.md | ||
*.iml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
################################## | ||
# Base image for STM32 Template # | ||
################################## | ||
FROM thunderatz/stm32cubemx:6.13.0-f1 AS base | ||
|
||
RUN apt-get update -y > /dev/null && \ | ||
apt-get upgrade -y > /dev/null && \ | ||
apt-get install -y \ | ||
gcc-arm-none-eabi \ | ||
make \ | ||
cmake \ | ||
clang-tidy \ | ||
clang-format > /dev/null\ | ||
&& apt-get clean > /dev/null | ||
|
||
WORKDIR /project | ||
COPY ./cube/*.ioc /project/cube/ | ||
|
||
ENV CUBE_CMD=${CUBE_PATH}/STM32CubeMX | ||
|
||
ENV DISPLAY=:10 | ||
ARG PROJECT_NAME=stm32_project_template | ||
|
||
RUN Xvfb :10 -ac & \ | ||
echo "config load /project/cube/${PROJECT_NAME}.ioc\nproject generate\nexit\n" > .cube && \ | ||
$CUBE_PATH/STM32CubeMX -q /project/.cube && \ | ||
rm .cube && \ | ||
pkill -f Xvfb | ||
|
||
RUN rm /tmp/.X10-lock | ||
|
||
RUN echo "trap 'chown -R ubuntu /project' EXIT" >> "/root/.bashrc" | ||
|
||
################################### | ||
# Build image for STM32 Template # | ||
################################### | ||
FROM base AS build | ||
|
||
COPY . /project |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
BUILD_ARG=$1 | ||
|
||
rm -rf /project/build || exit 1 | ||
mkdir -p /project/build || exit 1 | ||
cd /project/build || exit 1 | ||
cmake .. -DBUILD_TYPE=Release $BUILD_ARG || exit 1 | ||
|
||
echo "Compiling main..." | sed 's/.*/\x1b[34m&\x1b[0m/' | ||
|
||
make -j | ||
|
||
if [ $? -eq 0 ]; then | ||
echo "Compilation successful." | sed 's/.*/\x1b[32m&\x1b[0m/' | ||
else | ||
echo "Compilation failed." | sed 's/.*/\x1b[31m&\x1b[0m/' | ||
exit 1 | ||
fi | ||
|
||
echo "Compiling tests..." | sed 's/.*/\x1b[34m&\x1b[0m/' | ||
|
||
make test_all -j | ||
|
||
if [ $? -eq 0 ]; then | ||
echo "Tests compiled successfully." | sed 's/.*/\x1b[32m&\x1b[0m/' | ||
else | ||
echo "Tests compilation failed." | sed 's/.*/\x1b[31m&\x1b[0m/' | ||
exit 1 | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
FILES=$(find . \( -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) \ | ||
-not \( -path "*/cube/*" -o -path "*/build/*" -o -path "*/libs/*" \)) | ||
|
||
for FILE in $FILES; do | ||
clang-format -style=file -output-replacements-xml $FILE | grep "<replacement " >/dev/null | ||
if [ $? -eq 0 ]; then | ||
echo "Code not properly formatted (File: $FILE). Please run make format." | sed 's/.*/\x1b[31m&\x1b[0m/' | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "Code properly formatted." | sed 's/.*/\x1b[32m&\x1b[0m/' |
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,66 @@ | ||||||||||||
name: Build lint and check formatting | ||||||||||||
|
||||||||||||
on: | ||||||||||||
pull_request: | ||||||||||||
types: [opened, synchronize, reopened, ready_for_review] | ||||||||||||
branches: | ||||||||||||
- develop | ||||||||||||
- main | ||||||||||||
push: | ||||||||||||
branches: | ||||||||||||
- develop | ||||||||||||
- main | ||||||||||||
|
||||||||||||
jobs: | ||||||||||||
build: | ||||||||||||
runs-on: ubuntu-latest | ||||||||||||
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false | ||||||||||||
steps: | ||||||||||||
- name: 🔀 Checkout | ||||||||||||
uses: actions/checkout@v4 | ||||||||||||
with: | ||||||||||||
submodules: recursive | ||||||||||||
|
||||||||||||
- name: 🗃️ Check cache | ||||||||||||
id: cache | ||||||||||||
uses: actions/cache/restore@v4 | ||||||||||||
with: | ||||||||||||
path: .docker/Dockerfile | ||||||||||||
key: ${{ hashFiles('.github/*', 'cmake/*', '**/*.cpp', '**/*.hpp', '**/*.ioc', '.clang*', 'CMakeLists.txt', '.docker/*') }} | ||||||||||||
lookup-only: true | ||||||||||||
|
||||||||||||
- name: 🔧 Set up Docker Buildx | ||||||||||||
if: steps.cache.outputs.cache-hit != 'true' | ||||||||||||
uses: docker/setup-buildx-action@v3 | ||||||||||||
|
||||||||||||
- name: 🐋 Build Docker image | ||||||||||||
if: steps.cache.outputs.cache-hit != 'true' | ||||||||||||
uses: docker/build-push-action@v6 | ||||||||||||
Comment on lines
+37
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
with: | ||||||||||||
context: . | ||||||||||||
file: .docker/Dockerfile | ||||||||||||
target: build | ||||||||||||
load: true | ||||||||||||
cache-from: type=gha | ||||||||||||
cache-to: type=gha,mode=max | ||||||||||||
no-cache-filters: build | ||||||||||||
tags: project:build | ||||||||||||
|
||||||||||||
- name: 🎨 Check code formatting | ||||||||||||
if: steps.cache.outputs.cache-hit != 'true' | ||||||||||||
run: docker run --rm project:build /bin/bash /project/.docker/scripts/check_format.sh | ||||||||||||
|
||||||||||||
- name: 🔨 Build project | ||||||||||||
if: steps.cache.outputs.cache-hit != 'true' | ||||||||||||
run: docker run --rm project:build /bin/bash /project/.docker/scripts/build.sh | ||||||||||||
|
||||||||||||
- name: 🚨 Lint project | ||||||||||||
if: steps.cache.outputs.cache-hit != 'true' | ||||||||||||
run: docker run --rm project:build /bin/bash /project/.docker/scripts/build.sh -DLINTER_MODE=ON | ||||||||||||
Comment on lines
+53
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Não olhei tão a fundo, mas precisa desses dois estágios? O o build já não é feito junto do linting? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. verdade, acho q eh melhor juntar nesse caso a única diferença de resultado eh que quando roda com lint não tem binários de saída, mas como o CI não usa eu acho legal, já eh bom que diminui o tempo do check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a gnt tbm perde a clareza da informação se falhou na compilação ou no lint, mas acho q tá suave There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pra ambos os casos teria que olhar os logs pra ver o que falhou, então acho que não é tanto um problema. E aí economizar tempo na CI sempre ajuda, ainda mais pra projetos grandes aushhshshshsu There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eu ainda digo que esse if de cache em todos os steps não faz sentido nenhum e tem que ter uma forma melhor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Analisando melhor, acho que vale destacar uma troca importante entre clareza e performance aqui. Atualmente, temos dois estágios separados: um para o build puro e outro para o build com lint. A proposta de juntar os dois ajuda a economizar tempo no CI, mas tem algumas implicações. Comparativo entre os cenáriosBuild sem linter (estágios separados):
Build com linter somente (estágios unificados):
Ou seja, se o código não compila, o CI gasta 3 minutos para descobrir algo que poderia ser pego em 23 segundos. Isso pode ser relevante principalmente quando estamos em uma iteração rápida ou PRs mais simples. Além disso, com os estágios separados, a gente ganha um pouco mais de clareza visual no resultado do CI, já que conseguimos ver diretamente se falhou no build ou no lint pelo nome do step (com o emojizinho bonitinho :p). Se unificarmos, isso se perde, aí todo erro vai parecer um erro do "build+lint" Por outro lado… É justo dizer que falhas de compilação são menos comuns em branches que sobem PRs, então há um argumento forte pra otimizar pro caso comum (sucesso), e evitar rodar o build puro à toa. Eu particularmente acho que tanto faz kkkkkkkkkkkkkkkk mas como eu gosto dos emojis tendo a manter como está. De qualquer modo, é uma coisa extremamente simples que pode ser configurada pelo projeto se ele nao gostar do jeito que está |
||||||||||||
|
||||||||||||
- name: 🗃️ Save cache | ||||||||||||
if: steps.cache.outputs.cache-hit != 'true' | ||||||||||||
uses: actions/cache/save@v4 | ||||||||||||
with: | ||||||||||||
path: .docker/Dockerfile | ||||||||||||
key: ${{ steps.cache.outputs.cache-primary-key }} |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,42 @@ | ||||||||||||
name: Add binaries to release | ||||||||||||
|
||||||||||||
on: | ||||||||||||
release: | ||||||||||||
types: [published] | ||||||||||||
|
||||||||||||
permissions: | ||||||||||||
contents: write | ||||||||||||
|
||||||||||||
jobs: | ||||||||||||
build: | ||||||||||||
runs-on: ubuntu-latest | ||||||||||||
steps: | ||||||||||||
- name: 🔀 Checkout | ||||||||||||
uses: actions/checkout@v4 | ||||||||||||
with: | ||||||||||||
submodules: recursive | ||||||||||||
|
||||||||||||
- name: 🔧 Set up Docker Buildx | ||||||||||||
uses: docker/setup-buildx-action@v3 | ||||||||||||
|
||||||||||||
- name: 🐋 Build Docker image | ||||||||||||
uses: docker/build-push-action@v6 | ||||||||||||
Comment on lines
+22
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
with: | ||||||||||||
context: . | ||||||||||||
file: .docker/Dockerfile | ||||||||||||
target: build | ||||||||||||
load: true | ||||||||||||
cache-from: type=gha | ||||||||||||
cache-to: type=gha,mode=max | ||||||||||||
no-cache-filters: build | ||||||||||||
tags: project:build | ||||||||||||
|
||||||||||||
- name: 🔨 Build project | ||||||||||||
run: | | ||||||||||||
docker run --name release project:build /bin/bash /project/.docker/scripts/build.sh | ||||||||||||
docker cp release:/project/build/ output/ | ||||||||||||
|
||||||||||||
- name: ⬆️ Upload binaries | ||||||||||||
run: gh release upload ${{ github.event.release.tag_name }} output/*.hex output/*.elf | ||||||||||||
env: | ||||||||||||
GITHUB_TOKEN: ${{ github.token }} |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.