Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Sockets for C++ SIL #255

Sockets for C++ SIL

Sockets for C++ SIL #255

name: Build and Test Projects
on: [pull_request, workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install PlatformIO Core
run: pip install --upgrade platformio
- name: Test PlatformIO Libaries and Projects
shell: bash
run: |
git ls-files -z '**/platformio.ini' | while IFS= read -r -d '' ini; do
dir=$(dirname "$ini")
if [ -d "$dir/test" ]; then
echo "============================================================"
echo "==== Testing $dir"
echo "============================================================"
pio test --project-dir "$dir" -vvv || exit 1
else
echo "No tests found in $dir"
fi
done
- name: Build PlatformIO Projects
shell: bash
run: |
git ls-files -z 'projects/**/platformio.ini' | while IFS= read -r -d '' ini; do
dir=$(dirname "$ini")
echo "============================================================"
echo "==== Building $dir"
echo "============================================================"
pio run --project-dir "$dir" -vvv || exit 1
done
- name: Perform Static Code Analysis on PlatformIO Projects
shell: bash
run: |
git ls-files -z 'projects/**/platformio.ini' | grep -zv 'projects/demo/' | while IFS= read -r -d '' ini; do
dir=$(dirname "$ini")
echo "============================================================"
echo "==== Performing Static Code Analysis on $dir"
echo "============================================================"
SUBDIRS=("$dir/src" "$dir/include")
EXCLUDE_PREFIX="stm*"
# Check for changes in $dir/src and $dir/include, excluding files within $dir/src/platforms/stm*
if git diff --name-only origin/main...HEAD -- "${SUBDIRS[@]}" ":!$dir/src/platforms/$EXCLUDE_PREFIX" | grep -q .; then
echo "Changes detected in $dir → running pio check"
pio check --project-dir "$dir" --flags "--checks=bugprone-*,clang-analyzer-*,google-*,performance-*" --fail-on-defect=high || exit 1
else
echo "No changes in $dir → skipping"
fi
done