|
| 1 | +name: Race Condition Test |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + race-condition-test: |
| 8 | + runs-on: ubuntu-24.04 |
| 9 | + strategy: |
| 10 | + fail-fast: false |
| 11 | + matrix: |
| 12 | + test: [ |
| 13 | + "examples.hello_esp32.main", |
| 14 | + "examples.hello_esp32_sync.main", |
| 15 | + "examples.micropython_esp32.main" |
| 16 | + ] |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + - uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version: "3.11" |
| 23 | + - run: pip install hatch |
| 24 | + - name: Run a Wokwi CI server |
| 25 | + uses: wokwi/wokwi-ci-server-action@v1 |
| 26 | + - name: Run race condition test for 30 minutes |
| 27 | + if: env.WOKWI_CLI_TOKEN != '' |
| 28 | + env: |
| 29 | + WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }} |
| 30 | + WOKWI_SLEEP_TIME: "5" # Shorter sleep time for more iterations |
| 31 | + run: | |
| 32 | + echo "Starting race condition test for ${{ matrix.test }}" |
| 33 | + echo "Test will run for 30 minutes..." |
| 34 | +
|
| 35 | + start_time=$(date +%s) |
| 36 | + end_time=$((start_time + 1800)) # 30 minutes = 1800 seconds |
| 37 | + iteration=1 |
| 38 | +
|
| 39 | + while [ $(date +%s) -lt $end_time ]; do |
| 40 | + echo "=== Iteration $iteration for ${{ matrix.test }} ===" |
| 41 | + echo "Time: $(date)" |
| 42 | +
|
| 43 | + if ! timeout 120 hatch run python -m ${{ matrix.test }}; then |
| 44 | + echo "ERROR: Test failed on iteration $iteration" |
| 45 | + echo "Failure time: $(date)" |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | +
|
| 49 | + echo "Iteration $iteration completed successfully" |
| 50 | + iteration=$((iteration + 1)) |
| 51 | +
|
| 52 | + # Small delay between iterations |
| 53 | + sleep 2 |
| 54 | + done |
| 55 | +
|
| 56 | + echo "Race condition test completed successfully after $((iteration - 1)) iterations" |
| 57 | + echo "Total runtime: 30 minutes" |
0 commit comments