Skip to content

Merge pull request #16 from playmiel/dev #177

Merge pull request #16 from playmiel/dev

Merge pull request #16 from playmiel/dev #177

Workflow file for this run

name: Library Tests
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
schedule:
# Run tests weekly to catch dependency issues
- cron: '0 0 * * 0'
workflow_dispatch:
jobs:
test-dependencies:
runs-on: ubuntu-latest
strategy:
matrix:
platform: [esp32dev]
include:
- platform: esp32dev
async-tcp-repo: "https://github.com/ESP32Async/AsyncTCP.git"
test-name: "latest"
steps:
- uses: actions/checkout@v4
- 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
- name: Cache PlatformIO
uses: actions/cache@v4
with:
path: |
~/.platformio/.cache
key: ${{ runner.os }}-pio-${{ hashFiles('platformio.ini') }}
- name: Test with AsyncTCP version
run: |
mkdir -p /tmp/dep_test/lib/ESPAsyncWebClient
mkdir -p /tmp/dep_test/src
cp -r src/* /tmp/dep_test/lib/ESPAsyncWebClient/
# Create test sketch
cat > /tmp/dep_test/src/main.cpp << 'EOF'
#include <Arduino.h>
#include <WiFi.h>
#include <ESPAsyncWebClient.h>
AsyncHttpClient client;
void setup() {
Serial.begin(115200);
// Test basic functionality
client.setTimeout(5000);
client.setUserAgent("Test/1.0");
client.setHeader("Content-Type", "application/json");
Serial.println("Testing AsyncTCP version: ${{ matrix.test-name }}");
}
void loop() {
delay(1000);
}
EOF
# Create platformio.ini with specific dependency version
cat > /tmp/dep_test/platformio.ini << EOF
[platformio]
default_envs = ${{ matrix.platform }}
[env]
framework = arduino
platform_packages =
framework-arduinoespressif32@^3
lib_deps =
${{ matrix.async-tcp-repo }}
bblanchon/ArduinoJson@^6.21.0
[env:esp32dev]
platform = espressif32
board = esp32dev
EOF
cd /tmp/dep_test
pio run -e ${{ matrix.platform }}
code-quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check code formatting
run: |
# Check for common issues
echo "Checking for TODO/FIXME comments..."
grep -r "TODO\|FIXME" src/ || true
echo "Checking for debug prints..."
grep -r "Serial.print.*debug\|DEBUG" src/ || true
echo "Checking for memory leaks indicators..."
grep -r "new\|malloc" src/ || true
echo "Code quality check completed!"
test-different-arduino-versions:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- platform: esp32dev
framework-version: "espressif32"
platform-packages: "framework-arduinoespressif32@^3"
name: "ESP32 Arduino Core 3.x"
steps:
- uses: actions/checkout@v4
- 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
- name: Cache PlatformIO
uses: actions/cache@v4
with:
path: |
~/.platformio/.cache
key: ${{ runner.os }}-pio-${{ hashFiles('platformio.ini') }}
- name: Test with Arduino framework version ${{ matrix.name }}
run: |
mkdir -p /tmp/framework_test/lib/ESPAsyncWebClient
mkdir -p /tmp/framework_test/src
cp -r src/* /tmp/framework_test/lib/ESPAsyncWebClient/
cat > /tmp/framework_test/src/main.cpp << 'EOF'
#include <Arduino.h>
#include <WiFi.h>
#include <ESPAsyncWebClient.h>
AsyncHttpClient client;
void setup() {
Serial.begin(115200);
Serial.println("Testing framework compatibility");
}
void loop() {
delay(1000);
}
EOF
# Prepare platform_packages line if defined
PLATFORM_PACKAGES=""
if [ ! -z "${{ matrix.platform-packages }}" ]; then
PLATFORM_PACKAGES="platform_packages = ${{ matrix.platform-packages }}"
fi
cat > /tmp/framework_test/platformio.ini << EOF
[platformio]
default_envs = esp32dev
[env:esp32dev]
platform = ${{ matrix.framework-version }}
board = esp32dev
framework = arduino
$PLATFORM_PACKAGES
lib_deps =
https://github.com/ESP32Async/AsyncTCP.git
bblanchon/ArduinoJson@^6.21.0
EOF
cd /tmp/framework_test
pio run -e esp32dev
cpp-unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Cache PlatformIO
uses: actions/cache@v4
with:
path: |
~/.platformio/.cache
key: ${{ runner.os }}-pio-${{ hashFiles('platformio.ini') }}
- name: Run native unit tests (UrlParser)
if: ${{ hashFiles('test/**') != '' }}
run: |
echo "Detected test files:" $(ls test || true)
pio test -e native -f test_urlparser_native -v
- name: Skip notice (no tests found)
if: ${{ hashFiles('test/**') == '' }}
run: echo "No test directory present in this ref; skipping native tests."
python-parse-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
- name: Run pytest parse url mirror
run: |
pytest -q test_parse_url.py
chunk-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Cache PlatformIO
uses: actions/cache@v4
with:
path: |
~/.platformio/.cache
key: ${{ runner.os }}-pio-${{ hashFiles('platformio.ini') }}
- name: Build HTTP unit tests (no upload)
run: |
pio test -e esp32dev -f test_chunk_parse -f test_redirects --without-uploading --without-testing