Answers "how do we emulate/lint this?" with runnable tooling for every part, and factors the pure firmware logic out so it is unit-testable on the host. What changed: - firmware/src/wav.h, firmware/src/httprange.h: pure, header-only WAV header builder and HTTP Range parser (no Arduino deps), so the tricky byte-layout and range logic can be tested on a PC. storage.cpp and api_http.cpp refactored to use them. - firmware/test/test_pure/: Unity tests for the WAV header fields and Range parsing (start-end, open-ended, clamped, unsatisfiable, non-bytes). Run: pio test -e native. - firmware/platformio.ini: add [env:native] (host tests) and [env:esp32s3_wokwi] (emulator build with default WiFi = Wokwi-GUEST so the API comes up in the sim). - firmware/wokwi.toml + firmware/diagram.json: Wokwi emulator harness (ESP32-S3 + microSD + button + LED). Note: Wokwi has no I2S mic part, so audio isn't emulated; the harness targets boot + WiFi + REST API. - firmware/src/main.cpp + config.cpp: bring up WiFi + API even if audio/SD init fails (device stays reachable, reports the fault via GET /device); compile-time default WiFi honoured when NVS is empty (used by the Wokwi build). - .forgejo/workflows/ci.yml: add native tests + cppcheck to the firmware job; new openapi job (openapi-spec-validator) and emulator job (Wokwi build, plus a full run when WOKWI_CLI_TOKEN is set). - docs/testing.md: the full emulate/lint guide for firmware, server, API, app, case. - state/: NOTES points at the guide; TODO reflects this branch. Why: - The firmware can't be flashed yet (no parts) and doesn't build on this dev host, so we need host-runnable checks. Pure-logic unit tests + OpenAPI validation run anywhere; Wokwi emulates boot/WiFi/API; CI compiles the real firmware. Verified locally: the OpenAPI spec validates (12 paths, 10 schemas). Notes: - Native tests and cppcheck run in CI (no compiler on the dev host). The Wokwi full run is skipped unless a WOKWI_CLI_TOKEN secret is present; the build is still verified. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
83 lines
No EOL
2.6 KiB
YAML
83 lines
No EOL
2.6 KiB
YAML
# SPDX-License-Identifier: GPL-3.0-only
|
|
# OpenScribe CI - runs on the self-hosted Forgejo Actions runner.
|
|
name: ci
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
|
|
jobs:
|
|
firmware:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
- name: Install PlatformIO
|
|
run: pip install platformio
|
|
- name: Build firmware (both board profiles)
|
|
working-directory: firmware
|
|
run: |
|
|
pio run -e esp32s3_dev
|
|
pio run -e xiao_esp32s3
|
|
- name: Native unit tests (pure logic)
|
|
working-directory: firmware
|
|
run: pio test -e native
|
|
- name: Static analysis (cppcheck)
|
|
working-directory: firmware
|
|
run: pio check -e esp32s3_dev --fail-on-defect high --skip-packages
|
|
|
|
openapi:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
- name: Validate OpenAPI spec
|
|
run: |
|
|
pip install openapi-spec-validator pyyaml
|
|
python -c "from openapi_spec_validator import validate; import yaml; validate(yaml.safe_load(open('api/openapi.yaml'))); print('OpenAPI valid')"
|
|
|
|
emulator:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
- name: Build Wokwi firmware
|
|
working-directory: firmware
|
|
run: |
|
|
pip install platformio
|
|
pio run -e esp32s3_wokwi
|
|
- name: Run in Wokwi (skipped without a token)
|
|
working-directory: firmware
|
|
env:
|
|
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
|
|
run: |
|
|
if [ -z "$WOKWI_CLI_TOKEN" ]; then
|
|
echo "No WOKWI_CLI_TOKEN secret set - skipping the emulator run (build still verified)."
|
|
exit 0
|
|
fi
|
|
curl -L https://wokwi.com/ci/install.sh | sh
|
|
~/.wokwi/wokwi-cli --timeout 15000 --expect-text "API at http" .
|
|
|
|
server:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
- name: Install server deps
|
|
working-directory: server
|
|
run: |
|
|
pip install fastapi uvicorn pydantic pydantic-settings python-multipart ruff pytest
|
|
- name: Lint
|
|
working-directory: server
|
|
run: ruff check app
|
|
- name: Import check
|
|
working-directory: server
|
|
run: python -c "from app.main import app; print('server imports OK')" |