From 0a6a246550662920243c11e8bc18d91c248c5101 Mon Sep 17 00:00:00 2001 From: Roman Leonov Date: Fri, 19 Apr 2024 10:25:21 +0200 Subject: [PATCH] feature(ci): Added CI job for esp-idf device examples build verification --- .github/ci/override_managed_component.py | 64 ++++++++++++++++++++++++ .github/workflows/build_idf_examples.yml | 28 +++++++++++ 2 files changed, 92 insertions(+) create mode 100644 .github/ci/override_managed_component.py create mode 100644 .github/workflows/build_idf_examples.yml diff --git a/.github/ci/override_managed_component.py b/.github/ci/override_managed_component.py new file mode 100644 index 0000000000..bae246804a --- /dev/null +++ b/.github/ci/override_managed_component.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Apache-2.0 + +import sys +import argparse +from pathlib import Path +from glob import glob +from idf_component_tools.manifest import ManifestManager + + +def override_with_local_component(component, local_path, app): + app_path = Path(app) + + absolute_local_path = Path(local_path).absolute() + if not absolute_local_path.exists(): + print('[Error] {} path does not exist'.format(local_path)) + raise Exception + if not app_path.exists(): + print('[Error] {} path does not exist'.format(app_path)) + raise Exception + + print('[Info] Processing app {}'.format(app)) + manager = ManifestManager(app_path / 'main', 'app') + if '/' not in component: + # Prepend with default namespace + component_with_namespace = 'espressif/' + component + + try: + manager.manifest_tree['dependencies'][component_with_namespace] = { + 'version': '*', + 'override_path': str(absolute_local_path) + } + except KeyError: + print('[Error] {} app does not depend on {}'.format(app, component_with_namespace)) + raise KeyError + + manager.dump() + + +def override_with_local_component_all(component, local_path, apps): + # Process wildcard, e.g. "app_prefix_*" + apps_with_glob = list() + for app in apps: + apps_with_glob += glob(app) + + # Go through all collected apps + for app in apps_with_glob: + try: + override_with_local_component(component, local_path, app) + except: + print("[Error] Could not process app {}".format(app)) + return -1 + return 0 + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('component', help='Existing component that the app depends on') + parser.add_argument('local_path', help='Path to component that will be used instead of the managed version') + parser.add_argument('apps', nargs='*', help='List of apps to process') + args = parser.parse_args() + sys.exit(override_with_local_component_all(args.component, args.local_path, args.apps)) diff --git a/.github/workflows/build_idf_examples.yml b/.github/workflows/build_idf_examples.yml new file mode 100644 index 0000000000..de68699dd4 --- /dev/null +++ b/.github/workflows/build_idf_examples.yml @@ -0,0 +1,28 @@ +name: Build ESP-IDF USB examples + +on: + schedule: + - cron: '0 0 * * SAT' # Saturday midnight + pull_request: + types: [opened, reopened, synchronize] + +jobs: + build: + strategy: + matrix: + idf_ver: ["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 ESP-IDF USB Device examples + shell: bash + run: | + . ${IDF_PATH}/export.sh + pip install idf-component-manager==1.5.2 idf-build-apps --upgrade + python .github/ci/override_managed_component.py tinyusb . ${IDF_PATH}/examples/peripherals/usb/device/tusb_* + cd ${IDF_PATH} + idf-build-apps find --path examples/peripherals/usb/device/ --recursive --target all --manifest-file examples/peripherals/.build-test-rules.yml + idf-build-apps build --path examples/peripherals/usb/device/ --recursive --target all --manifest-file examples/peripherals/.build-test-rules.yml