forked from atomvm/AtomVM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runs the esp32 tests across 5 targets/models and 4 esp-idf versions. Including the wifi_example test. Signed-off-by: Peter M <[email protected]>
- Loading branch information
Showing
17 changed files
with
495 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# | ||
# Copyright 2022 Davide Bettio <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later | ||
# | ||
|
||
name: ESP32 Sim test | ||
|
||
on: | ||
push: | ||
paths: | ||
- ".github/workflows/esp32-build.yaml" | ||
- "CMakeLists.txt" | ||
- "libs/**" | ||
- "src/platforms/esp32/**" | ||
- "src/libAtomVM/**" | ||
- "tools/packbeam/**" | ||
pull_request: | ||
paths: | ||
- ".github/workflows/esp32-build.yaml" | ||
- "src/platforms/esp32/**" | ||
- "src/libAtomVM/**" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
cli_token: | ||
name: Determine WOKWI_CLI_TOKEN presence | ||
runs-on: ubuntu-latest | ||
outputs: | ||
token_check: ${{ steps.token_check.outputs.should-run }} | ||
|
||
steps: | ||
- name: Mark esp-sim-test job as 'to be run' | ||
id: token_check | ||
env: | ||
wokwi_secret: ${{ secrets.WOKWI_CLI_TOKEN }} | ||
run: | | ||
if [${{ env.wokwi_secret }} == '']; | ||
then | ||
echo "WOKWI_CLI_TOKEN not found" | ||
else | ||
echo "WOKWI_CLI_TOKEN found continuing" | ||
echo "should-run=true" >> $GITHUB_OUTPUT | ||
fi | ||
esp-sim-test: | ||
needs: cli_token | ||
runs-on: ubuntu-latest | ||
if: needs.cli_token.outputs.token_check == 'true' | ||
container: espressif/idf:${{ matrix.idf-version }} | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
matrix: | ||
esp-idf-target: ["esp32", "esp32s2", "esp32s3", "esp32c3", "esp32c6"] | ||
idf-version: | ||
- "v4.4.7" | ||
- "v5.0.6" | ||
- "v5.1.3" | ||
- "v5.2" | ||
exclude: | ||
- esp-idf-target: "esp32c6" | ||
idf-version: "v4.4.7" | ||
- esp-idf-target: "esp32c6" | ||
idf-version: "v5.0.6" | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install the Wokwi CLI | ||
run: curl -L https://raw.githubusercontent.com/petermm/wokwi-cli/patch-1/scripts/install.sh | sh | ||
|
||
- name: Install dependencies to build host AtomVM | ||
run: | | ||
set -eu | ||
apt update | ||
DEBIAN_FRONTEND=noninteractive apt install -y -q \ | ||
doxygen erlang-base erlang-dialyzer \ | ||
libglib2.0-0 libpixman-1-0 \ | ||
gcc g++ zlib1g-dev libsdl2-2.0-0 libslirp0 libmbedtls-dev | ||
- name: Install pytest and pytest-embedded plugins | ||
run: | | ||
set -e | ||
. $IDF_PATH/export.sh | ||
pip install pytest==8.0.2 \ | ||
pytest-embedded==1.8.1 \ | ||
pytest-embedded-idf==1.8.1 \ | ||
pytest-embedded-qemu==1.8.1 \ | ||
pytest-embedded-wokwi==1.8.1 | ||
- name: "Use simtest defaults" | ||
shell: bash | ||
working-directory: ./src/platforms/esp32/test/ | ||
run: | | ||
cp sdkconfig.simtest-defaults sdkconfig.defaults | ||
- name: "On Esp32 use board with sd card" | ||
if: matrix.esp-idf-target == 'esp32' | ||
shell: bash | ||
working-directory: ./src/platforms/esp32/test/ | ||
run: | | ||
cp diagram_esp32.json diagram.json | ||
- name: Build ESP32-sim tests using idf.py | ||
working-directory: ./src/platforms/esp32/test/ | ||
run: | | ||
set -e | ||
. $IDF_PATH/export.sh | ||
idf.py set-target ${{matrix.esp-idf-target}} | ||
idf.py build | ||
- name: Run ESP32-sim tests using Wokwi CI | ||
working-directory: ./src/platforms/esp32/test/ | ||
env: | ||
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }} | ||
timeout-minutes: 10 | ||
run: | | ||
set -e | ||
. $IDF_PATH/export.sh | ||
pytest -k 'test_atomvm_sim' --embedded-services=idf,wokwi --wokwi-timeout=90000 --target=${{ matrix.esp-idf-target }} -s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<!-- | ||
Copyright 2024 Davide Bettio <[email protected]> | ||
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later | ||
--> | ||
|
||
# AtomVM device tests | ||
|
||
AtomVM provides two paths for testing on device, the locally run QEMU emulator or the remote Wokwi CI. | ||
|
||
# QEMU testing | ||
|
||
Instructions for running the tests [on QEMU are documented here](https://www.atomvm.net/doc/main/build-instructions.html#running-tests-for-esp32). | ||
|
||
# Wokwi CI testing | ||
|
||
Wokwi CI is a commercial cloud CI, see [wokwi-ci/getting-started](https://docs.wokwi.com/wokwi-ci/getting-started), running it locally requires you to obtain a `WOKWI_CLI_TOKEN` and usage fees may apply - AtomVM uses it through the [pytest-embedded-wokwi](https://github.com/espressif/pytest-embedded/tree/main/pytest-embedded-wokwi) integration. | ||
|
||
## Github CI/Actions | ||
|
||
The `WOKWI_CLI_TOKEN` needs to be set in your repo secrets. | ||
|
||
## Installing prerequisites | ||
|
||
1. The Wokwi CLI needs to be installed: | ||
|
||
```shell | ||
curl -L https://wokwi.com/ci/install.sh | sh | ||
``` | ||
|
||
Or [alternative installation methods here](https://docs.wokwi.com/wokwi-ci/getting-started#cli-installation). | ||
|
||
2. `WOKWI_CLI_TOKEN` needs to be set in your enviroment variables: | ||
|
||
```shell | ||
export WOKWI_CLI_TOKEN="your-api-key" | ||
``` | ||
|
||
3. A recent pytest, and pytest-embedded must be installed: | ||
|
||
```shell | ||
$ pip install pytest==8.0.2 \ | ||
pytest-embedded==1.8.1 \ | ||
pytest-embedded-serial-esp==1.8.1 \ | ||
pytest-embedded-idf==1.8.1 \ | ||
pytest-embedded-wokwi==1.8.1 | ||
``` | ||
|
||
4. The ESP-IDF build environment must be installed and available: | ||
|
||
```shell | ||
$ get_idf | ||
``` | ||
|
||
## Running Wokwi CI | ||
|
||
1. We need to use a special sdkconfig different from the QEMU one: | ||
```shell | ||
$ cp sdkconfig.simtest-defaults sdkconfig.defaults | ||
``` | ||
2. Set `IDF_TARGET`, and run `idf.py set-target ${IDF_TARGET}`: | ||
```shell | ||
$ export IDF_TARGET=esp32 && idf.py set-target ${IDF_TARGET} | ||
``` | ||
3. Wokwi CI uses a `diagram.json`, to describe the device used (specific board, pin connections, sensors, sd card etc). When changing `IDF_TARGET`, we need to clean it out: | ||
|
||
```shell | ||
# only when changing IDF_TARGET | ||
$ rm diagram.json | ||
``` | ||
|
||
_NB!_ - on the `esp32` target, the SD card tests are enabled, so we need to use a special diagram.json, where a SD card is wired up: | ||
|
||
```shell | ||
# when using esp32 target | ||
$ cp diagram_esp32.json diagram.json | ||
``` | ||
|
||
For all other targets we run without diagram.json. | ||
|
||
4. Now we run `idf.py build` and run the CI: | ||
|
||
```shell | ||
$ idf.py build && pytest -k 'test_atomvm_sim' --embedded-services=idf,wokwi --wokwi-timeout=90000 --target=${IDF_TARGET} -s -W ignore::DeprecationWarning | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"version": 1, | ||
"author": "peter", | ||
"editor": "wokwi", | ||
"parts": [ | ||
{ | ||
"type": "board-esp32-devkit-c-v4", | ||
"id": "esp", | ||
"top": -28.8, | ||
"left": -196.76, | ||
"attrs": { "builder": "esp-idf" } | ||
}, | ||
{ "type": "wokwi-microsd-card", "id": "sd1", "top": 48.23, "left": 76.87, "attrs": {} } | ||
], | ||
"connections": [ | ||
[ "esp:TX", "$serialMonitor:RX", "", [] ], | ||
[ "esp:RX", "$serialMonitor:TX", "", [] ], | ||
[ "sd1:CS", "esp:5", "blue", [ "h38.4", "v19.26", "h-144", "v-48" ] ], | ||
[ "sd1:VCC", "esp:3V3", "red", [ "h76.8", "v105.74", "h-460.8", "v-201.6" ] ], | ||
[ "sd1:GND", "esp:GND.2", "black", [ "h67.2", "v-143.89", "h-316.8" ] ], | ||
[ "sd1:SCK", "esp:18", "yellow", [ "h57.6", "v67.19", "h-220.8", "v-76.8" ] ], | ||
[ "sd1:DO", "esp:19", "green", [ "h9.6", "v-38.29", "h-144", "v38.4" ] ], | ||
[ "sd1:DI", "esp:23", "magenta", [ "h38.4", "v-96.09", "h-288" ] ] | ||
], | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SPDX-License-Identifier: Apache-2.0 | ||
SPDX-FileCopyrightText: AtomVM Contributors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.