Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
//"dockerFile": "../.github/actions/compile-examples/Dockerfile",
"dockerFile": "../.github/actions/run-tests-in-container/Dockerfile",
"dockerFile": "../Dockerfile",

// Set *default* container specific settings.json values on container create.
"settings": {},
Expand Down
17 changes: 0 additions & 17 deletions .github/actions/compile-examples/action.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/actions/load-ci-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Load note-arduino CI Docker image'
runs:
using: 'composite'
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Download image artifact
uses: actions/download-artifact@v2
with:
name: note_arduino_ci_image
path: /tmp

- name: Load Docker image
shell: bash
run: |
docker load --input /tmp/note_arduino_ci_image.tar
27 changes: 0 additions & 27 deletions .github/actions/run-tests-in-container/Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions .github/actions/run-tests-in-container/action.yml

This file was deleted.

202 changes: 151 additions & 51 deletions .github/workflows/note-arduino-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,157 @@ on:
branches: [ master ]

jobs:
validate_library: # job id
runs-on: ubuntu-latest
steps:
- name: Checkout Code
id: checkout
uses: actions/checkout@v3
- name: Run Tests In Container
id: containerized_tests
uses: ./.github/actions/run-tests-in-container
- name: Coveralls Action Bug Workaround
id: coveralls_bug_workaround
run: sudo sed -i 's/github\/workspace/home\/runner\/work\/note-arduino\/note-arduino/g' ./coverage/lcov.info
- name: Publish Test Coverage
id: publish_coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
validate_examples: # job id
# 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
continue-on-error: true
strategy:
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:
- STMicroelectronics:stm32:BluesW:pnum=SWAN_R5
- esp32:esp32:featheresp32
- adafruit:samd:adafruit_feather_m4
- STMicroelectronics:stm32:GenF4:pnum=FEATHER_F405
- arduino:mbed_nano:nano33ble
- SparkFun:apollo3:sfe_artemis_thing_plus
- STMicroelectronics:stm32:Nucleo_32:pnum=NUCLEO_L432KC
- adafruit:nrf52:feather52840:softdevice=s140v6
- rp2040:rp2040:rpipico
- arduino:avr:uno
if: ${{ always() }}
# needs: [build_ci_docker_image]

steps:
- name: Checkout Code
id: checkout
- name: Checkout code
uses: actions/checkout@v3
- name: Compile Examples
id: compile_examples
uses: ./.github/actions/compile-examples
with:
example-sketch: ${{ matrix.example-sketch }}
fully-qualified-board-name: ${{ matrix.fully-qualified-board-name }}

# - 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 \
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]
# continue-on-error: true
# strategy:
# 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
# # TODO: Uncomment these once note-c is updated with the necessary NoteBinary* functions.
# # - ./examples/Example8_BinarySendReceive/Example8_BinarySendReceive.ino
# # - ./examples/Example9_BinarySendReceiveChunked/Example9_BinarySendReceiveChunked.ino
# fully-qualified-board-name:
# - STMicroelectronics:stm32:BluesW:pnum=SWAN_R5
# - esp32:esp32:featheresp32
# - adafruit:samd:adafruit_feather_m4
# - STMicroelectronics:stm32:GenF4:pnum=FEATHER_F405
# # TODO: Fix this. May require upstream fix.
# # - arduino:mbed_nano:nano33ble
# - SparkFun:apollo3:sfe_artemis_thing_plus
# - STMicroelectronics:stm32:Nucleo_32:pnum=NUCLEO_L432KC
# - adafruit:nrf52:feather52840:softdevice=s140v6
# - rp2040:rp2040:rpipico
# - arduino:avr:uno

# 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
15 changes: 6 additions & 9 deletions .github/actions/compile-examples/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 Blues Inc. All rights reserved.
# Copyright 2023 Blues Inc. All rights reserved.
# Use of this source code is governed by licenses granted by the
# copyright holder including that found in the LICENSE file.

Expand Down Expand Up @@ -55,11 +55,16 @@ RUN ["dash", "-c", "\
bash-completion \
ca-certificates \
curl \
g++ \
gdb \
gzip \
lcov \
python-is-python3 \
python3 \
python3-pip \
ssh \
tree \
valgrind \
&& pip install \
adafruit-nrfutil \
pyserial \
Expand Down Expand Up @@ -104,11 +109,3 @@ RUN ["dash", "-c", "\
&& arduino-cli core install STMicroelectronics:stm32 \
&& arduino-cli lib install \"Blues Wireless Notecard Pseudo Sensor\" \
"]

# Set Execution Environment
USER root
WORKDIR /host-volume

ENTRYPOINT ["arduino-cli"]

CMD ["help"]
19 changes: 19 additions & 0 deletions examples/build_example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
NOTE_ARDUINO_DIR="$SCRIPT_DIR/.."

# If this is being run inside a Docker container (i.e. for GitHub actions CI),
# copy the latest note-arduino code into the appropriate place so that it can
# be consumed when building the example.
if grep -sq 'docker\|lxc' /proc/1/cgroup; then
cp -r $NOTE_ARDUINO_DIR $HOME/Arduino/libraries/Blues_Wireless_Notecard
fi

arduino-cli compile \
--build-property compiler.cpp.extra_flags='-Wno-unused-parameter -Werror' \
--fqbn $1 \
--log-level trace \
--verbose \
--warnings all \
$2
10 changes: 7 additions & 3 deletions test/run_all_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ DEFAULT='\x1B[0;0m'

all_tests_result=0

# This fixes a problem when running valgrind in a Docker container when the
# host machine is running Fedora. See https://stackoverflow.com/a/75293014.
ulimit -n 1024

if [ 0 -eq $all_tests_result ]; then
echo && echo -e "${YELLOW}Compiling and running Notecard Test Suite...${DEFAULT}"
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \
Expand Down Expand Up @@ -164,8 +168,8 @@ if [ 0 -eq ${all_tests_result} ]; then

# Run coverage if available
if [ $(which lcov) ]; then
rm mock-*.gc?? *_Mock.gc?? *test.gc?? \
&& gcov --version \
rm mock-*.gc?? *_Mock.gc?? *test.gc??
gcov --version \
&& lcov --version \
&& mkdir -p ./coverage \
&& lcov --capture \
Expand All @@ -177,7 +181,7 @@ if [ 0 -eq ${all_tests_result} ]; then
echo -e "${YELLOW}COVERAGE REPORT NOT PRODUCED!!!${DEFAULT}";
all_tests_result=998
else
lcov --summary ./coverage/lcov.info
lcov --summary --rc lcov_branch_coverage=1 ./coverage/lcov.info
fi
fi
rm -f failed_test_run
Expand Down