diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml new file mode 100644 index 000000000..df24d0eac --- /dev/null +++ b/.github/workflows/examples.yaml @@ -0,0 +1,106 @@ +# https://github.com/arduino/arduino-cli-example/blob/master/.github/workflows/test.yaml + +# This is the name of the workflow, visible on GitHub UI. +name: Build Examples + +# Here we tell GitHub to run the workflow when a commit +# is pushed or a Pull Request is opened. +on: [push, pull_request] + +# This is the list of jobs that will be run concurrently. +# Since we use a build matrix, the actual number of jobs +# started depends on how many configurations the matrix +# will produce. +jobs: + # This is the name of the job - can be whatever. + examples-matrix: + + # Here we tell GitHub that the jobs must be determined + # dynamically depending on a matrix configuration. + strategy: + matrix: + # The matrix will produce one job for each configuration + # parameter of type `board`, in this case a + # total of 3. + board: + - teensy41 + - teensy40 + - stm32f4 + flags: + - "-DQNETHERNET_ENABLE_RAW_FRAME_SUPPORT=1 -DQNETHERNET_DRIVER_W5500" + - "-DQNETHERNET_ENABLE_RAW_FRAME_SUPPORT=1" + + # This is usually optional but we need to statically define the + # FQBN of the boards we want to test for each platform. In the + # future the CLI might automatically detect and download the core + # needed to compile against a certain FQBN, at that point the + # following `include` section will be useless. + include: + # This works like this: when the board is "arduino:samd", the + # variable `fqbn` is set to "arduino:samd:nano_33_iot". + - board: teensy41 + platform: teensy:avr + fqbn: teensy:avr:teensy41 + url: https://www.pjrc.com/teensy/package_teensy_index.json + - board: teensy40 + platform: teensy:avr + fqbn: teensy:avr:teensy41 + url: https://www.pjrc.com/teensy/package_teensy_index.json + - board: stm32f4 + platform: STMicroelectronics:stm32 + fqbn: STMicroelectronics:stm32:GenF4 + url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json + + # This is the platform GitHub will use to run our workflow, we + # pick Windows for no particular reason. + runs-on: ubuntu-latest + + # This is the list of steps this job will run. + steps: + # First of all, we clone the repo using the `checkout` action. + - name: Checkout + uses: actions/checkout@v4 + + # We use the `arduino/setup-arduino-cli` action to install and + # configure the Arduino CLI on the system. + - name: Setup Arduino CLI + uses: arduino/setup-arduino-cli@v2 + + # We then install the platform, which one will be determined + # dynamically by the build matrix. + - name: Install Platform + run: | + arduino-cli --additional-urls ${{ matrix.url }} core update-index + arduino-cli --additional-urls ${{ matrix.url }} core install ${{ matrix.platform }} + arduino-cli lib install LiteOSCParser + + # Finally, we compile the sketch, using the FQBN that was set + # in the build matrix. + - name: Compile Examples + run: | + for example in examples/*; do + echo + echo "Building ${example}..." + echo -n "=========" + for i in $(seq 1 ${#example}); do echo -n "="; done + echo "====" + if [[ "${{ matrix.fqbn }}" =~ ^teensy: ]]; then + all_flags="$(arduino-cli compile --fqbn ${{ matrix.fqbn }} ${example} --show-properties |grep build.flags.defs) ${{ matrix.flags }}" + arduino-cli compile \ + --library . \ + --warnings all \ + --build-property "${all_flags}" \ + --fqbn ${{ matrix.fqbn }} ${example} #&> /dev/null + else + if [[ ${example} != examples/PixelPusherServer ]]; then + arduino-cli compile \ + --library . \ + --warnings all \ + --build-property compiler.cpp.extra_flags="${{ matrix.flags }}" \ + --build-property compiler.c.extra_flags="${{ matrix.flags }}" \ + --fqbn ${{ matrix.fqbn }} ${example} #&> /dev/null + else + echo Skipping. + fi + fi + done