Skip to content
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

Use gcovr to process code coverage data #2739

Merged
merged 3 commits into from
Mar 30, 2023
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
21 changes: 5 additions & 16 deletions .github/workflows/sonar-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
sudo apt-get install -y --allow-downgrades openssl=${openssl_ver} libssl-dev=${libssl_ver}
sudo apt-get install -y \
ccache \
gcovr \
parallel \
libboost-thread-dev \
libboost-iostreams-dev \
Expand Down Expand Up @@ -184,23 +185,11 @@ jobs:
df -h
- name: Prepare for scanning with SonarScanner
run: |
find _build/libraries/[acdenptuw]*/CMakeFiles/*.dir \
_build/libraries/plugins/*/CMakeFiles/*.dir \
-type d -print \
| while read d; do \
tmpd="${d:7}"; \
srcd="${tmpd/CMakeFiles*.dir/.}"; \
gcov -o "$d" "${srcd}"/*.[ch][px][px] \
"${srcd}"/include/graphene/*/*.[ch][px][px] ; \
done >/dev/null
find _build/programs/[cdgjsw]*/CMakeFiles/*.dir \
-type d -print \
| while read d; do \
tmpd="${d:7}"; \
srcd="${tmpd/CMakeFiles*.dir/.}"; \
gcov -o "$d" "${srcd}"/*.[ch][px][px] ; \
done >/dev/null
programs/build_helpers/set_sonar_branch_for_github_actions sonar-project.properties
pushd _build
gcovr --version
gcovr --exclude-unreachable-branches --sonarqube ../coverage.xml -r ..
popd
- name: Scan with SonarScanner
env:
# to get access to secrets.SONAR_TOKEN, provide GITHUB_TOKEN
Expand Down
7 changes: 6 additions & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ sonar.tests=tests
sonar.exclusions=programs/build_helper/**/*,libraries/fc/**/*,libraries/egenesis/egenesis_full.cpp
sonar.sources=libraries,programs
sonar.cfamily.build-wrapper-output=bw-output
sonar.cfamily.gcov.reportsPath=.

# Note:
# It is hard to get the gcov sensor working, but gcovr works.
# See https://community.sonarsource.com/t/code-coverage-incorrect-for-c-gcov-project/41837/5
#sonar.cfamily.gcov.reportsPath=.
sonar.coverageReportPaths=coverage.xml

# Decide which tree the current build belongs to in SonarCloud.
# Managed by the `set_sonar_branch*` script(s) when building with CI.
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1246,8 +1246,8 @@ BOOST_FIXTURE_TEST_CASE( cli_confidential_tx_test, cli_fixture )
// then confirm that balances are received, and then analyze the range
// prooofs to make sure the mantissa length does not reveal approximate
// balance (issue #480).
std::map<std::string, share_type> to_list = {{"alice",100000000000},
{"bob", 1000000000}};
std::map<std::string, share_type> to_list = {{"alice",100000000000LL},
{"bob", 1000000000LL}};
vector<blind_confirmation> bconfs;
auto core_asset = W.get_asset("1.3.0");
BOOST_TEST_MESSAGE("Sending blind transactions to alice and bob");
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/settle_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,7 @@ BOOST_AUTO_TEST_CASE( create_bitassets )
transfer( committee_account, rachelregistrar_id, asset( 10000000 ) );
transfer( committee_account, rachelreferrer_id, asset( 10000000 ) );
transfer( committee_account, rachel.get_id(), asset( 10000000) );
transfer( committee_account, paul_id, asset( 10000000000 ) );
transfer( committee_account, paul_id, asset( 10000000000LL ) );

asset_update_operation op;
op.issuer = biteur.issuer;
Expand Down