|  | 
|  | 1 | +name: Run tests in hardware | 
|  | 2 | + | 
|  | 3 | +on: | 
|  | 4 | + pull_request: | 
|  | 5 | + types: [opened, reopened, synchronize, labeled] | 
|  | 6 | + | 
|  | 7 | + schedule: | 
|  | 8 | + - cron: '0 2 * * *' | 
|  | 9 | + | 
|  | 10 | +env: | 
|  | 11 | + MAX_CHUNKS: 15 | 
|  | 12 | + | 
|  | 13 | +concurrency: | 
|  | 14 | + group: hil-${{github.event.pull_request.number || github.ref}} | 
|  | 15 | + cancel-in-progress: true | 
|  | 16 | + | 
|  | 17 | +jobs: | 
|  | 18 | + gen_chunks: | 
|  | 19 | + if: | | 
|  | 20 | + contains(github.event.pull_request.labels.*.name, 'hil_test') || | 
|  | 21 | + github.event_name == 'schedule' | 
|  | 22 | + name: Generate Chunks matrix | 
|  | 23 | + runs-on: ubuntu-latest | 
|  | 24 | + outputs: | 
|  | 25 | + chunks: ${{ steps.gen-chunks.outputs.chunks }} | 
|  | 26 | + steps: | 
|  | 27 | + - name: Checkout Repository | 
|  | 28 | + uses: actions/checkout@v2 | 
|  | 29 | + | 
|  | 30 | + - name: Generate Chunks matrix | 
|  | 31 | + id: gen-chunks | 
|  | 32 | + run: | | 
|  | 33 | + set +e | 
|  | 34 | + bash .github/scripts/sketch_utils.sh count tests | 
|  | 35 | + sketches=$((? - 1)) | 
|  | 36 | + if [[ $sketches -gt ${{env.MAX_CHUNKS}} ]]; then | 
|  | 37 | + $sketches=${{env.MAX_CHUNKS}} | 
|  | 38 | + fi | 
|  | 39 | + set -e | 
|  | 40 | + rm sketches.txt | 
|  | 41 | + CHUNKS=$(jq -c -n '$ARGS.positional' --args `seq 0 1 $sketches`) | 
|  | 42 | + echo "::set-output name=chunks::${CHUNKS}" | 
|  | 43 | +
 | 
|  | 44 | + Build: | 
|  | 45 | + needs: gen_chunks | 
|  | 46 | + name: ${{matrix.chip}}-Build#${{matrix.chunks}} | 
|  | 47 | + runs-on: ubuntu-latest | 
|  | 48 | + strategy: | 
|  | 49 | + matrix: | 
|  | 50 | + chip: ['esp32', 'esp32s2', 'esp32c3'] | 
|  | 51 | + chunks: ${{fromJson(needs.gen_chunks.outputs.chunks)}} | 
|  | 52 | + | 
|  | 53 | + steps: | 
|  | 54 | + - name: Checkout Repository | 
|  | 55 | + uses: actions/checkout@v2 | 
|  | 56 | + | 
|  | 57 | + - name: Build sketches | 
|  | 58 | + run: | | 
|  | 59 | + bash .github/scripts/tests_build.sh ${{matrix.chip}} ${{matrix.chunks}} ${{env.MAX_CHUNKS}} | 
|  | 60 | + - name: Upload ${{matrix.chip}}-${{matrix.chunks}} artifacts | 
|  | 61 | + uses: actions/upload-artifact@v2 | 
|  | 62 | + with: | 
|  | 63 | + name: ${{matrix.chip}}-${{matrix.chunks}}.artifacts | 
|  | 64 | + path: | | 
|  | 65 | + tests/*/build/*.bin | 
|  | 66 | + tests/*/build/*.json | 
|  | 67 | + Test: | 
|  | 68 | + needs: [gen_chunks, Build] | 
|  | 69 | + name: ${{matrix.chip}}-Test#${{matrix.chunks}} | 
|  | 70 | + runs-on: ESP32 | 
|  | 71 | + strategy: | 
|  | 72 | + fail-fast: false | 
|  | 73 | + matrix: | 
|  | 74 | + chip: ['esp32', 'esp32s2', 'esp32c3'] | 
|  | 75 | + chunks: ${{fromJson(needs.gen_chunks.outputs.chunks)}} | 
|  | 76 | + container: | 
|  | 77 | + image: python:3.10.1-bullseye | 
|  | 78 | + options: --privileged | 
|  | 79 | + | 
|  | 80 | + steps: | 
|  | 81 | + - name: Checkout repository | 
|  | 82 | + uses: actions/checkout@v2 | 
|  | 83 | + | 
|  | 84 | + - name: Download ${{matrix.chip}}-${{matrix.chunks}} artifacts | 
|  | 85 | + uses: actions/download-artifact@v2 | 
|  | 86 | + with: | 
|  | 87 | + name: ${{matrix.chip}}-${{matrix.chunks}}.artifacts | 
|  | 88 | + path: tests/ | 
|  | 89 | + | 
|  | 90 | + - name: Check Artifacts | 
|  | 91 | + run: | | 
|  | 92 | + ls -R tests | 
|  | 93 | + cat tests/*/build/build.options.json | 
|  | 94 | +
 | 
|  | 95 | + - name: Install dependencies | 
|  | 96 | + run: | | 
|  | 97 | + pip install -U pip | 
|  | 98 | + pip install -r tests/requirements.txt | 
|  | 99 | +
 | 
|  | 100 | + - name: Run Tests | 
|  | 101 | + run: | | 
|  | 102 | + bash .github/scripts/tests_run.sh ${{matrix.chip}} ${{matrix.chunks}} ${{env.MAX_CHUNKS}} | 
|  | 103 | +
 | 
|  | 104 | + - name: Upload test result artifacts | 
|  | 105 | + uses: actions/upload-artifact@v2 | 
|  | 106 | + if: always() | 
|  | 107 | + with: | 
|  | 108 | + name: test_results-${{matrix.chip}}-${{matrix.chunks}} | 
|  | 109 | + path: tests/*/*.xml | 
|  | 110 | + | 
|  | 111 | + event_file: | 
|  | 112 | + name: "Event File" | 
|  | 113 | + needs: Test | 
|  | 114 | + runs-on: ubuntu-latest | 
|  | 115 | + steps: | 
|  | 116 | + - name: Upload | 
|  | 117 | + uses: actions/upload-artifact@v2 | 
|  | 118 | + with: | 
|  | 119 | + name: Event File | 
|  | 120 | + path: ${{github.event_path}} | 
0 commit comments