|
| 1 | +name: Compile Examples |
| 2 | + |
| 3 | +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows |
| 4 | +on: |
| 5 | + push: |
| 6 | + paths: |
| 7 | + - ".github/workflows/**" |
| 8 | + - "examples/**" |
| 9 | + - "**.cpp" |
| 10 | + - "**.h" |
| 11 | + - "**.hpp" |
| 12 | + pull_request: |
| 13 | + paths: |
| 14 | + - ".github/workflows/**" |
| 15 | + - "examples/**" |
| 16 | + - "**.cpp" |
| 17 | + - "**.h" |
| 18 | + - "**.hpp" |
| 19 | + workflow_dispatch: |
| 20 | + repository_dispatch: |
| 21 | + |
| 22 | +jobs: |
| 23 | + # debounce job to reduce duplicate compilations, taken from https://stackoverflow.com/questions/75714742/do-not-trigger-github-action-workflow-on-push-if-a-pr-is-open-on-the-branch |
| 24 | + debounce: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + env: |
| 27 | + GH_TOKEN: ${{ github.token }} |
| 28 | + outputs: |
| 29 | + abort: ${{ steps.debounce.outputs.abort }} |
| 30 | + steps: |
| 31 | + - name: Debounce |
| 32 | + if: github.event_name == 'push' |
| 33 | + id: debounce |
| 34 | + run: | |
| 35 | + pr_branches=$(gh pr list --repo $GITHUB_REPOSITORY -q '.[] | select(.isCrossRepository == false)' --json isCrossRepository --json headRefName) |
| 36 | + this_branch=$(echo $GITHUB_REF | sed -e 's/refs\/heads\///') |
| 37 | + if [[ $(echo "$pr_branches" | grep "$this_branch") ]]; then |
| 38 | + echo "This push is associated with a pull request. Skipping the job." |
| 39 | + echo "abort=true" >> "$GITHUB_OUTPUT" |
| 40 | + fi |
| 41 | +
|
| 42 | + build: |
| 43 | + name: ${{ matrix.board.fqbn }} |
| 44 | + runs-on: ubuntu-latest |
| 45 | + needs: debounce |
| 46 | + if: needs.debounce.outputs.abort != 'true' |
| 47 | + |
| 48 | + env: |
| 49 | + SKETCHES_REPORTS_PATH: sketches-reports |
| 50 | + |
| 51 | + strategy: |
| 52 | + fail-fast: false |
| 53 | + |
| 54 | +# Of course we'll want to add all supported arches. See https://github.com/arduino-libraries/ArduinoIoTCloud/blob/master/.github/workflows/compile-examples.yml for a complex multi-board setup |
| 55 | + matrix: |
| 56 | + board: |
| 57 | + - fqbn: arduino:avr:uno |
| 58 | + platforms: | |
| 59 | + - name: arduino:avr |
| 60 | + internalid: arduino_avr # This is just some unique id string we assign for use in the artifact name (fqbn does not qualify due to containing colons) |
| 61 | + - fqbn: esp8266:esp8266:huzzah |
| 62 | + type: 8266 |
| 63 | + platforms: | |
| 64 | + - name: esp8266:esp8266 |
| 65 | + source-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json |
| 66 | + internalid: esp8266 |
| 67 | + - fqbn: STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 |
| 68 | + platforms: | |
| 69 | + - name: STMicroelectronics:stm32 |
| 70 | + source-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json |
| 71 | + internalid: stm32_official |
| 72 | + - fqbn: arduino:mbed_giga:giga |
| 73 | + platforms: | |
| 74 | + - name: arduino:mbed_giga |
| 75 | + internalid: arduino_giga |
| 76 | + # SAMD boards. There is also an Adrafruit fork of this core, and the two seem to have diverged, considerably. I have no idea on the differences. |
| 77 | + - fqbn: arduino:samd:adafruit_circuitplayground_m0 |
| 78 | + platforms: | |
| 79 | + - name: arduino:samd |
| 80 | + internalid: arduino_samd |
| 81 | + - fqbn: rp2040:rp2040:rpipico |
| 82 | + type: rp2040 |
| 83 | + platforms: | |
| 84 | + - name: rp2040:rp2040 |
| 85 | + source-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json |
| 86 | + internalid: rp2040 |
| 87 | + - fqbn: arduino:renesas_uno:minima |
| 88 | + platforms: | |
| 89 | + - name: arduino:renesas_uno |
| 90 | + internalid: arduino_unor4 |
| 91 | + |
| 92 | + steps: |
| 93 | + - name: Checkout repository |
| 94 | + uses: actions/checkout@v3 |
| 95 | + |
| 96 | + - name: Compile examples |
| 97 | + uses: arduino/compile-sketches@v1 |
| 98 | + with: |
| 99 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 100 | + fqbn: ${{ matrix.board.fqbn }} |
| 101 | + platforms: ${{ matrix.board.platforms }} |
| 102 | +# limit to only some sketches for now, while figuring out the workflow |
| 103 | + sketch-paths: | |
| 104 | + - examples/01.Basics |
| 105 | + - examples/02.Control |
| 106 | + - examples/06.Synthesis |
| 107 | + libraries: | |
| 108 | + - source-path: ./ |
| 109 | + - name: PinChangeInterrupt |
| 110 | + - name: MIDI Library |
| 111 | + - name: Arduino_AdvancedAnalog |
| 112 | + enable-deltas-report: true |
| 113 | + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} |
| 114 | + |
| 115 | + - name: Save sketches report as workflow artifact |
| 116 | + uses: actions/upload-artifact@v4 |
| 117 | + with: |
| 118 | + if-no-files-found: error |
| 119 | + path: ${{ env.SKETCHES_REPORTS_PATH }} |
| 120 | + name: sketches-reports-artifact-${{ matrix.board.internalid }} |
| 121 | + |
| 122 | + # When using a matrix to compile for multiple boards, it's necessary to use a separate job for the deltas report |
| 123 | + report: |
| 124 | + needs: build # Wait for the compile job to finish to get the data for the report |
| 125 | + if: github.event_name == 'pull_request' # Only run the job when the workflow is triggered by a pull request |
| 126 | + continue-on-error: true # Not the programmer's fault, if reporting fails |
| 127 | + runs-on: ubuntu-latest |
| 128 | + steps: |
| 129 | + # This step is needed to get the size data produced by the compile jobs |
| 130 | + - name: Download sketches reports artifact |
| 131 | + uses: actions/download-artifact@v4 |
| 132 | + with: |
| 133 | + pattern: sketches-reports-artifact-* |
| 134 | + merge-multiple: true |
| 135 | + path: ${{ env.SKETCHES_REPORTS_PATH }} |
| 136 | + |
| 137 | + - uses: arduino/report-size-deltas@v1 |
| 138 | + with: |
| 139 | + sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }} |
0 commit comments