Skip to content

Commit

Permalink
Merge pull request #2 from makers-for-life/enable-ci
Browse files Browse the repository at this point in the history
Migrate GitHub actions from old repo
  • Loading branch information
dsferruzza authored May 5, 2020
2 parents 490cdbb + 80e534b commit 6dcd1a6
Show file tree
Hide file tree
Showing 9 changed files with 340 additions and 26 deletions.
22 changes: 22 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
AccessModifierOffset: -3
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortIfStatementsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: true
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Attach
ColumnLimit: 100
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
IncludeBlocks: Preserve
IndentWidth: 4
Language: Cpp
MacroBlockBegin: "^MAPS_BEGIN_[A-Z]*_DEFINITION$"
MacroBlockEnd: "^MAPS_END_[A-Z]*_DEFINITION$"
PointerAlignment: Left
SpacesInParentheses: false
UseTab: Never
SpacesBeforeTrailingComments: 2
31 changes: 31 additions & 0 deletions .github/workflows/firmware-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Firmware Documentation

on: [push, pull_request]

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Create documentation directory
run: |
mkdir -p local/docs
- name: Generate documentation for firmware
uses: mattnotmitt/doxygen-action@v1

- name: Archive all documentation
uses: actions/upload-artifact@v1
with:
name: docs
path: local/docs/

- name: Deploy all documentation
uses: JamesIves/github-pages-deploy-action@releases/v3
if: github.ref == 'refs/heads/master'
with:
BRANCH: gh-pages
FOLDER: local/docs/html/
TARGET_FOLDER: ./
34 changes: 34 additions & 0 deletions .github/workflows/firmware-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Firmware Lint

on: [push, pull_request]

jobs:
cpp-lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: action-cpp-lint
uses: CyberZHG/[email protected]
with:
args: "--recursive ./"

cppcheck:
runs-on: ubuntu-18.04
steps:
- name: install cppcheck
run: |
sed 's/bionic/focal/g' /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/focal.list
sudo apt-get update
echo "Package: cppcheck" | sudo tee /etc/apt/preferences.d/cppcheck
echo "Pin: release n=focal" | sudo tee -a /etc/apt/preferences.d/cppcheck
echo "Pin-Priority: 990" | sudo tee -a /etc/apt/preferences.d/cppcheck
sudo apt-get install -y cppcheck
- uses: actions/checkout@v2
- name: run cppcheck
run: |
cppcheck --version
cppcheck --error-exitcode=1 --enable=all --inline-suppr -I ./includes ./srcs
cppcheck --error-exitcode=1 --addon=cert --inline-suppr -I ./includes ./srcs
cppcheck --error-exitcode=1 --addon=misra --inline-suppr --suppressions-list=./cppcheck/misra-suppr.txt -I ./includes ./srcs
164 changes: 164 additions & 0 deletions .github/workflows/firmware-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
name: Firmware Release

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install Arduino CLI
uses: arduino/[email protected]

