diff --git a/.github/scripts/find_all_boards.sh b/.github/scripts/find_all_boards.sh new file mode 100755 index 00000000000..a2c53c212c5 --- /dev/null +++ b/.github/scripts/find_all_boards.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Get all boards +boards_array=() + +for line in `grep '.tarch=' boards.txt`; do + board_name=$(echo "$line" | cut -d '.' -f1 | cut -d '#' -f1) + boards_array+=("espressif:esp32:$board_name") + echo "Added 'espressif:esp32:$board_name' to array" +done + +# Create JSON like string with all boards found and pass it to env variable +board_count=${#boards_array[@]} +echo "Boards found: $board_count" +echo "BOARD-COUNT=$board_count" >> $GITHUB_ENV + +if [ $board_count -gt 0 ] +then + json_matrix='[' + for board in ${boards_array[@]} + do + json_matrix+='"'$board'"' + if [ $board_count -gt 1 ] + then + json_matrix+="," + fi + board_count=$(($board_count - 1)) + done + json_matrix+=']' + + echo $json_matrix + echo "FQBNS=${json_matrix}" >> $GITHUB_ENV +else + echo "FQBNS=" >> $GITHUB_ENV +fi diff --git a/.github/workflows/allboards.yml b/.github/workflows/allboards.yml new file mode 100644 index 00000000000..ddd631b1bf8 --- /dev/null +++ b/.github/workflows/allboards.yml @@ -0,0 +1,86 @@ +name: Boards Test - Remote trigger + +# The workflow will run on remote dispath with event-type set to "test-boards" +on: + repository_dispatch: + types: [test-boards] + +jobs: + find-boards: + runs-on: ubuntu-latest + + outputs: + fqbns: ${{ env.FQBNS }} + board-count: ${{ env.BOARD-COUNT }} + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + ref: ${{ github.event.client_payload.branch }} + + - name: Get boards fqbns + run: + bash .github/scripts/find_all_boards.sh + + setup-chunks: + needs: find-boards + runs-on: ubuntu-latest + if: needs.find-boards.outputs.fqbns != '' + + outputs: + test-chunks: ${{ steps['set-test-chunks'].outputs['test-chunks'] }} + + steps: + - uses: actions/checkout@v3 + - run: npm install + - name: Setup jq + uses: dcarbone/install-jq-action@v1.0.1 + + - id: set-test-chunks + name: Set Chunks + run: + echo "test-chunks<> $GITHUB_OUTPUT + + echo "$( jq -nc '${{ needs.find-boards.outputs.fqbns }} | [_nwise( ${{ needs.find-boards.outputs.board-count }}/15 | ceil)]')" >> $GITHUB_OUTPUT + + echo "EOF" >> $GITHUB_OUTPUT + + test-boards: + needs: setup-chunks + runs-on: ubuntu-latest + + env: + REPOSITORY: | + - source-path: '.' + name: "espressif:esp32" + + strategy: + fail-fast: false + matrix: + chunk: ${{ fromJSON(needs.setup-chunks.outputs['test-chunks']) }} + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Echo FQBNS to file + run: + echo "$FQBN" > fqbns.json + env: + FQBN: ${{ toJSON(matrix.chunk) }} + + - name: Compile sketch + uses: P-R-O-C-H-Y/compile-sketches@main + with: + platforms: | + ${{ env.REPOSITORY }} + multiple-fqbn: true + multiple-fqbn-path: "fqbns.json" + use-json-file: false + enable-deltas-report: false + enable-warnings-report: false + cli-compile-flags: | + - --warnings="all" + sketch-paths: + "- ./libraries/ESP32/examples/CI/CIBoardsTest/CIBoardsTest.ino"