Skip to content

Simplify components #421

Simplify components

Simplify components #421

Workflow file for this run

name: PlatformIO CI
on:
pull_request:
branches:
- master
- develop
paths-ignore:
- "**/*.md"
push:
branches:
- master
- develop
paths-ignore:
- "**/*.md"
jobs:
build-bhaptics:
name: Build ${{ matrix.target }} ${{ matrix.coverage && 'with coverage' || 'without coverage' }}, -D ${{ matrix.battery_flag }} -D ${{ matrix.serial_plotter_flag }} -D ${{ matrix.nimble_flag }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
target:
- bhaptics_tactsuit_x16
- bhaptics_tactsuit_x16_pca9685
- bhaptics_tactsuit_x40
- bhaptics_tactosy2_forearm_right
- bhaptics_tactosyh_hand_right
- bhaptics_tactosyf_foot_right
- bhaptics_tactal
- bhaptics_tactvisor
- bhaptics_tactglove_right
battery_flag: [SENSESHIFT_BATTERY_ENABLED=true]
serial_plotter_flag: [SENSESHIFT_SERIAL_PLOTTER=false]
nimble_flag: [SENSESHIFT_BLE_USE_NIMBLE=false]
coverage: [false]
include:
# Extra tests for x40, as it uses the most features
- target: bhaptics_tactsuit_x40
os: ubuntu-latest
coverage: true
battery_flag: SENSESHIFT_BATTERY_ENABLED=true
serial_plotter_flag: SENSESHIFT_SERIAL_PLOTTER=true
nimble_flag: SENSESHIFT_BLE_USE_NIMBLE=true
# - target: bhaptics_tactsuit_x40
# os: ubuntu-latest
# coverage: true
# battery_flag: SENSESHIFT_BATTERY_ENABLED=true
# serial_plotter_flag: SENSESHIFT_SERIAL_PLOTTER=true
# nimble_flag: SENSESHIFT_BLE_USE_NIMBLE=false
- target: bhaptics_tactsuit_x40
os: ubuntu-latest
coverage: false
battery_flag: SENSESHIFT_BATTERY_ENABLED=true
serial_plotter_flag: SENSESHIFT_SERIAL_PLOTTER=false
nimble_flag: SENSESHIFT_BLE_USE_NIMBLE=true
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Get firmware name
id: firmware_name
run: |
./.github/scripts/get_firmware_name.sh ${{ matrix.target }} ${{ matrix.serial_plotter_flag }} ${{ matrix.battery_flag }} ${{ matrix.nimble_flag }}
- name: Enable coverage (non-macOS)
if: runner.os != 'macOS' && matrix.coverage
run: |
sed -i '/__OH_FIRMWARE__/p; s/-D __OH_FIRMWARE__/-lgcov --coverage/' platformio.ini
- name: Enable coverage (macOS)
if: runner.os == 'macOS' && matrix.coverage
run: |
sed -i '' '/__OH_FIRMWARE__/p; s/-D __OH_FIRMWARE__/-lgcov --coverage/' platformio.ini
- name: Update build flags (non-macOS)
if: runner.os != 'macOS'
run: |
sed -i '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.battery_flag }}/' platformio.ini
sed -i '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.serial_plotter_flag }}/' platformio.ini
sed -i '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.nimble_flag }}/' platformio.ini
- name: Update build flags (macOS)
if: runner.os == 'macOS'
run: |
sed -i '' '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.battery_flag }}/' platformio.ini
sed -i '' '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.serial_plotter_flag }}/' platformio.ini
sed -i '' '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.nimble_flag }}/' platformio.ini
- name: Speedup package installation
if: matrix.coverage
uses: abbbi/github-actions-tune@v1
- name: Setup LCOV
if: matrix.coverage
uses: hrishikesh-kadam/setup-lcov@v1
- 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/.cache
./.pio
key: ${{ runner.os }}-pio-${{ matrix.target }}-${{ hashFiles('**/*.ini') }}
restore-keys: |
${{ runner.os }}-pio-${{ matrix.target }}-
${{ runner.os }}-pio-
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
pio upgrade --dev
pio pkg update --global
- name: Install libs
run: pio pkg install -e ${{matrix.target}}
- name: Change memory segments
if: matrix.coverage
run: |
sed -i "s/len\s=\s0x2c200\s-\s0xdb5c/len = 2898880/" ~/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/memory.ld
sed -i "/\[env\]/p; s/\[env\]/board_build.partitions = huge_app.csv/" platformio.ini
- name: Build
run: |
echo "::group::platformio.ini"
cat platformio.ini
echo "::endgroup::"
pio run --environment ${{matrix.target}}
- name: Collect initial coverage
if: matrix.coverage
run: |
mkdir -p ./build/lcov
lcov -i -d ./.pio/build/${{matrix.target}}/ -c -o ./build/lcov/lcov.info.${{ steps.firmware_name.outputs.firmware }} -gcov-tool ~/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcov
- name: Upload coverage Artifact
uses: actions/upload-artifact@v3
if: matrix.coverage
with:
name: lcov.info.${{ steps.firmware_name.outputs.firmware }}
path: ./build/lcov/lcov.info.${{ steps.firmware_name.outputs.firmware }}
retention-days: 1
build-opengloves:
name: Build ${{ matrix.target }} ${{ matrix.coverage && 'with coverage' || 'without coverage' }}, -D ${{ matrix.comm_flag }} -D ${{ matrix.curl_calibration_flag }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
target:
- lucidgloves-prototype3
- lucidgloves-prototype4
- indexer-c
- indexer-cf
- indexer-cs
- indexer-csf
comm_flag:
- COMMUNICATION_PROTOCOL=OPENGLOVES_COMM_SERIAL
- COMMUNICATION_PROTOCOL=OPENGLOVES_COMM_BTSERIAL
coverage: [false]
include:
- os: ubuntu-latest
target: lucidgloves-prototype4-ffb
curl_calibration_flag: CALIBRATION_CURL="::SenseShift::Calibration::MinMaxCalibrator<uint16_t, 0, ANALOG_MAX>"
coverage: true
- os: ubuntu-latest
target: lucidgloves-prototype4-ffb
curl_calibration_flag: CALIBRATION_CURL="::SenseShift::Calibration::CenterPointDeviationCalibrator<uint16_t, 20, 270, 0, ANALOG_MAX>"
coverage: true
- os: ubuntu-latest
target: lucidgloves-prototype4-ffb
curl_calibration_flag: CALIBRATION_CURL="::SenseShift::Calibration::FixedCenterPointDeviationCalibrator<uint16_t, 20, 270, 0, ANALOG_MAX>"
coverage: true
- os: ubuntu-latest
target: indexer-csf
comm_flag: COMMUNICATION_PROTOCOL=OPENGLOVES_COMM_BTSERIAL
coverage: true
- os: ubuntu-latest
target: indexer-csf
comm_flag: COMMUNICATION_PROTOCOL=OPENGLOVES_COMM_BLESERIAL
coverage: true
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Get firmware name
id: firmware_name
run: |
./.github/scripts/get_firmware_name.sh ${{ matrix.target }} ${{ matrix.comm_flag }} ${{ matrix.curl_calibration_flag }}
- name: Speedup package installation
if: matrix.coverage
uses: abbbi/github-actions-tune@v1
- name: Setup LCOV
if: matrix.coverage
uses: hrishikesh-kadam/setup-lcov@v1
- 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/.cache
./.pio
key: ${{ runner.os }}-pio-${{ matrix.target }}-${{ hashFiles('platformio.ini') }}
restore-keys: |
${{ runner.os }}-pio-${{ matrix.target }}-
${{ runner.os }}-pio-
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Enable coverage (non-macOS)
if: runner.os != 'macOS' && matrix.coverage
run: |
sed -i '/__OH_FIRMWARE__/p; s/-D __OH_FIRMWARE__/-lgcov --coverage/' platformio.ini
- name: Enable coverage (macOS)
if: runner.os == 'macOS' && matrix.coverage
run: |
sed -i '' '/__OH_FIRMWARE__/p; s/-D __OH_FIRMWARE__/-lgcov --coverage/' platformio.ini
- name: Update build flags (non-macOS)
if: runner.os != 'macOS'
run: |
sed -i '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.curl_calibration_flag }}/' platformio.ini
sed -i '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.comm_flag }}/' platformio.ini
- name: Update build flags (macOS)
if: runner.os == 'macOS'
run: |
sed -i '' '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.curl_calibration_flag }}/' platformio.ini
sed -i '' '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.comm_flag }}/' platformio.ini
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
pio upgrade --dev
pio pkg update --global
- name: Install libs
run: pio pkg install -e ${{matrix.target}}
- name: Change memory segments
if: matrix.coverage
run: |
sed -i "s/len\s=\s0x2c200\s-\s0xdb5c/len = 2898880/" ~/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/memory.ld
sed -i "/\[env\]/p; s/\[env\]/board_build.partitions = huge_app.csv/" platformio.ini
- name: Build
if: matrix.coverage == false
run: |
echo "::group::platformio.ini"
cat platformio.ini
echo "::endgroup::"
pio run --environment ${{matrix.target}}
- name: Build (debug)
if: matrix.coverage
run: |
echo "::group::platformio.ini"
cat platformio.ini
echo "::endgroup::"
pio debug --environment ${{matrix.target}}
- name: Upload firmware Artifact
if: matrix.coverage == false
uses: actions/upload-artifact@v3
with:
name: ${{ steps.firmware_name.outputs.firmware }}
path: |
./.pio/build/${{matrix.target}}/firmware.bin
./.pio/build/${{matrix.target}}/firmware.elf
retention-days: 1
if-no-files-found: error
- name: Collect initial coverage
if: matrix.coverage
run: |
mkdir -p ./build/lcov
lcov -i -d ./.pio/build/${{matrix.target}}/ -c -o ./build/lcov/lcov.info.${{ steps.firmware_name.outputs.firmware }} -gcov-tool ~/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcov
- name: Upload coverage Artifact
uses: actions/upload-artifact@v3
if: matrix.coverage
with:
name: lcov.info.${{ steps.firmware_name.outputs.firmware }}
path: ./build/lcov/lcov.info.${{ steps.firmware_name.outputs.firmware }}
retention-days: 1
if-no-files-found: error
test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
target:
- native
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Speedup package installation
uses: abbbi/github-actions-tune@v1
- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1
- 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/.cache
./.pio
key: ${{ runner.os }}-pio-${{ matrix.target }}-${{ hashFiles('platformio.ini') }}
restore-keys: |
${{ runner.os }}-pio-${{ matrix.target }}
${{ runner.os }}-pio-
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
pio upgrade --dev
pio pkg update --global
- name: Install libs
run: pio pkg install -e ${{matrix.target}}
- name: Run Unit Tests
run: pio test -e ${{matrix.target}}
- name: Collect coverage report
run: |
mkdir -p ./build/lcov
lcov -d ./.pio/build/${{matrix.target}}/ -c -o ./build/lcov/lcov.info.${{matrix.target}}.test
- name: Upload coverage Artifact
uses: actions/upload-artifact@v3
with:
name: lcov.info.${{matrix.target}}.test
path: ./build/lcov/lcov.info.${{matrix.target}}.test
retention-days: 5
coverage-report:
needs:
- build-bhaptics
- build-opengloves
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Speedup package installation
uses: abbbi/github-actions-tune@v1
- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1
- name: Download all workflow run artifacts
id: download
uses: actions/download-artifact@v3
with:
path: build/artifacts
- name: Merge lcov files
run: |
mkdir ./build/lcov/
find ./build/artifacts -mindepth 2 -type f -exec mv '{}' ./build/lcov/ \;
ls -lahR ./build/lcov/
find ./build/lcov -name 'lcov.info.*' -exec echo -a {} \; | xargs lcov -o ./build/lcov/lcov.info
lcov --remove ./build/lcov/lcov.info '/usr/include/*' '*.platformio/*' '*/.pio/*' '*/tool-unity/*' '*/test/*' '*/MockArduino/*' '*/lib/frozen/*' -o ./build/lcov/lcov.info.cleaned
- name: Generate HTML report
run: genhtml -p $PWD -o ./build/coverage/ --demangle-cpp ./build/lcov/lcov.info.cleaned
- name: Upload coverage Artifact
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: |
./build/coverage/
retention-days: 5
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: ./build/lcov/lcov.info.cleaned
flags: unittests
wokwi:
needs:
- build-bhaptics
- build-opengloves
- test
runs-on: ubuntu-latest
strategy:
matrix:
variant:
- lucidgloves-prototype3+serial
- lucidgloves-prototype4+serial
steps:
- uses: actions/checkout@v3
- name: Extract target
id: target_name
run: |
target=$(echo ${{ matrix.variant }} | cut -d'+' -f1)
echo "target=$target" >> $GITHUB_OUTPUT
- name: Download firmware artifact
uses: actions/download-artifact@v3
with:
name: ${{ matrix.variant }}
path: ./.pio/build/${{ steps.target_name.outputs.target }}
- name: Run Wokwi scenario
uses: wokwi/wokwi-ci-action@v1
with:
token: ${{ secrets.WOKWI_CLI_TOKEN }}
path: ./.wokwi/${{ matrix.variant }}
scenario: "test.yaml"