|
| 1 | +name: build |
| 2 | + |
| 3 | +on: [push, pull_request, workflow_dispatch] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + |
| 9 | + strategy: |
| 10 | + matrix: |
| 11 | + board: ["Arduino Uno", "Arduino Leonardo", "Arduino Mega 2560"] |
| 12 | + include: |
| 13 | + - board: "Arduino Uno" # board name, human-readable (matching board array above) |
| 14 | + platform: "arduino:avr" # board platform, to be installed by the CLI |
| 15 | + fqbn: "arduino:avr:uno" # fully qualified board name |
| 16 | + - board: "Arduino Leonardo" |
| 17 | + platform: "arduino:avr" |
| 18 | + fqbn: "arduino:avr:leonardo" |
| 19 | + - board: "Arduino Mega 2560" |
| 20 | + platform: "arduino:avr" |
| 21 | + fqbn: "arduino:avr:mega:cpu=atmega2560" |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v2 |
| 26 | + |
| 27 | + - name: Setup Arduino CLI |
| 28 | + |
| 29 | + |
| 30 | + - name: Install Board Platform |
| 31 | + run: | |
| 32 | + arduino-cli core update-index |
| 33 | + arduino-cli core install ${{ matrix.platform }} |
| 34 | +
|
| 35 | + - name: Add Library Symbolic Link to Repo |
| 36 | + run: | |
| 37 | + mkdir --parents "$HOME/Arduino/libraries" |
| 38 | + ln --symbolic "$PWD" "$HOME/Arduino/libraries/." |
| 39 | +
|
| 40 | + - name: Compile Library Examples |
| 41 | + run: | |
| 42 | + buildSketchPath() { |
| 43 | + sktch=${1##*/examples/}; |
| 44 | + sktch=${sktch%/*.ino}; |
| 45 | + echo -e "\nBuilding sketch $sktch.ino"; |
| 46 | + arduino-cli compile --fqbn ${{ matrix.fqbn }} "$1"; |
| 47 | + } |
| 48 | + buildExampleSketch() { |
| 49 | + buildSketchPath "$PWD/examples/$1/$2/$2.ino"; |
| 50 | + } |
| 51 | + buildExampleFolder() { |
| 52 | + IFS=$'\n'; set -f; |
| 53 | + for f in $(find $PWD/examples/"$1" -name '*.ino'); |
| 54 | + do |
| 55 | + buildSketchPath $f; |
| 56 | + done; |
| 57 | + unset IFS; set +f; |
| 58 | + } |
| 59 | + buildExampleSketch Any DebugPrint |
| 60 | + buildExampleSketch Any IdentifyController |
| 61 | + buildExampleSketch Any MultipleTypes |
| 62 | + buildExampleSketch Any SpeedTest |
| 63 | + if [ "$MULTI2C" = "true" ]; then |
| 64 | + echo "Board has 2 or more I2C buses"; |
| 65 | + buildExampleSketch Any MultipleBus; |
| 66 | + else |
| 67 | + echo "Board has only 1 I2C bus, not building MultipleBus example"; |
| 68 | + fi |
| 69 | + buildExampleFolder "Classic Controller" |
| 70 | + buildExampleFolder "DJ" |
| 71 | + buildExampleFolder "Drums" |
| 72 | + buildExampleFolder "Guitar" |
| 73 | + buildExampleFolder "NES Mini" |
| 74 | + buildExampleFolder "Nunchuk" |
| 75 | + buildExampleFolder "SNES Mini" |
| 76 | + buildExampleFolder "uDraw Tablet" |
| 77 | + buildExampleFolder "Drawsome Tablet" |
0 commit comments