Skip to content

fix: Add reading from serial port #114

fix: Add reading from serial port

fix: Add reading from serial port #114

Workflow file for this run

name: Build and Run Integration tests
on:
pull_request:
branches:
- main
push:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
# Cancel any currently running workflows from the same PR, branch, or
# tag when a new workflow is triggered.
#
# https://stackoverflow.com/a/66336834
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
jobs:
build-app:
name: Generate and Build App
strategy:
matrix:
board:
- mcu: esp32
target: xtensa-esp32-none-elf
- mcu: esp32c3
target: riscv32imc-unknown-none-elf
# - mcu: esp32c6
# target: riscv32imac-unknown-none-elf
- mcu: esp32h2
target: riscv32imac-unknown-none-elf
- mcu: esp32s2
target: xtensa-esp32s2-none-elf
- mcu: esp32s3
target: xtensa-esp32s3-none-elf
fail-fast: false
runs-on: ubuntu-22.04
steps:
- if: matrix.board.mcu == 'esp32' || matrix.board.mcu == 'esp32s2' || matrix.board.mcu == 'esp32s3'
uses: esp-rs/[email protected]
with:
default: true
buildtargets: ${{ matrix.board.mcu }}
ldproxy: false
- if: matrix.board.mcu != 'esp32' && matrix.board.mcu != 'esp32s2' && matrix.board.mcu != 'esp32s3'
uses: dtolnay/rust-toolchain@nightly
with:
target: ${{ matrix.board.target }}
components: rust-src
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v4
with:
repository: esp-rs/esp-hal
path: esp-hal
- run: cargo build --release --example hello_world
working-directory: esp-hal/${{ matrix.board.mcu }}-hal
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.board.mcu }}_app
path: esp-hal/${{ matrix.board.mcu }}-hal/target/${{ matrix.board.target }}/release/examples/hello_world
if-no-files-found: error
build-espflash:
name: Build espflash
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-target
with:
arch: x86_64
target: x86_64-unknown-linux-gnu
- name: Build espflash
run: cargo build --release
working-directory: espflash
- uses: actions/upload-artifact@v3
with:
name: espflash
path: target/release/espflash
if-no-files-found: error
run-target:
name: Run Tests on Target
if: ${{ github.repository_owner == 'esp-rs' }}
needs: [build-app, build-espflash]
runs-on: [self-hosted, linux, x64, "${{ matrix.board }}" ]
strategy:
matrix:
# board: [esp32, esp32c3, esp32c6, esp32h2, esp32s2, esp32s3]
board: [esp32, esp32c3, esp32h2, esp32s2, esp32s3]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: ${{ matrix.board }}_app
path: espflash/${{ matrix.board }}_app
- uses: actions/download-artifact@v3
with:
name: espflash
path: espflash_app
- name: interactive test
shell: bash
run: |
echo "$-"
if [[ $- == *i* ]]; then
echo "Shell is interactive"
else
echo "Shell is not interactive"
fi
- run: chmod +x espflash_app/espflash
- name: board-info test
env:
ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board }}
run: |
result=$(espflash_app/espflash board-info 2>&1)
echo "$result"
if ! echo "$result" | grep -q "esp32"; then
exit 1
fi
- name: erase-flash
env:
ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board }}
run: espflash_app/espflash erase-flash 2>&1
- name: flash test
env:
ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board }}
ESPFLASH_APP: espflash/${{ matrix.board }}_app/hello_world
shell: 'script -qec "bash {0}"'
run: |
result=$(timeout 20s espflash_app/espflash flash --monitor ${{ env.ESPFLASH_APP }} 2>&1)
echo "$result"
ret=$?
if [[ $ret -eq 124 ]]; then
ret=0
fi
if ! echo "$result" | grep -q "Flashing has completed!"; then
exit 1
fi
exit $ret
- name: cat serial port
env:
ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board }}
run: |
result=$(timeout 5s cat ${{ env.ESPFLASH_PORT }})
echo "$result"
if ! echo "$result" | grep -q "Hello world!"; then
exit 1
fi