From 39bb8230ed0979f97ec2f5a42cab45c11034fb57 Mon Sep 17 00:00:00 2001 From: Hays Chan <25737801+hayschan@users.noreply.github.com> Date: Thu, 30 May 2024 18:30:41 +0800 Subject: [PATCH] chore: Update build and test workflow configuration using Wokwi --- .github/workflows/build_and_test.yml | 104 +++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 .github/workflows/build_and_test.yml diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml new file mode 100644 index 0000000..dd73ed6 --- /dev/null +++ b/.github/workflows/build_and_test.yml @@ -0,0 +1,104 @@ +name: Build and Test Application + +on: + pull_request: + branches: + - main + push: + branches: + - main + workflow_dispatch: + +env: + IDF_PATH: /opt/esp/idf + test_dirs: . + +defaults: + run: + shell: bash + +jobs: + build-test-app: + name: Build Test App + strategy: + fail-fast: false + matrix: + idf-branch: + - release-v5.0 + - release-v5.1 + target: + - esp32s3 + runs-on: ubuntu-22.04 + container: + image: espressif/idf:${{ matrix.idf-branch }} + steps: + - uses: actions/checkout@v3 + - name: Install Python Dependencies + run: | + . $IDF_PATH/export.sh + python -m pip install idf-build-apps + - name: Build Test Application with ESP-IDF + run: | + . $IDF_PATH/export.sh + idf-build-apps build \ + -p ${{ env.test_dirs }} \ + --target ${{ matrix.target }} \ + --recursive \ + --build-dir build_${{ matrix.target }}_${{ matrix.idf-branch }} + - name: Upload files to artifacts for run-target job + uses: actions/upload-artifact@v3 + with: + name: built_binaries_${{ matrix.target }}_${{ matrix.idf-branch }} + path: | + **/build**/bootloader/bootloader.bin + **/build**/partition_table/partition-table.bin + **/build**/*.bin + **/build**/*.elf + **/build**/flasher_args.json + if-no-files-found: error + + simulate-test: + name: Simulate Test on WokWi + needs: build-test-app + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' # Ensure this matches the Python version needed for your testing + - name: Download built binaries from build job + uses: actions/download-artifact@v2 + with: + name: built_binaries_${{ matrix.target }}_${{ matrix.idf-branch }} + - name: Install Python packages for PyTest + run: | + pip install \ + pytest-embedded \ + pytest-embedded-serial-esp \ + pytest-embedded-idf + - name: Run Test App in WokWi Simulator + run: | + pytest ${{ env.test_dirs }} \ + --embedded-services idf,wokwi \ + --tb short \ + --junit-xml test_wokwi_${{ matrix.target }}_${{ matrix.idf-branch }}.xml + - uses: actions/upload-artifact@v2 + with: + name: test_wokwi_${{ matrix.target }}_${{ matrix.idf-branch }}_junit + path: test_wokwi_${{ matrix.target }}_${{ matrix.idf-branch }}.xml + + publish-results: + name: Publish Test App results + needs: simulate-test + runs-on: ubuntu-20.04 + steps: + - name: Download Test results + uses: actions/download-artifact@v3 + with: + path: test_results + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + files: test_results/**/*.xml