- name: Install STM libs
run: |
arduino-cli config init --additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json
arduino-cli config dump
arduino-cli core update-index
arduino-cli core install STM32:stm32
arduino-cli lib install LiquidCrystal
arduino-cli lib install "Analog Buttons"
arduino-cli lib install OneButton
sed -i '/recipe.output.tmp_file={build.project_name}.hex/d' "$HOME/.arduino15/packages/STM32/hardware/stm32/1.8.0/platform.txt"
sed -i '/recipe.output.save_file={build.project_name}.{build.variant}.hex/d' "$HOME/.arduino15/packages/STM32/hardware/stm32/1.8.0/platform.txt"
- name: Get the version
id: version
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: |
echo ::set-output name=version::${GITHUB_REF/refs\/tags\//}
- name: Set VERSION variable
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && steps.version.outputs.version != ''
run: |
sed -Ei "s/#define VERSION \".+\"/#define VERSION \"${{ steps.version.outputs.version }}\"/" includes/parameters.h
- name: Build production HW2-FAULHABER
run: |
sed -Ei 's/#define HARDWARE_VERSION [0-9]+/#define HARDWARE_VERSION 2/' includes/config.h
sed -Ei 's/#define MODE .+/#define MODE MODE_PROD/' includes/config.h
sed -Ei 's/#define PNEUMATIC_HARDWARE_VERSION .+/#define PNEUMATIC_HARDWARE_VERSION PHW_FAULHABER/' includes/config.h
sed -Ei 's/#define VALVE_TYPE .+/#define VALVE_TYPE VT_FAULHABER/' includes/config.h
arduino-cli compile --fqbn STM32:stm32:Nucleo_64:opt=o3std,pnum=NUCLEO_F411RE --verbose srcs/respirator.cpp --output output/respirator-production
mkdir -p dist/
VERSION=$(sed -En 's/#define VERSION[ ]+["](.+)["]/\1/p' includes/parameters.h)
cp output/respirator-production.bin "dist/respirator-production-HW2-FAULHABER-$VERSION-$GITHUB_SHA.bin"
- name: Build qualification HW2-FAULHABER
run: |
sed -Ei 's/#define HARDWARE_VERSION [0-9]+/#define HARDWARE_VERSION 2/' includes/config.h
sed -Ei 's/#define MODE .+/#define MODE MODE_QUALIFICATION/' includes/config.h
sed -Ei 's/#define PNEUMATIC_HARDWARE_VERSION .+/#define PNEUMATIC_HARDWARE_VERSION PHW_FAULHABER/' includes/config.h
sed -Ei 's/#define VALVE_TYPE .+/#define VALVE_TYPE VT_FAULHABER/' includes/config.h
arduino-cli compile --fqbn STM32:stm32:Nucleo_64:opt=o3std,pnum=NUCLEO_F411RE --verbose srcs/qualification.cpp --output output/respirator-qualification
mkdir -p dist/
VERSION=$(sed -En 's/#define VERSION[ ]+["](.+)["]/\1/p' includes/parameters.h)
cp output/respirator-qualification.bin "dist/respirator-qualification-HW2-FAULHABER-$VERSION-$GITHUB_SHA.bin"
- name: Build integration test HW2-FAULHABER
run: |
sed -Ei 's/#define HARDWARE_VERSION [0-9]+/#define HARDWARE_VERSION 2/' includes/config.h
sed -Ei 's/#define MODE .+/#define MODE MODE_INTEGRATION_TEST/' includes/config.h
sed -Ei 's/#define PNEUMATIC_HARDWARE_VERSION .+/#define PNEUMATIC_HARDWARE_VERSION PHW_FAULHABER/' includes/config.h
sed -Ei 's/#define VALVE_TYPE .+/#define VALVE_TYPE VT_FAULHABER/' includes/config.h
arduino-cli compile --fqbn STM32:stm32:Nucleo_64:opt=o3std,pnum=NUCLEO_F411RE --verbose srcs/qualification.cpp --output output/respirator-integration-test
mkdir -p dist/
VERSION=$(sed -En 's/#define VERSION[ ]+["](.+)["]/\1/p' includes/parameters.h)
cp output/respirator-integration-test.bin "dist/respirator-integration-test-HW2-FAULHABER-$VERSION-$GITHUB_SHA.bin"
- name: Build production HW2
run: |
sed -Ei 's/#define HARDWARE_VERSION [0-9]+/#define HARDWARE_VERSION 2/' includes/config.h
sed -Ei 's/#define MODE .+/#define MODE MODE_PROD/' includes/config.h
sed -Ei 's/#define PNEUMATIC_HARDWARE_VERSION .+/#define PNEUMATIC_HARDWARE_VERSION PHW_CHU/' includes/config.h
sed -Ei 's/#define VALVE_TYPE .+/#define VALVE_TYPE VT_SERVO_V1/' includes/config.h
arduino-cli compile --fqbn STM32:stm32:Nucleo_64:opt=o3std,pnum=NUCLEO_F411RE --verbose srcs/respirator.cpp --output output/respirator-production
mkdir -p dist/
VERSION=$(sed -En 's/#define VERSION[ ]+["](.+)["]/\1/p' includes/parameters.h)
cp output/respirator-production.bin "dist/respirator-production-HW2-$VERSION-$GITHUB_SHA.bin"
- name: Build qualification HW2
run: |
sed -Ei 's/#define HARDWARE_VERSION [0-9]+/#define HARDWARE_VERSION 2/' includes/config.h
sed -Ei 's/#define MODE .+/#define MODE MODE_QUALIFICATION/' includes/config.h
sed -Ei 's/#define PNEUMATIC_HARDWARE_VERSION .+/#define PNEUMATIC_HARDWARE_VERSION PHW_CHU/' includes/config.h
sed -Ei 's/#define VALVE_TYPE .+/#define VALVE_TYPE VT_SERVO_V1/' includes/config.h
arduino-cli compile --fqbn STM32:stm32:Nucleo_64:opt=o3std,pnum=NUCLEO_F411RE --verbose srcs/qualification.cpp --output output/respirator-qualification
mkdir -p dist/
VERSION=$(sed -En 's/#define VERSION[ ]+["](.+)["]/\1/p' includes/parameters.h)
cp output/respirator-qualification.bin "dist/respirator-qualification-HW2-$VERSION-$GITHUB_SHA.bin"
- name: Build integration test HW2
run: |
sed -Ei 's/#define HARDWARE_VERSION [0-9]+/#define HARDWARE_VERSION 2/' includes/config.h
sed -Ei 's/#define MODE .+/#define MODE MODE_INTEGRATION_TEST/' includes/config.h
sed -Ei 's/#define PNEUMATIC_HARDWARE_VERSION .+/#define PNEUMATIC_HARDWARE_VERSION PHW_CHU/' includes/config.h
sed -Ei 's/#define VALVE_TYPE .+/#define VALVE_TYPE VT_SERVO_V1/' includes/config.h
arduino-cli compile --fqbn STM32:stm32:Nucleo_64:opt=o3std,pnum=NUCLEO_F411RE --verbose srcs/qualification.cpp --output output/respirator-integration-test
mkdir -p dist/
VERSION=$(sed -En 's/#define VERSION[ ]+["](.+)["]/\1/p' includes/parameters.h)
cp output/respirator-integration-test.bin "dist/respirator-integration-test-HW2-$VERSION-$GITHUB_SHA.bin"
- name: Build production HW1
run: |
sed -Ei 's/#define HARDWARE_VERSION [0-9]+/#define HARDWARE_VERSION 1/' includes/config.h
sed -Ei 's/#define MODE .+/#define MODE MODE_PROD/' includes/config.h
sed -Ei 's/#define PNEUMATIC_HARDWARE_VERSION .+/#define PNEUMATIC_HARDWARE_VERSION PHW_CHU/' includes/config.h
sed -Ei 's/#define VALVE_TYPE .+/#define VALVE_TYPE VT_SERVO_V1/' includes/config.h
arduino-cli compile --fqbn STM32:stm32:Nucleo_64:opt=o3std,pnum=NUCLEO_F411RE --verbose srcs/respirator.cpp --output output/respirator-production
mkdir -p dist/
VERSION=$(sed -En 's/#define VERSION[ ]+["](.+)["]/\1/p' includes/parameters.h)
cp output/respirator-production.bin "dist/respirator-production-HW1-$VERSION-$GITHUB_SHA.bin"
- name: Build qualification HW1
run: |
sed -Ei 's/#define HARDWARE_VERSION [0-9]+/#define HARDWARE_VERSION 1/' includes/config.h
sed -Ei 's/#define MODE .+/#define MODE MODE_QUALIFICATION/' includes/config.h
sed -Ei 's/#define PNEUMATIC_HARDWARE_VERSION .+/#define PNEUMATIC_HARDWARE_VERSION PHW_CHU/' includes/config.h
sed -Ei 's/#define VALVE_TYPE .+/#define VALVE_TYPE VT_SERVO_V1/' includes/config.h
arduino-cli compile --fqbn STM32:stm32:Nucleo_64:opt=o3std,pnum=NUCLEO_F411RE --verbose srcs/qualification.cpp --output output/respirator-qualification
mkdir -p dist/
VERSION=$(sed -En 's/#define VERSION[ ]+["](.+)["]/\1/p' includes/parameters.h)
cp output/respirator-qualification.bin "dist/respirator-qualification-HW1-$VERSION-$GITHUB_SHA.bin"
- name: Build integration test HW1
run: |
sed -Ei 's/#define HARDWARE_VERSION [0-9]+/#define HARDWARE_VERSION 1/' includes/config.h
sed -Ei 's/#define MODE .+/#define MODE MODE_INTEGRATION_TEST/' includes/config.h
sed -Ei 's/#define PNEUMATIC_HARDWARE_VERSION .+/#define PNEUMATIC_HARDWARE_VERSION PHW_CHU/' includes/config.h
sed -Ei 's/#define VALVE_TYPE .+/#define VALVE_TYPE VT_SERVO_V1/' includes/config.h
arduino-cli compile --fqbn STM32:stm32:Nucleo_64:opt=o3std,pnum=NUCLEO_F411RE --verbose srcs/qualification.cpp --output output/respirator-integration-test
mkdir -p dist/
VERSION=$(sed -En 's/#define VERSION[ ]+["](.+)["]/\1/p' includes/parameters.h)
cp output/respirator-integration-test.bin "dist/respirator-integration-test-HW1-$VERSION-$GITHUB_SHA.bin"
- name: Archive binaries
uses: actions/upload-artifact@v1
with:
name: bin
path: dist/

- name: Release dev binaries
uses: softprops/action-gh-release@v1
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
files: |
dist/*.bin
body: |
Auto-release (${{ github.sha }})
⚠️ FOR TEST PURPOSE ONLY - DO NOT USE IN PRODUCTION
tag_name: auto-${{ github.run_id }}
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Release stable binaries
uses: softprops/action-gh-release@v1
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && steps.version.outputs.version != ''
with:
files: |
dist/*.bin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/firmware-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Firmware Unit Tests

on: [push, pull_request]

jobs:
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Install Google Test
run: |
export gtest_ver="1.10.0"
# build and install Google Test
wget https://github.com/google/googletest/archive/release-${gtest_ver}.tar.gz
tar xf release-${gtest_ver}.tar.gz
cd googletest-release-${gtest_ver}
cmake .
sudo cmake --build . --target install
- name: Unit Test
run: |
cd $GITHUB_WORKSPACE
# build unit test
mkdir build_test
cd build_test
cmake $GITHUB_WORKSPACE/test/
cmake --build .
# Run tests
ctest
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/.pio/
/.vscode/
/local/
.DS_Store
/output/*
!/output/.gitkeep
/*.csv
/*.ods
/*.csv#
/*.ods#
build/*
.scannerwork
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY = "local/docs/software/firmware"
OUTPUT_DIRECTORY = "local/docs"

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
Expand Down
4 changes: 2 additions & 2 deletions cppcheck/misra-suppr.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// url inside comment
misra-c2012-3.1:src/software/firmware/srcs/screen.cpp:1
misra-c2012-3.1:srcs/screen.cpp:1

// url inside comment
misra-c2012-3.1:src/software/firmware/srcs/keyboard.cpp:1
misra-c2012-3.1:srcs/keyboard.cpp:1
Loading

0 comments on commit 6dcd1a6

Please sign in to comment.