From ddeaf3f048f74e1415f60d038b074196420159d4 Mon Sep 17 00:00:00 2001 From: Peter Marcisovsky Date: Thu, 18 Jan 2024 14:38:42 +0100 Subject: [PATCH] ci: enable ci - usb-related code from idf-extra-components migrated to new repo esp-usb - enable CI in the new esp-usb - refactor build_and_run_test_app_usb.yml to use idf-build-apps --- .build-test-rules.yml | 3 + .../workflows/build_and_run_test_app_usb.yml | 65 +++++++++++++++++++ .github/workflows/upload_component.yml | 49 ++++++++++++++ .idf_build_apps.toml | 8 +++ pytest.ini | 6 +- 5 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 .build-test-rules.yml create mode 100644 .github/workflows/build_and_run_test_app_usb.yml create mode 100644 .github/workflows/upload_component.yml create mode 100644 .idf_build_apps.toml diff --git a/.build-test-rules.yml b/.build-test-rules.yml new file mode 100644 index 00000000..9eab2183 --- /dev/null +++ b/.build-test-rules.yml @@ -0,0 +1,3 @@ +usb/test_app: + enable: + - if: IDF_TARGET in ["esp32s2", "esp32s3"] \ No newline at end of file diff --git a/.github/workflows/build_and_run_test_app_usb.yml b/.github/workflows/build_and_run_test_app_usb.yml new file mode 100644 index 00000000..ca7e598d --- /dev/null +++ b/.github/workflows/build_and_run_test_app_usb.yml @@ -0,0 +1,65 @@ +name: Build and Run USB Test Application + +on: + schedule: + - cron: '0 0 * * SAT' # Saturday midnight + pull_request: + types: [opened, reopened, synchronize] + +jobs: + build: + name: Build USB Test App + strategy: + fail-fast: false + matrix: + idf_ver: ["release-v4.4", "release-v5.0", "release-v5.1", "release-v5.2", "latest"] + runs-on: ubuntu-20.04 + container: espressif/idf:${{ matrix.idf_ver }} + steps: + - uses: actions/checkout@v3 + with: + submodules: 'true' + - name: Build USB Test Application + shell: bash + run: | + . ${IDF_PATH}/export.sh + pip install idf-component-manager idf-build-apps --upgrade + 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 find + idf-build-apps build + - uses: actions/upload-artifact@v2 + with: + name: usb_test_app_bin_${{ matrix.idf_ver }} + path: | + usb/test_app/build_esp*/bootloader/bootloader.bin + usb/test_app/build_esp*/partition_table/partition-table.bin + usb/test_app/build_esp*/usb_test_app.bin + usb/test_app/build_esp*/usb_test_app.elf + usb/test_app/build_esp*/flasher_args.json + + run-target: + name: Run USB Test App on target + if: ${{ github.repository_owner == 'espressif' }} + needs: build + strategy: + fail-fast: false + matrix: + idf_ver: ["release-v5.0", "release-v5.1", "release-v5.2", "latest"] + idf_target: ["esp32s2"] + runs-on: [self-hosted, linux, docker, "${{ matrix.idf_target }}", "usb_host"] + container: + image: python:3.7-buster + options: --privileged # Privileged mode has access to serial ports + steps: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v2 + with: + name: usb_test_app_bin_${{ matrix.idf_ver }} + - name: Install Python packages + env: + PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi/" + run: pip install --only-binary cryptography pytest-embedded pytest-embedded-serial-esp pytest-embedded-idf pyserial + - name: Run USB Test App on target + run: pytest --target=${{ matrix.idf_target }} -m usb_host --build-dir=build_${{ matrix.idf_target }} \ No newline at end of file diff --git a/.github/workflows/upload_component.yml b/.github/workflows/upload_component.yml new file mode 100644 index 00000000..d05f61ad --- /dev/null +++ b/.github/workflows/upload_component.yml @@ -0,0 +1,49 @@ +name: Push components to Espressif Component Service + +on: + # For pull requests: perform upload with "--dry-run" argument, + # i.e. validate that the component passes all checks for being uploaded. + pull_request: + + # For pushes to master: actually upload the components to the registry. + push: + branches: + - master + +jobs: + upload_components: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + - run: | + echo "${{ ( github.ref_name != 'master' || github.repository_owner != 'espressif' ) && 'Checking' || 'Uploading' }} components" + - name: Upload components to component service + uses: espressif/upload-components-ci-action@v1 + with: + # Please try to keep the directories list sorted. + # + # Do note, however, that if you are updating two components in the same PR + # and one depends on the other, the new version of the 2nd component won't + # be found in the registry when the 1st component is uploaded. + # + # This is only a problem if you are adding two components for the first time, + # or if the 2nd component depends on the exact (new) version of the first one. + # + directories: > + usb/esp_modem_usb_dte; + usb/esp_tinyusb; + usb/usb_host_cdc_acm; + usb/usb_host_ch34x_vcp; + usb/usb_host_cp210x_vcp; + usb/usb_host_ftdi_vcp; + usb/usb_host_hid; + usb/usb_host_msc; + usb/usb_host_uvc; + usb/usb_host_vcp; + namespace: "espressif" + # API token will only be available in the master branch in the main repository. + # However, dry-run doesn't require a valid token. + api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }} + dry_run: ${{ github.ref_name != 'master' || github.repository_owner != 'espressif' }} \ No newline at end of file diff --git a/.idf_build_apps.toml b/.idf_build_apps.toml new file mode 100644 index 00000000..2c873059 --- /dev/null +++ b/.idf_build_apps.toml @@ -0,0 +1,8 @@ +target = "all" +paths = "usb/test_app" +recursive = true +manifest_file = ".build-test-rules.yml" +check_warnings = true + +# build related options +build_dir = "build_@t" \ No newline at end of file diff --git a/pytest.ini b/pytest.ini index 2cdf30fb..e95d52a4 100644 --- a/pytest.ini +++ b/pytest.ini @@ -10,18 +10,14 @@ addopts = markers = # target markers - esp32: support esp32 target esp32s2: support esp32s2 target esp32s3: support esp32s3 target - esp32c3: support esp32c3 target - esp32c2: support esp32c2 target - supported_targets: support all supported targets ('esp32', 'esp32s2', 'esp32c3', 'esp32s3', 'esp32c2') + supported_targets: support all supported targets ('esp32s2', 'esp32s3') # env markers generic: generic runner usb_host: usb host runners usb_device: usb device runners - ethernet: ethernet runners # log related log_cli = True