Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 05cac87

Browse files
Merge pull request #123 from per1234/ci-unit-test-workflow
Add workflow to run unit tests
2 parents 4ce098f + 9c538de commit 05cac87

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

‎.github/workflows/unit-tests.yml‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Unit Tests
2+
3+
on:
4+
pull_request:
5+
# Only run workflow if a file in these paths are modified
6+
paths:
7+
- ".github/workflows/unit-tests.yml"
8+
- "test/**"
9+
- "api/**"
10+
11+
push:
12+
paths:
13+
- ".github/workflows/unit-tests.yml"
14+
- "test/**"
15+
- "api/**"
16+
17+
jobs:
18+
test:
19+
name: Run unit tests
20+
runs-on: ubuntu-latest
21+
22+
env:
23+
BUILD_PATH: ${{ github.workspace }}/test/build
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v2
28+
29+
- name: Install valgrind
30+
run: sudo apt-get --assume-yes install valgrind
31+
32+
- name: Run unit tests
33+
run: |
34+
mkdir "$BUILD_PATH"
35+
cd "$BUILD_PATH"
36+
# Generate makefile
37+
cmake ..
38+
# Compile tests
39+
make
40+
# Run tests and check for memory leaks
41+
valgrind --leak-check=yes --error-exitcode=1 bin/test-ArduinoCore-API
42+
43+
- name: Install lcov
44+
run: sudo apt-get --assume-yes install lcov
45+
46+
- name: Report code coverage
47+
run: |
48+
cd "$BUILD_PATH"
49+
lcov --directory . --capture --output-file coverage.info
50+
# Remove external files from coverage data
51+
lcov --quiet --remove coverage.info '*/test/*' '/usr/*' --output-file coverage.info
52+
# Print coverage report in the workflow log
53+
lcov --list coverage.info
54+
55+
# See: https://github.com/codecov/codecov-action/blob/master/README.md
56+
- name: Upload coverage report to Codecov
57+
uses: codecov/codecov-action@v1
58+
with:
59+
file: ${{ env.BUILD_PATH }}/coverage.info
60+
fail_ci_if_error: true

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /