Skip to content

👷 (Wokwi): Run scenarios on examples #9

👷 (Wokwi): Run scenarios on examples

👷 (Wokwi): Run scenarios on examples #9

Workflow file for this run

name: PlatformIO CI
on:
pull_request:
branches:
- main
- master
- develop
- feature/mpu6050
paths-ignore:
- "**/*.md"
push:
branches:
- main
- master
- develop
- feature/mpu6050
paths-ignore:
- "**/*.md"
jobs:
platformio:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
example:
- "examples/PCA9685/Servo/Servo.ino"
- "examples/PCA9685/VibroPulse/VibroPulse.ino"
boards: [ [ uno, esp32dev ] ]
steps:
- uses: actions/checkout@v4
# We will skip the build if there are no changes in the examples or src folder
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
"examples/**/*.ino"
"src/**/*"
- name: Extract device name
id: device
run: |
# get 2nd element from the example path as lowercase
DEVICE=$(echo "${{ matrix.example }}" | cut -d'/' -f2 | tr '[:upper:]' '[:lower:]')
echo "device=$DEVICE" >> "$GITHUB_OUTPUT"
- name: Check if the build is necessary
id: should-build
run: |
if [ -z "${{ steps.changed-files.outputs.all_modified_files }}" ]; then
echo "No changes in the examples or src folder. Skipping the build."
echo "should_build=false" >> "$GITHUB_OUTPUT"
else
echo "Changes detected in the examples or src folder. Proceeding with the build."
echo "should_build=true" >> "$GITHUB_OUTPUT"
fi
- name: Cache pip
if : ${{ steps.should-build.outputs.should_build == 'true' }}
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
if : ${{ steps.should-build.outputs.should_build == 'true' }}
uses: actions/cache@v4
with:
path: |
~/.platformio/.cache
./.pio
key: ${{ runner.os }}-pio-${{ hashFiles('**/*.ini') }}
restore-keys: |
${{ runner.os }}-pio-
- name: Set up Python
if : ${{ steps.should-build.outputs.should_build == 'true' }}
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install PlatformIO
if : ${{ steps.should-build.outputs.should_build == 'true' }}
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
pio upgrade --dev
pio pkg update --global
- name: Build example
if : ${{ steps.should-build.outputs.should_build == 'true' }}
run: |
pio ci --lib="." --board=${{ join(matrix.boards, ' --board=') }}
env:
PLATFORMIO_CI_SRC: ${{ matrix.example }}