Skip to content
172 changes: 172 additions & 0 deletions .github/workflows/build_and_run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: Build and Run

on:
pull_request:
types: [opened, reopened, synchronize]
workflow_dispatch:

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
idf_ver: ["release-v6.0"]
container:
image: espressif/idf:${{ matrix.idf_ver }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ws/zephyr
fetch-depth: 0

- name: Setup ESP-IDF environment
shell: bash
run: |
. ${IDF_PATH}/export.sh
cd ${IDF_PATH}
python --version
which xtensa-esp32s3-elf-gcc || true
which riscv32-esp-elf-gcc || true

- name: Install build tools (cmake, ninja, dtc, etc.)
shell: bash
run: |
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
cmake ninja-build gperf ccache \
device-tree-compiler \
python3-dev python3-pip python3-venv \
git wget xz-utils file \
dfu-util
rm -rf /var/lib/apt/lists/*

- name: Setup Zephyr west workspace + Python deps
shell: bash
run: |
cd /__w/${{ github.repository }}/__w/${{ github.repository }} || true
# In Actions containers, $GITHUB_WORKSPACE is set; use it reliably:
cd "$GITHUB_WORKSPACE"

cd ws
# Create workspace metadata
python3 -m venv .venv-zephyr
. .venv-zephyr/bin/activate
pip install -U pip wheel
pip install -r zephyr/scripts/requirements.txt \
-r zephyr/scripts/requirements-build-test.txt

west init -l zephyr
west update hal_espressif zephyr
west zephyr-export

- name: Twister build-only (ESP32S3)
shell: bash
env:
PYTEST_DISABLE_PLUGIN_AUTOLOAD: "1"
ZEPHYR_TOOLCHAIN_VARIANT: espressif
run: |
cd "$GITHUB_WORKSPACE"
# Activate IDF env (toolchain + python path)
. ${IDF_PATH}/export.sh

# Activate Zephyr venv (west + python deps)
. ws/.venv-zephyr/bin/activate

cd ws/zephyr

west twister \
-T samples/subsys/testsuite/pytest/shell \
-p esp32s3_devkitc/esp32s3/procpu \
-s sample.pytest.shell \
--build-only \
-j 1 -v --outdir ../../twister-out

- name: Pack twister-out artifact
shell: bash
run: |
cd "$GITHUB_WORKSPACE"
tar -czf twister-out.tgz twister-out

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: twister-out
path: twister-out.tgz
if-no-files-found: error

run:
if: startsWith(github.head_ref, 'pr-add-ci-') || startsWith(github.head_ref, 'pr-add-dwc2-')
runs-on: [self-hosted, esp32s3]
needs: [build]

steps:
- name: Checkout (workspace layout)
uses: actions/checkout@v4
with:
path: ws/zephyr
fetch-depth: 0

- name: Python venv + requirements (clean)
shell: bash
run: |
python3 -m venv ws/.venv
. ws/.venv/bin/activate
pip install -U pip wheel
pip install -r ws/zephyr/scripts/requirements.txt \
-r ws/zephyr/scripts/requirements-build-test.txt

- name: West init/update/export (runner)
shell: bash
run: |
. ws/.venv/bin/activate
cd ws
if [ ! -d .west ]; then
west init -l zephyr
fi
west update hal_espressif
west zephyr-export

- name: Download twister-out artifact
uses: actions/download-artifact@v4
with:
name: twister-out
path: .

- name: Unpack twister-out
shell: bash
run: |
rm -rf twister-out
tar -xzf twister-out.tgz

- name: Run on hardware (test-only)
shell: bash
env:
PYTEST_DISABLE_PLUGIN_AUTOLOAD: "1"
ZEPHYR_TOOLCHAIN_VARIANT: espressif
run: |
. ws/.venv/bin/activate
cd ws/zephyr

west twister \
-T samples/subsys/testsuite/pytest/shell \
-p esp32s3_devkitc/esp32s3/procpu \
-s sample.pytest.shell \
--test-only \
--device-testing \
--hardware-map tests/hil/hw/esp32s3/map-esp32s3.yml \
-j 1 -v --outdir ../../twister-out

- name: Upload Twister reports
if: always()
uses: actions/upload-artifact@v4
with:
name: twister-reports
path: |
twister-out/twister.xml
twister-out/twister_report.xml
twister-out/twister.json
7 changes: 7 additions & 0 deletions tests/hil/hw/esp32s3/map-esp32s3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- connected: true
id: /dev/ttyACM0
platform: esp32s3_devkitc/esp32s3/procpu
product: "ESP32-S3 DevKitC"
runner: esp32
serial: /dev/ttyACM0
flash_before: true
Loading