Skip to content

Commit 1e8b8b9

Browse files
per1234aentinger
authored andcommitted
Add GitHub Actions workflow to run unit tests and check code coverage
On every pull request or push that changes relevant files: - Run unit tests - Print coverage report to the workflow log - Upload coverage report to Codecov
1 parent d2b4fd8 commit 1e8b8b9

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

.github/workflows/unit-tests.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Unit Tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- ".github/workflows/unit-tests.yml"
7+
- 'extras/test/**'
8+
- 'src/**'
9+
10+
push:
11+
paths:
12+
- ".github/workflows/unit-tests.yml"
13+
- 'extras/test/**'
14+
- 'src/**'
15+
16+
jobs:
17+
test:
18+
name: Run unit tests
19+
runs-on: ubuntu-latest
20+
21+
env:
22+
BUILD_PATH: "${{ github.workspace }}/extras/test/build"
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v2
27+
28+
- name: Run unit tests
29+
run: |
30+
mkdir "$BUILD_PATH"
31+
cd "$BUILD_PATH"
32+
cmake ..
33+
make
34+
bin/testArduinoIoTCloud
35+
36+
- name: Check code coverage
37+
run: |
38+
cd "$BUILD_PATH"
39+
sudo apt-get --assume-yes install lcov > /dev/null
40+
lcov --directory . --capture --output-file coverage.info
41+
lcov --quiet --remove coverage.info '*/extras/test/*' '/usr/*' --output-file coverage.info
42+
lcov --list coverage.info
43+
44+
- name: Upload coverage report to Codecov
45+
uses: codecov/codecov-action@v1
46+
with:
47+
file: "${{ env.BUILD_PATH }}/coverage.info"
48+
fail_ci_if_error: true

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
=================
33
[![Compile Examples](https://github.com/arduino-libraries/ArduinoIoTCloud/workflows/Compile%20Examples/badge.svg)](https://github.com/arduino-libraries/ArduinoIoTCloud/actions?workflow=Compile+Examples)
44
[![Spell Check](https://github.com/arduino-libraries/ArduinoIoTCloud/workflows/Spell%20Check/badge.svg)](https://github.com/arduino-libraries/ArduinoIoTCloud/actions?workflow=Spell+Check)
5+
[![Unit Tests](https://github.com/arduino-libraries/ArduinoIoTCloud/workflows/Unit%20Tests/badge.svg)](https://github.com/arduino-libraries/ArduinoIoTCloud/actions?workflow=Unit+Tests)
6+
[![codecov](https://codecov.io/gh/arduino-libraries/ArduinoIoTCloud/branch/master/graph/badge.svg)](https://codecov.io/gh/arduino-libraries/ArduinoIoTCloud)
57

68
### What?
79
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:

0 commit comments

Comments
 (0)