generated from BrandonElectronic/ESP-PROJECT-TEMPLATE
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update build and test workflow configuration using Wokwi
- Loading branch information
Showing
1 changed file
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |