chore: cleanup (#116) #360
This file contains 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@v3 | |
# 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@v2 | |
id: filter | |
with: | |
base: 'master' | |
filters: | | |
changed: | |
- '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@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Rebuild image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
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@v3 | |
with: | |
name: note_arduino_ci_image | |
path: /tmp/note_arduino_ci_image.tar | |
run_tests: | |
runs-on: ubuntu-latest | |
if: ${{ always() }} | |
needs: [build_ci_docker_image] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Load CI Docker image | |
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 | |
if: ${{ always() }} | |
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 | |
fully-qualified-board-name: | |
- adafruit:nrf52:feather52840:softdevice=s140v6 | |
- adafruit:samd:adafruit_feather_m4 | |
# The binary examples don't fit in the Uno's flash. | |
# - arduino:avr:uno | |
# TODO: Fix this. May require upstream fix. | |
# - arduino:mbed_nano:nano33ble | |
- esp32:esp32:featheresp32 | |
- rp2040:rp2040:rpipico | |
- SparkFun:apollo3:sfe_artemis_thing_plus | |
- STMicroelectronics:stm32:BluesW:pnum=SWAN_R5 | |
- STMicroelectronics:stm32:GenF4:pnum=FEATHER_F405 | |
- STMicroelectronics:stm32:Nucleo_32:pnum=NUCLEO_L432KC | |
steps: | |
- name: Checkout code | |
id: checkout | |
uses: actions/checkout@v3 | |
- 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 ./examples/build_example.sh \ | |
ghcr.io/blues/note_arduino_ci:latest \ | |
${{ matrix.fully-qualified-board-name }} \ | |
${{ matrix.example-sketch }} | |
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: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Push image to registry | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
tags: ghcr.io/blues/note_arduino_ci:latest |