-
-
Notifications
You must be signed in to change notification settings - Fork 38
81 lines (68 loc) · 2.21 KB
/
wokwi_ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Wokwi CI
on: [pull_request]
jobs:
provide-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: |
TMP="["
for FILE in examples/*/*.ino; do TMP="$TMP\"$FILE\","; done
TMP="${TMP::-1}]"
echo "::set-output name=matrix::$TMP"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
run-ci:
needs: provide-examples
strategy:
matrix:
example: ${{ fromJson(needs.provide-examples.outputs.matrix) }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup cache
uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Prepare Example File
run: |
EXAMPLE_FILE=$(python .scripts/prepare_example.py ${{ matrix.example }})
EXAMPLE_NAME=$(basename $EXAMPLE_FILE .cpp)
cp $EXAMPLE_FILE src/main.cpp
if [ -f "test/$EXAMPLE_NAME.test.yml" ]; then
echo "TEST_FILE=test/$EXAMPLE_NAME.test.yml" >> $GITHUB_ENV
fi
- name: Prepare Test Script
if: env.TEST_FILE != ''
run: |
RUN_DURATION=$(python .scripts/prepare_workflow.py ${{ env.TEST_FILE }} ${{ vars.WOKWI_SERIAL_DELAY }})
echo "RUN_DURATION=$((RUN_DURATION + ${{ vars.WOKWI_TIMEOUT_BUFFER }}))" >> $GITHUB_ENV
- name: Install PlatformIO
if: env.TEST_FILE != ''
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Install library dependencies
if: env.TEST_FILE != ''
run: pio lib install
- name: Build PlatformIO
if: env.TEST_FILE != ''
run: pio run
env:
LOCAL_BUILD: 1
- name: Running ${{ env.TEST_FILE }} on Wokwi
if: env.TEST_FILE != ''
uses: wokwi/wokwi-ci-action@v1
with:
token: ${{ secrets.WOKWI_CLI_TOKEN }}
scenario: ${{ env.TEST_FILE }}
timeout: ${{ env.RUN_DURATION }}