feat: Notestation #508
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Note Arduino CI | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| branches: [ master ] | |
| jobs: | |
| check_dockerfile_changed: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| changed: ${{ steps.filter.outputs.changed }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # TODO: This is a 3rd party GitHub action from some dude. Ideally, we'd | |
| # use something more "official". | |
| - name: Check if Dockerfile changed | |
| uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| base: 'master' | |
| filters: | | |
| changed: | |
| - '.devcontainer/Dockerfile' | |
| build_ci_docker_image: | |
| runs-on: ubuntu-latest | |
| needs: [check_dockerfile_changed] | |
| if: ${{ needs.check_dockerfile_changed.outputs.changed == 'true' }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Rebuild image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: .devcontainer/Dockerfile | |
| load: true | |
| tags: ghcr.io/blues/note_arduino_ci:latest | |
| outputs: type=docker,dest=/tmp/note_arduino_ci_image.tar | |
| - name: Upload image artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: note_arduino_ci_image | |
| path: /tmp/note_arduino_ci_image.tar | |
| run_tests: | |
| runs-on: ubuntu-latest | |
| needs: [build_ci_docker_image] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Load CI Docker image | |
| # Only load the Docker image artifact if build_ci_docker_image actually | |
| # ran (e.g. it wasn't skipped and was successful). | |
| if: ${{ needs.build_ci_docker_image.result == 'success' }} | |
| uses: ./.github/actions/load-ci-image | |
| - name: Run tests | |
| run: | | |
| docker run --rm --volume $(pwd):/note-arduino/ \ | |
| --workdir /note-arduino/ \ | |
| --entrypoint ./test/run_all_tests.sh \ | |
| --user root \ | |
| ghcr.io/blues/note_arduino_ci:latest | |
| - name: Adjust lcov source file paths for Coveralls | |
| run: sudo sed -i 's/\/note-arduino\///g' ./coverage/lcov.info | |
| - name: Publish test coverage | |
| uses: coverallsapp/github-action@master | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| path-to-lcov: ./coverage/lcov.info | |
| build_examples: | |
| runs-on: ubuntu-latest | |
| needs: [build_ci_docker_image] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| example-sketch: | |
| - ./examples/Example0_LibrarylessCommunication/Example0_LibrarylessCommunication.ino | |
| - ./examples/Example1_NotecardBasics/Example1_NotecardBasics.ino | |
| - ./examples/Example2_PeriodicCommunications/Example2_PeriodicCommunications.ino | |
| - ./examples/Example3_InboundPolling/Example3_InboundPolling.ino | |
| - ./examples/Example4_InboundInterrupts/Example4_InboundInterrupts.ino | |
| - ./examples/Example5_UsingTemplates/Example5_UsingTemplates.ino | |
| - ./examples/Example6_SensorTutorial/Example6_SensorTutorial.ino | |
| - ./examples/Example7_PowerControl/Example7_PowerControl.ino | |
| - ./examples/Example8_BinarySendReceive/Example8_BinarySendReceive.ino | |
| - ./examples/Example9_BinarySendReceiveChunked/Example9_BinarySendReceiveChunked.ino | |
| board: | |
| # Order: fqbn, extra-flags (matches build_example.sh parameter order) | |
| # Note: index URLs are pre-configured in Dockerfile, no need to specify here | |
| # adafruit: https://raw.githubusercontent.com/adafruit/arduino-board-index/gh-pages/package_adafruit_index.json | |
| - fqbn: adafruit:nrf52:feather52840:softdevice=s140v6 | |
| - fqbn: adafruit:samd:adafruit_feather_m4 | |
| # arduino: (built-in, no additional index needed) | |
| - fqbn: arduino:avr:uno | |
| - fqbn: arduino:mbed_nano:nano33ble | |
| # The mbed_nano platform generates compiler warning. | |
| # https://github.com/arduino/ArduinoCore-mbed/issues/1024 | |
| extra-flags: "-DMBED_CONF_NORDIC_NRF_LF_CLOCK_SRC=NRF_LF_SRC_XTAL" | |
| # esp32: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json | |
| - fqbn: esp32:esp32:featheresp32 | |
| # rp2040: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json | |
| - fqbn: rp2040:rp2040:rpipico | |
| # SparkFun: https://raw.githubusercontent.com/sparkfun/Arduino_Apollo3/main/package_sparkfun_apollo3_index.json | |
| - fqbn: SparkFun:apollo3:sfe_artemis_thing_plus | |
| # STMicroelectronics: https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/main/package_stmicroelectronics_index.json | |
| - fqbn: STMicroelectronics:stm32:Blues:pnum=CYGNET | |
| - fqbn: STMicroelectronics:stm32:Blues:pnum=SWAN_R5 | |
| - fqbn: STMicroelectronics:stm32:GenF4:pnum=FEATHER_F405 | |
| - fqbn: STMicroelectronics:stm32:Nucleo_32:pnum=NUCLEO_L432KC | |
| exclude: | |
| # Binary examples don't fit in AVR Uno's flash | |
| - board: | |
| fqbn: arduino:avr:uno | |
| example-sketch: ./examples/Example8_BinarySendReceive/Example8_BinarySendReceive.ino | |
| - board: | |
| fqbn: arduino:avr:uno | |
| example-sketch: ./examples/Example9_BinarySendReceiveChunked/Example9_BinarySendReceiveChunked.ino | |
| steps: | |
| - name: Checkout code | |
| id: checkout | |
| uses: actions/checkout@v4 | |
| - name: Load CI docker image | |
| if: ${{ needs.build_ci_docker_image.result == 'success' }} | |
| uses: ./.github/actions/load-ci-image | |
| - name: Compile Examples | |
| run: | | |
| docker run --rm --volume $(pwd):/note-arduino/ \ | |
| --workdir /note-arduino/ \ | |
| --entrypoint ./scripts/build_example.sh \ | |
| ghcr.io/blues/note_arduino_ci:latest \ | |
| "${{ matrix.board.fqbn }}" \ | |
| "${{ matrix.example-sketch }}" \ | |
| "${{ matrix.board.extra-flags }}" | |
| publish_ci_image: | |
| runs-on: ubuntu-latest | |
| # Make sure tests passed and examples built successfully before publishing. | |
| needs: [build_ci_docker_image, run_tests, build_examples] | |
| # Only publish the image if this is a push event and the Docker image was rebuilt. | |
| if: ${{ github.event_name == 'push' && needs.build_ci_docker_image.result == 'success' }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Push image to registry | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: .devcontainer/Dockerfile | |
| push: true | |
| tags: ghcr.io/blues/note_arduino_ci:latest |