feat(esp_delta_ota): Added pytest for the delta OTA example #1758
Workflow file for this run
This file contains hidden or 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
| name: Build and Run Apps | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # Once per day at midnight | |
| pull_request: | |
| types: [opened, reopened, synchronize] | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| prepare: | |
| name: Prepare pipeline | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| outputs: | |
| test_all_apps: ${{ steps.get_labels.outputs.test_all_apps }} | |
| build_only: ${{ steps.get_labels.outputs.build_only }} | |
| idf_build_apps_args: ${{ steps.find_changes.outputs.idf_build_apps_args }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'true' | |
| - name: Fix git repo permissions | |
| # Needed by the next git diff step. | |
| # See https://github.com/actions/runner/issues/2033 | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| build_dir=$PWD | |
| cd / | |
| git config --global --add safe.directory $build_dir | |
| cd - | |
| - name: Install dependencies | |
| run: pip install 'idf-build-apps~=2.12' | |
| - name: Get labels | |
| id: get_labels | |
| if: github.event_name == 'pull_request' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| # Check for labels | |
| # "PR: test all apps" | |
| # "PR: build only" | |
| run: | | |
| gh api --jq '.labels.[].name' /repos/{owner}/{repo}/pulls/${{ github.event.number }} > labels.txt | |
| test_all_apps=$(grep -c 'PR: test all apps' labels.txt || true) | |
| build_only=$(grep -c 'PR: build only' labels.txt || true) | |
| echo "test_all_apps=$test_all_apps" >> $GITHUB_OUTPUT | |
| echo "build_only=$build_only" >> $GITHUB_OUTPUT | |
| echo "test_all_apps=$test_all_apps" | |
| echo "build_only=$build_only" | |
| - name: Find changed files and components | |
| id: find_changes | |
| if: github.event_name == 'pull_request' && steps.get_labels.outputs.test_all_apps == '0' | |
| # - based on the files list, determine which components have changed | |
| # - output both lists as a file of idf-build-apps arguments | |
| run: | | |
| git fetch --recurse-submodules=no origin ${{ github.base_ref }}:base_ref | |
| git fetch --recurse-submodules=no origin pull/${{ github.event.pull_request.number }}/head:pr_ref | |
| git diff --name-only -r base_ref pr_ref > changed_files.txt | |
| python3 .github/get_idf_build_apps_args.py -v changed_files.txt idf_build_apps_args.txt | |
| echo "idf_build_apps_args=$(cat idf_build_apps_args.txt)" >> $GITHUB_OUTPUT | |
| echo "idf_build_apps_args=$(cat idf_build_apps_args.txt)" | |
| build: | |
| name: Build Apps | |
| needs: prepare | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| idf_ver: | |
| - "release-v5.1" | |
| - "release-v5.2" | |
| - "release-v5.3" | |
| - "release-v5.4" | |
| - "release-v5.5" | |
| - "latest" | |
| parallel_index: [1,2,3,4,5] # Update --parallel-count below when changing this | |
| runs-on: ubuntu-22.04 | |
| container: espressif/idf:${{ matrix.idf_ver }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'true' | |
| - name: Install dependencies | |
| shell: bash | |
| run: | | |
| export IDF_PYTHON_CHECK_CONSTRAINTS=yes | |
| ${IDF_PATH}/install.sh --enable-ci | |
| . ${IDF_PATH}/export.sh | |
| pip install --upgrade idf-component-manager 'idf-build-apps~=2.12' | |
| - name: Build apps | |
| shell: bash | |
| run: | | |
| . ${IDF_PATH}/export.sh | |
| export PEDANTIC_FLAGS="-DIDF_CI_BUILD -Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function" | |
| export EXTRA_CFLAGS="${PEDANTIC_FLAGS} -Wstrict-prototypes" | |
| export EXTRA_CXXFLAGS="${PEDANTIC_FLAGS}" | |
| idf-build-apps build --parallel-index ${{ matrix.parallel_index }} --parallel-count 5 --collect-app-info build_info_${{ matrix.idf_ver }}_${{ matrix.parallel_index }}.json ${{ needs.prepare.outputs.idf_build_apps_args }} | |
| - uses: actions/upload-artifact@v4 | |
| if: github.repository_owner == 'espressif' && needs.prepare.outputs.build_only == '0' | |
| with: | |
| name: app_binaries_${{ matrix.idf_ver }}_${{ matrix.parallel_index }} | |
| path: | | |
| */examples/*/build_esp*/bootloader/bootloader.bin | |
| */examples/*/build_esp*/partition_table/partition-table.bin | |
| */examples/*/build_esp*/*.bin | |
| */examples/*/build_esp*/flasher_args.json | |
| */examples/*/build_esp*/config/sdkconfig.json | |
| */test_app*/**/build_esp*/bootloader/bootloader.bin | |
| */test_app*/**/build_esp*/partition_table/partition-table.bin | |
| */test_app*/**/build_esp*/*.bin | |
| */test_app*/**/build_esp*/flasher_args.json | |
| */test_app*/**/build_esp*/config/sdkconfig.json | |
| build_info*.json | |
| build-linux: | |
| name: Build Apps for Linux | |
| needs: prepare | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| idf_ver: | |
| # Not building for 5.1 with linux target due to limited support | |
| - "release-v5.2" | |
| - "release-v5.3" | |
| - "release-v5.4" | |
| - "release-v5.5" | |
| - "latest" | |
| runs-on: ubuntu-22.04 | |
| container: | |
| image: espressif/idf:${{ matrix.idf_ver }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'true' | |
| - name: Install dependencies | |
| shell: bash | |
| run: | | |
| export IDF_PYTHON_CHECK_CONSTRAINTS=yes | |
| ${IDF_PATH}/install.sh --enable-ci | |
| . ${IDF_PATH}/export.sh | |
| pip install --upgrade idf-component-manager 'idf-build-apps~=2.12' | |
| - name: Build apps for Linux | |
| shell: bash | |
| run: | | |
| . ${IDF_PATH}/export.sh | |
| export PEDANTIC_FLAGS="-DIDF_CI_BUILD -Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function" | |
| export EXTRA_CFLAGS="${PEDANTIC_FLAGS} -Wstrict-prototypes" | |
| export EXTRA_CXXFLAGS="${PEDANTIC_FLAGS}" | |
| idf-build-apps build --target linux --collect-app-info build_info_linux_${{ matrix.idf_ver }}_${{ matrix.parallel_index }}.json ${{ needs.prepare.outputs.idf_build_apps_args }} | |
| - uses: actions/upload-artifact@v4 | |
| if: github.repository_owner == 'espressif' && needs.prepare.outputs.build_only == '0' | |
| with: | |
| name: app_binaries_${{ matrix.idf_ver }}_linux | |
| path: | | |
| */examples/*/build_linux*/*.elf | |
| */examples/*/build_linux*/config/sdkconfig.json | |
| */test_app*/**/build_linux*/*.elf | |
| */test_app*/**/build_linux*/config/sdkconfig.json | |
| build_info*.json | |
| run-target: | |
| name: Run apps on target | |
| if: github.repository_owner == 'espressif' && needs.prepare.outputs.build_only != '1' | |
| needs: [build] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| idf_ver: | |
| - "release-v5.1" | |
| - "release-v5.2" | |
| - "release-v5.3" | |
| - "release-v5.4" | |
| - "release-v5.5" | |
| - "latest" | |
| runner: | |
| - runs-on: "esp32" | |
| marker: "generic" | |
| target: "esp32" | |
| runner-labels: [self-hosted, linux, docker, "esp32"] | |
| pytest_args: "" | |
| - runs-on: "esp32s2" | |
| marker: "generic" | |
| target: "esp32s2" | |
| runner-labels: [self-hosted, linux, docker, "esp32s2"] | |
| pytest_args: "" | |
| - runs-on: "esp32s3" | |
| marker: "generic" | |
| target: "esp32s3" | |
| runner-labels: [self-hosted, linux, docker, "esp32s3"] | |
| pytest_args: "" | |
| - runs-on: "ESP32-ETHERNET-KIT" | |
| marker: "ethernet" | |
| target: "esp32" | |
| runner-labels: [self-hosted, linux, docker, "ESP32-ETHERNET-KIT"] | |
| pytest_args: "" | |
| - runs-on: "spi_nand_flash" | |
| marker: "spi_nand_flash" | |
| target: "esp32" | |
| runner-labels: [self-hosted, linux, docker, "spi_nand_flash"] | |
| pytest_args: "" | |
| - runs-on: "qemu" | |
| marker: "qemu" | |
| target: ["esp32s3", "esp32c3"] | |
| runner-labels: [self-hosted, linux, docker] | |
| pytest_args: "--embedded-services idf,qemu" | |
| env: | |
| TEST_RESULT_NAME: test_results_${{ matrix.runner.target }}_${{ matrix.runner.marker }}_${{ matrix.idf_ver }} | |
| TEST_RESULT_FILE: test_results_${{ matrix.runner.target }}_${{ matrix.runner.marker }}_${{ matrix.idf_ver }}.xml | |
| runs-on: ${{ matrix.runner.runner-labels }} | |
| container: | |
| image: python:3.11-bookworm | |
| options: --privileged # Privileged mode has access to serial ports | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: app_binaries_${{ matrix.idf_ver }}_* | |
| merge-multiple: true | |
| - name: Install Python packages | |
| env: | |
| PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi/" | |
| run: | | |
| pip install --prefer-binary cryptography pytest-embedded pytest-embedded-qemu pytest-embedded-serial-esp pytest-embedded-idf pytest-custom_exit_code | |
| - name: Setup QEMU | |
| if: matrix.runner.marker == 'qemu' | |
| run: | | |
| . .github/setup_qemu.sh | |
| echo "PATH=$PATH" >> $GITHUB_ENV | |
| - name: Run apps | |
| run: | | |
| python3 .github/get_pytest_args.py --target=${{ matrix.runner.target }} -v 'build_info*.json' pytest-args.txt | |
| cat pytest-args.txt | |
| pytest --suppress-no-test-exit-code $(cat pytest-args.txt) --ignore-glob '*/managed_components/*' --ignore=.github --junit-xml=${{ env.TEST_RESULT_FILE }} --target=${{ matrix.runner.target }} -m ${{ matrix.runner.marker }} --build-dir=build_${{ matrix.runner.target }} ${{ matrix.runner.pytest_args }} | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: ${{ env.TEST_RESULT_NAME }} | |
| path: ${{ env.TEST_RESULT_FILE }} | |
| run-target-linux: | |
| name: Run apps on Linux target | |
| if: github.repository_owner == 'espressif' && needs.prepare.outputs.build_only != '1' | |
| needs: [build-linux] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| idf_ver: | |
| # - "release-v5.1" # Not testing for 5.1 with linux target due to limited support | |
| - "release-v5.2" | |
| - "release-v5.3" | |
| - "release-v5.4" | |
| - "release-v5.5" | |
| - "latest" | |
| runner: | |
| - runs-on: "linux" | |
| marker: "host_test" | |
| target: "linux" | |
| pytest_args: "--embedded-services idf" | |
| exclude: | |
| - idf_ver: "release-v5.2" # Bug with Unity IDF test apps | |
| runner: | |
| target: "linux" | |
| env: | |
| TEST_RESULT_NAME: test_results_${{ matrix.runner.target }}_${{ matrix.runner.marker }}_${{ matrix.idf_ver }} | |
| TEST_RESULT_FILE: test_results_${{ matrix.runner.target }}_${{ matrix.runner.marker }}_${{ matrix.idf_ver }}.xml | |
| runs-on: ubuntu-latest | |
| container: | |
| image: python:3.14-slim-trixie # Newer Debian base to support newer glibc for Linux apps | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: app_binaries_${{ matrix.idf_ver }}_* | |
| merge-multiple: true | |
| - name: Install Python packages | |
| env: | |
| PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi/" | |
| run: | | |
| pip install --prefer-binary cryptography pytest-embedded pytest-embedded-serial-esp pytest-embedded-idf pytest-custom_exit_code | |
| - name: Make .elf files executable | |
| if: matrix.runner.target == 'linux' | |
| continue-on-error: true | |
| shell: bash | |
| run: | | |
| chmod +x */examples/*/build_linux*/*.elf || echo "No example .elf files found" | |
| shopt -s globstar | |
| chmod +x */test_app*/**/build_linux*/*.elf || echo "No test_app .elf files found" | |
| - name: Run apps | |
| shell: bash | |
| run: | | |
| python3 .github/get_pytest_args.py --target=${{ matrix.runner.target }} -v 'build_info*.json' pytest-args.txt | |
| cat pytest-args.txt | |
| pytest --suppress-no-test-exit-code $(cat pytest-args.txt) --ignore-glob '*/managed_components/*' --ignore=.github --junit-xml=${{ env.TEST_RESULT_FILE }} --target=${{ matrix.runner.target }} -m ${{ matrix.runner.marker }} --build-dir=build_${{ matrix.runner.target }} ${{ matrix.runner.pytest_args }} | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: ${{ env.TEST_RESULT_NAME }} | |
| path: ${{ env.TEST_RESULT_FILE }} | |
| publish-results: | |
| name: Publish Test results | |
| needs: | |
| - run-target | |
| - run-target-linux | |
| if: github.repository_owner == 'espressif' && always() && github.event_name == 'pull_request' && needs.prepare.outputs.build_only == '0' | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Download Test results | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: test_results_* | |
| path: test_results | |
| - name: Publish Test Results | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| with: | |
| files: test_results/**/*.xml |