@@ -20,41 +20,26 @@ jobs:
2020runs-on :ubuntu-latest
2121
2222env :
23- BUILD_PATH : ${{ github.workspace }}/test/build
23+ COVERAGE_DATA_PATH : extras/coverage-data/coverage.info
2424
2525steps :
2626 -name :Checkout repository
2727uses :actions/checkout@v2
2828
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
29+ # See: https://github.com/arduino/cpp-test-action/blob/main/README.md
30+ -uses :arduino/cpp-test-action@main
31+ with :
32+ source-path :test
33+ build-path :test/build
34+ runtime-path :test/build/bin/test-ArduinoCore-API
35+ coverage-exclude-paths :|
36+ - '*/test/*'
37+ - '/usr/*'
38+ coverage-data-path :${{ env.COVERAGE_DATA_PATH }}
5439
5540# See: https://github.com/codecov/codecov-action/blob/master/README.md
5641 -name :Upload coverage report to Codecov
5742uses :codecov/codecov-action@v1
5843with :
59- file :${{ env.BUILD_PATH }}/coverage.info
44+ file :${{ env.COVERAGE_DATA_PATH }}
6045fail_ci_if_error :true