Wokwi.com CI #28
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
--- | |
name: Wokwi.com CI | |
on: | |
push: | |
paths: | |
- '.github/workflows/wokwi_projects.yml' | |
pull_request: | |
paths: | |
- '.github/workflows/wokwi_projects.yml' | |
schedule: | |
- cron: "50 7 * * *" | |
workflow_dispatch: | |
jobs: | |
wokwi-check: | |
name: ${{ matrix.project.name }} | |
if: github.actor == 'esp-rs' | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
project: | |
# - name: "hello-world" | |
# id: "382725628217620481" | |
# path: "intro/hello-world" | |
- name: blinky | |
id: "382725482391094273" | |
path: "intro/blinky" | |
- name: button | |
id: "382725583123606529" | |
path: "intro/button" | |
- name: button-interrupt | |
id: "382723722184136705" | |
path: "intro/button-interrupt" | |
- name: panic | |
id: "382726300037178369" | |
path: "intro/panic" | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
- name: Download project code | |
run: | | |
wget -q -O ${{ matrix.project.name }}.zip https://wokwi.com/api/projects/${{ matrix.project.id }}/zip | |
unzip ${{ matrix.project.name }}.zip -d ${{ matrix.project.name }} | |
mkdir -p ${{ matrix.project.name }}/src | |
rm -rf ${{ matrix.project.path }}/src/*.rs | |
cp ${{ matrix.project.name }}/*.rs ${{ matrix.project.path }}/src/ | |
rm -rf ${{ matrix.project.path }}/Cargo.toml | |
cp ${{ matrix.project.name }}/Cargo.toml ${{ matrix.project.path }}/Cargo.toml | |
- name: Create wokwi.toml | |
run: echo -e "[wokwi]\nversion = 1\nfirmware = '${{ matrix.project.name }}/${{ matrix.project.name }}'\nelf = '${{ matrix.project.name }}/${{ matrix.project.name }}'" > ${{ matrix.project.path }}/wokwi.toml | |
- name: Update ownership | |
run: | | |
sudo chown 1000:1000 -R ${{ matrix.project.path }} | |
- name: Pull Docker image | |
run: docker image pull espressif/idf-rust:esp32c3_latest | |
- name: Test code example in Docker image | |
uses: addnab/docker-run-action@v3 | |
with: | |
image: espressif/idf-rust:esp32c3_latest | |
options: -u esp -v ${{ github.workspace }}:/home/esp/workspace | |
run: | | |
cd /home/esp/workspace/${{ matrix.project.path }} | |
export SSID="Wokwi-GUEST" && export PASSWORD="" | |
/home/esp/.cargo/bin/cargo build --release --out-dir /home/esp/workspace/${{ matrix.project.path }}/${{ matrix.project.name }} -Z unstable-options | |
rm -rf /home/esp/workspace/${{ matrix.project.path }}/target | |
- run: cat ${{ matrix.project.path }}/wokwi.toml | |
- name: Wokwi CI check | |
uses: wokwi/wokwi-ci-action@v1 | |
with: | |
token: ${{ secrets.WOKWI_CLI_TOKEN }} | |
path: ${{ matrix.project.path }} | |
timeout: 30000 | |
scenario: ${{ github.workspace }}/.github/${{ matrix.project.name }}.test.yaml | |
fail_text: 'Error' | |
- name: Upload source code | |
if: success() || failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.project.name }}_${{ matrix.project.id }} | |
path: ${{ matrix.project.path }} |