Skip to content

👷 (Wokwi): Run scenarios on examples #19

👷 (Wokwi): Run scenarios on examples

👷 (Wokwi): Run scenarios on examples #19

Workflow file for this run

name: PlatformIO CI
on:
pull_request:
paths:
- "examples/**/*"
- "src/**/*"
push:
paths:
- "examples/**/*"
- "src/**/*"
jobs:
platformio:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
example:
- "PCA9685/Servo"
- "PCA9685/VibroPulse"
- "MPU6050/BasicReadings"
boards: [ [ uno, esp32dev ] ]
env:
PLATFORMIO_BUILD_DIR: "~/.build/${{ matrix.example }}"
steps:
- uses: actions/checkout@v4
- id: metadata
run: |
# get 1st element from the example path as lowercase
DEVICE=$(echo "${{ matrix.example }}" | cut -d'/' -f1 | tr '[:upper:]' '[:lower:]')
echo "device=$DEVICE" >> "$GITHUB_OUTPUT"
# check if example folder contains a wokwi.toml file
SHOULD_UPLOAD_ARTIFACTS=$(test -f "examples/${{ matrix.example }}/wokwi.toml" && echo "true" || echo "false")
echo "upload_artifact=$SHOULD_UPLOAD_ARTIFACTS" >> "$GITHUB_OUTPUT"
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v4
with:
path: |
~/.platformio/.cache
./.pio
key: ${{ runner.os }}-pio-${{ hashFiles('**/*.ini') }}
restore-keys: |
${{ runner.os }}-pio-
- name: Set up Python
uses: actions/setup-python@v5
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: Build example
run: |
mkdir -p $PLATFORMIO_BUILD_DIR
pio ci --lib="." --board=${{ join(matrix.boards, ' --board=') }} --build-dir=$PLATFORMIO_BUILD_DIR --keep-build-dir
env:
PLATFORMIO_CI_SRC: "./examples/${{ matrix.example }}/*.ino"
- name: Upload artifacts
if: steps.metadata.outputs.upload_artifact == 'true'
uses: actions/upload-artifact@v4
with:
name: example-${{ matrix.example }}
path: |
${{ env.PLATFORMIO_BUILD_DIR }}/firmware.bin
${{ env.PLATFORMIO_BUILD_DIR }}/firmware.elf
${{ env.PLATFORMIO_BUILD_DIR }}/firmware.hex
retention-days: 1