From d5823472e36d2013ebba72929a8073b1573d79c6 Mon Sep 17 00:00:00 2001 From: amai2012 Date: Fri, 13 Mar 2020 22:42:15 +0100 Subject: [PATCH] Add code coverage to Github Actions (#2566) Create and store coverage data including upload to codecov.io --- .github/workflows/coverage.yml | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 000000000..4889ab134 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,48 @@ +# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions +# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners +name: Coverage + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Install missing software on ubuntu + run: | + sudo apt update + sudo apt-get install libxml2-utils + sudo apt-get install z3 libz3-dev + sudo apt-get install lcov + pip install lcov_cobertura + + - name: Compile instrumented + run: | + make test CXXFLAGS="-g -fprofile-arcs -ftest-coverage" USE_Z3=yes -j2 + + - name: Generate coverage report + run: | + rm -rf coverage_report + ./testrunner + test/cfg/runtests.sh + gcov lib/*.cpp -o lib/ + lcov --directory ./ --capture --output-file lcov_tmp.info -b ./ + lcov --extract lcov_tmp.info "$(pwd)/*" --output-file lcov.info + genhtml lcov.info -o coverage_report --frame --legend --demangle-cpp + + - uses: actions/upload-artifact@v1 + with: + name: Coverage results + path: coverage_report + + - uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos + # file: ./coverage.xml # optional + flags: unittests # optional + name: ${{ github.repository }} # optional + fail_ci_if_error: true # optional (default = false):