Skip to content

Add GitHub Actions workflow to run unit tests and check code coverage #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2020
Merged
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
48 changes: 48 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Unit Tests

on:
pull_request:
paths:
- ".github/workflows/unit-tests.yml"
- 'extras/test/**'
- 'src/**'

push:
paths:
- ".github/workflows/unit-tests.yml"
- 'extras/test/**'
- 'src/**'

jobs:
test:
name: Run unit tests
runs-on: ubuntu-latest

env:
BUILD_PATH: "${{ github.workspace }}/extras/test/build"

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Run unit tests
run: |
mkdir "$BUILD_PATH"
cd "$BUILD_PATH"
cmake ..
make
bin/testArduinoIoTCloud

- name: Check code coverage
run: |
cd "$BUILD_PATH"
sudo apt-get --assume-yes install lcov > /dev/null
lcov --directory . --capture --output-file coverage.info
lcov --quiet --remove coverage.info '*/extras/test/*' '/usr/*' --output-file coverage.info
lcov --list coverage.info

- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v1
with:
file: "${{ env.BUILD_PATH }}/coverage.info"
fail_ci_if_error: true
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
=================
[![Compile Examples](https://github.com/arduino-libraries/ArduinoIoTCloud/workflows/Compile%20Examples/badge.svg)](https://github.com/arduino-libraries/ArduinoIoTCloud/actions?workflow=Compile+Examples)
[![Spell Check](https://github.com/arduino-libraries/ArduinoIoTCloud/workflows/Spell%20Check/badge.svg)](https://github.com/arduino-libraries/ArduinoIoTCloud/actions?workflow=Spell+Check)
[![Unit Tests](https://github.com/arduino-libraries/ArduinoIoTCloud/workflows/Unit%20Tests/badge.svg)](https://github.com/arduino-libraries/ArduinoIoTCloud/actions?workflow=Unit+Tests)
[![codecov](https://codecov.io/gh/arduino-libraries/ArduinoIoTCloud/branch/master/graph/badge.svg)](https://codecov.io/gh/arduino-libraries/ArduinoIoTCloud)

### What?
The `ArduinoIoTCloud` library is the central element of the firmware enabling certain Arduino boards to connect to the [Arduino IoT Cloud](https://www.arduino.cc/en/IoT/HomePage). The following boards are supported:
Expand Down
3 changes: 3 additions & 0 deletions extras/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ set(TEST_SRCS
add_compile_definitions(HOST)
add_compile_options(-Wall -Wextra -Wpedantic -Werror)

set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "--coverage")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "--coverage")

##########################################################################

add_executable(
Expand Down