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

Fix Travis CI sonar-scanner timeout issue #2287

Merged
merged 2 commits into from
Oct 12, 2020
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
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ jobs:
script: ./programs/build_helpers/scan_with_sonar_step_2
- stage: scan with sonar, step 3
script: ./programs/build_helpers/scan_with_sonar_step_3
- stage: scan with sonar, step 4
script: ./programs/build_helpers/scan_with_sonar_step_4
2 changes: 1 addition & 1 deletion programs/build_helpers/scan_with_sonar_step_2
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ du -hs sonar_cache
# The first pass, skip some files. This will remove the skipped files from the cache, but is an acceptable trade-off
programs/build_helpers/buildstep prepare.sonar.part1 1 "cp sonar-project.properties sonar-project.properties.bak; sed -i '/sonar\.exclusions=/d;s/#sonar\.exclusions.part1/sonar.exclusions/' sonar-project.properties"
programs/build_helpers/buildstep run.sonar.part1 1500 "which sonar-scanner && sonar-scanner"
programs/build_helpers/buildstep prepare.sonar.full 1 "cp sonar-project.properties.bak sonar-project.properties"
programs/build_helpers/buildstep prepare.sonar.full1 1 "cp sonar-project.properties.bak sonar-project.properties"
du -hs sonar_cache
# The second pass, skip fewer files
programs/build_helpers/buildstep prepare.sonar.part2 1 "cp sonar-project.properties sonar-project.properties.bak; sed -i '/sonar\.exclusions=/d;s/#sonar\.exclusions.part2/sonar.exclusions/' sonar-project.properties"
Expand Down
11 changes: 5 additions & 6 deletions programs/build_helpers/scan_with_sonar_step_3
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ programs/build_helpers/buildstep Prepare 1 "sed -i '/tests/d' libraries/fc/CMake
programs/build_helpers/buildstep cmake 5 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON ."
programs/build_helpers/buildstep make.programs 1800 "programs/build_helpers/make_with_sonar bw-output -j 2 witness_node cli_wallet js_operation_serializer get_dev_key network_mapper app_test chain_test cli_test"
set -o pipefail
programs/build_helpers/buildstep run.chain_test 600 "libraries/fc/tests/run-parallel-tests.sh tests/chain_test"
programs/build_helpers/buildstep run.cli_test 180 "libraries/fc/tests/run-parallel-tests.sh tests/cli_test"
programs/build_helpers/buildstep run.app_test 180 "tests/app_test"
programs/build_helpers/buildstep prepare.sonar 20 "find libraries/[acdenptuw]*/CMakeFiles/*.dir programs/[cdgjsw]*/CMakeFiles/*.dir -type d -print | while read d; do gcov -o \"\$d\" \"\${d/CMakeFiles*.dir//}\"/*.cpp; done >/dev/null; programs/build_helpers/set_sonar_branch sonar-project.properties"
du -hs sonar_cache
# The first pass is skipped here
# The second pass, skip fewer files than the first pass. This will remove the skipped files from the cache, but is an acceptable trade-off
programs/build_helpers/buildstep prepare.sonar.part2 1 "cp sonar-project.properties sonar-project.properties.bak; sed -i '/sonar\.exclusions=/d;s/#sonar\.exclusions.part2/sonar.exclusions/' sonar-project.properties"
programs/build_helpers/buildstep run.sonar.part2 1500 "which sonar-scanner && sonar-scanner"
programs/build_helpers/buildstep prepare.sonar.full 1 "cp sonar-project.properties.bak sonar-project.properties"
programs/build_helpers/buildstep prepare.sonar.full2 1 "cp sonar-project.properties.bak sonar-project.properties"
du -hs sonar_cache
# The third pass, scan all files
programs/build_helpers/buildstep run.sonar.full 1500 "which sonar-scanner && sonar-scanner"
# The third pass, skip fewer files
programs/build_helpers/buildstep prepare.sonar.part3 1 "cp sonar-project.properties sonar-project.properties.bak; sed -i '/sonar\.exclusions=/d;s/#sonar\.exclusions.part3/sonar.exclusions/' sonar-project.properties"
programs/build_helpers/buildstep run.sonar.part3 1500 "which sonar-scanner && sonar-scanner"
programs/build_helpers/buildstep prepare.sonar.full3 1 "cp sonar-project.properties.bak sonar-project.properties"
du -hs sonar_cache
programs/build_helpers/buildstep end 0
ccache -s
Expand Down
26 changes: 26 additions & 0 deletions programs/build_helpers/scan_with_sonar_step_4
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -e

programs/build_helpers/buildstep -s 3500
ccache -s
programs/build_helpers/buildstep Prepare 1 "sed -i '/tests/d' libraries/fc/CMakeLists.txt"
programs/build_helpers/buildstep cmake 5 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON ."
programs/build_helpers/buildstep make.programs 1800 "programs/build_helpers/make_with_sonar bw-output -j 2 witness_node cli_wallet js_operation_serializer get_dev_key network_mapper app_test chain_test cli_test"
set -o pipefail
programs/build_helpers/buildstep run.chain_test 600 "libraries/fc/tests/run-parallel-tests.sh tests/chain_test"
programs/build_helpers/buildstep run.cli_test 180 "libraries/fc/tests/run-parallel-tests.sh tests/cli_test"
programs/build_helpers/buildstep run.app_test 180 "tests/app_test"
programs/build_helpers/buildstep prepare.sonar 20 "find libraries/[acdenptuw]*/CMakeFiles/*.dir programs/[cdgjsw]*/CMakeFiles/*.dir -type d -print | while read d; do gcov -o \"\$d\" \"\${d/CMakeFiles*.dir//}\"/*.cpp; done >/dev/null; programs/build_helpers/set_sonar_branch sonar-project.properties"
du -hs sonar_cache
# The first pass and the second pass are skipped here
# The third pass, skip fewer files than the previous passes. This will remove the skipped files from the cache, but is an acceptable trade-off
programs/build_helpers/buildstep prepare.sonar.part3 1 "cp sonar-project.properties sonar-project.properties.bak; sed -i '/sonar\.exclusions=/d;s/#sonar\.exclusions.part3/sonar.exclusions/' sonar-project.properties"
programs/build_helpers/buildstep run.sonar.part3 1500 "which sonar-scanner && sonar-scanner"
programs/build_helpers/buildstep prepare.sonar.full3 1 "cp sonar-project.properties.bak sonar-project.properties"
du -hs sonar_cache
# The fourth pass, scan all files
programs/build_helpers/buildstep run.sonar.full 1500 "which sonar-scanner && sonar-scanner"
du -hs sonar_cache
programs/build_helpers/buildstep end 0
ccache -s

1 change: 1 addition & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sonar.tests=tests
# Used by the `build_and_test` script for the first pass when building with Travis CI, to skip some files
#sonar.exclusions.part1=programs/build_helper/**/*,libraries/fc/**/*,libraries/egenesis/egenesis_full.cpp,libraries/chain/**/*,libraries/protocol/**/*
#sonar.exclusions.part2=programs/build_helper/**/*,libraries/fc/**/*,libraries/egenesis/egenesis_full.cpp,libraries/chain/**/*
#sonar.exclusions.part3=programs/build_helper/**/*,libraries/fc/**/*,libraries/egenesis/egenesis_full.cpp,libraries/chain/**/d*
sonar.exclusions=programs/build_helper/**/*,libraries/fc/**/*,libraries/egenesis/egenesis_full.cpp
sonar.sources=libraries,programs
sonar.cfamily.build-wrapper-output=bw-output
Expand Down