From fccb3bf762b1c4b4d9bcab1601f1f2479f99b8f9 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Fri, 10 Jan 2025 10:17:13 +0100 Subject: [PATCH] feat: Test wokwi simulation --- .github/workflows/wokwi_ci.yml | 94 +++++++++++++++++++ .../scenarios/embassy_executor_benchmark.yaml | 8 ++ qa-test/scenarios/ram.yaml | 7 ++ 3 files changed, 109 insertions(+) create mode 100644 .github/workflows/wokwi_ci.yml create mode 100644 qa-test/scenarios/embassy_executor_benchmark.yaml create mode 100644 qa-test/scenarios/ram.yaml diff --git a/.github/workflows/wokwi_ci.yml b/.github/workflows/wokwi_ci.yml new file mode 100644 index 00000000000..66cd2282281 --- /dev/null +++ b/.github/workflows/wokwi_ci.yml @@ -0,0 +1,94 @@ +name: Simulate QA Tests + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + merge_group: + workflow_dispatch: + inputs: + repository: + description: "Owner and repository to test" + required: true + default: 'esp-rs/esp-hal' + branch: + description: "Branch, tag or SHA to checkout." + required: true + default: "main" + +# Cancel any currently running workflows from the same PR, branch, or +# tag when a new workflow is triggered. +# +# https://stackoverflow.com/a/66336834 +concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + +env: + CARGO_TERM_COLOR: always + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + +jobs: + simulate-qa-tests: + name: Simulate | ${{ matrix.qa-test }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + device: [ + # RISC-V devices: + { soc: "esp32c3", target: "riscv32imc-unknown-none-elf", board: "board-esp32-c3-devkitm-1" }, + { soc: "esp32c6", target: "riscv32imac-unknown-none-elf", board: "board-esp32-c6-devkitc-1" }, + { soc: "esp32h2", target: "riscv32imac-unknown-none-elf", board: "board-esp32-h2-devkitm-1" }, + # Xtensa devices: + { soc: "esp32", target: "xtensa-esp32-none-elf", board: "board-esp32-devkit-c-v4" }, + { soc: "esp32s2", target: "xtensa-esp32s2-none-elf", board: "board-esp32-s2-devkitm-1" }, + { soc: "esp32s3", target: "xtensa-esp32s3-none-elf", board: "board-esp32-s3-devkitc-1" }, + ] + qa-test: [embassy_executor_benchmark, ram] + + steps: + - uses: actions/checkout@v4 + + # Install the Rust toolchain for Xtensa devices: + - uses: esp-rs/xtensa-toolchain@v1.5 + if: contains(fromJson('["esp32", "esp32s2", "esp32s3"]'), matrix.device.soc) + with: + ldproxy: false + version: 1.83.0.1 + # Install the Rust stable toolchain for RISC-V devices: + - uses: dtolnay/rust-toolchain@v1 + if: ${{ !contains(fromJson('["esp32", "esp32s2", "esp32s3"]'), matrix.device.soc) }} + with: + target: riscv32imc-unknown-none-elf,riscv32imac-unknown-none-elf + toolchain: stable + components: rust-src + + - uses: Swatinem/rust-cache@v2 + + - name: Build qa-tests + run: cargo xtask build-examples qa-test ${{ matrix.device.soc }} ${{ matrix.qa-test }} + + - name: Create wokwi.toml + run: echo -e "[wokwi]\nversion = 1\nfirmware = 'target/${{ matrix.device.target }}/release/${{ matrix.qa-test }}'\nelf = 'target/${{ matrix.device.target }}/release/${{ matrix.qa-test }}'" > qa-test/wokwi.toml + + - name: Create diagram.json + run: | + echo '{ + "version": 1, + "author": "esp-rs", + "editor": "wokwi", + "parts": [ { "type": "${{ matrix.device.board }}", "id": "esp", "top": 0, "left": 0, "attrs": {} } ], + "connections": [ [ "esp:TX", "$serialMonitor:RX", "", [] ], [ "esp:RX", "$serialMonitor:TX", "", [] ] ], + "dependencies": {} + }' > qa-test/diagram.json + + - name: Run simulation + uses: wokwi/wokwi-ci-action@v1 + with: + token: ${{ secrets.WOKWI_CLI_TOKEN }} + path: qa-test + timeout: 10000 + scenario: qa-test/scenarios/${{ matrix.qa-test }}.yaml + fail_text: 'Error' diff --git a/qa-test/scenarios/embassy_executor_benchmark.yaml b/qa-test/scenarios/embassy_executor_benchmark.yaml new file mode 100644 index 00000000000..a7a436ccee8 --- /dev/null +++ b/qa-test/scenarios/embassy_executor_benchmark.yaml @@ -0,0 +1,8 @@ +name: Embassy Executor Benchmark Test +version: 1 +author: esp-rs + +steps: + - wait-serial: "Embassy initialized!" + - wait-serial: "Starting test" + - wait-serial: "Test OK, count=" diff --git a/qa-test/scenarios/ram.yaml b/qa-test/scenarios/ram.yaml new file mode 100644 index 00000000000..32517013bdd --- /dev/null +++ b/qa-test/scenarios/ram.yaml @@ -0,0 +1,7 @@ +name: Ram Test +version: 1 +author: esp-rs + +steps: + - wait-serial: "IRAM function located at " + - wait-serial: "Restarting in"