Skip to content

Commit

Permalink
Merge pull request #22 from dwd/sonar-fixes
Browse files Browse the repository at this point in the history
Sonar fixes
  • Loading branch information
dwd authored Sep 6, 2024
2 parents fc54834 + b3c1787 commit 6008cf6
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 104 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/gtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,29 @@ jobs:
run: sudo apt-get update
- name: Install libcurl
run: sudo apt-get install libcurl4-openssl-dev
- name: Set up Python 3.8 for gcovr
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: install gcovr 5.0
run: |
pip install gcovr==5.0 # 5.1 is not supported
- name: SonarQube install
uses: SonarSource/sonarcloud-github-c-cpp@v3
- name: Make build directory
run: mkdir gtest-build
- name: CMake
run: cmake -S . -B gtest-build -DCMAKE_BUILD_TYPE=Debug -DCMAKE-CXX_FLAGS=-Werror
run: cmake -S . -B gtest-build -DCMAKE_BUILD_TYPE=Debug
- name: Build Wrapper
run: build-wrapper-linux-x86-64 --out-dir sonar-out cmake --build gtest-build
- name: Run Tests
run: cd ./gtest-build && ./rapidxml-test
- name: Show coverage
run: cd ./gtest-build && gcovr -r ..
- name: Collate coverage
run: cd ./gtest-build && gcovr -r .. --sonarqube >../coverage.xml
- name: Sonar Scanner
run: sonar-scanner --define sonar.cfamily.compile-commands=sonar-out/compile_commands.json
run: sonar-scanner --define sonar.cfamily.compile-commands=sonar-out/compile_commands.json --define sonar.coverageReportPaths=coverage.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Run Tests
run: cd gtest-build && ./rapidxml-test
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ add_executable(rapidxml-test
test/xpath.cpp
rapidxml_generator.hpp
test/main.cc
rapidxml_predicates.hpp
)
target_link_libraries(rapidxml-test PRIVATE
GTest::gtest
Expand All @@ -51,6 +52,8 @@ target_include_directories(rapidxml-test
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)
target_compile_options(rapidxml-test PRIVATE -Werror -Wall --coverage -g -O0)
target_link_options(rapidxml-test PRIVATE --coverage -g)
if (RAPIDXML_PERF_TESTS)
message("Running performance tests")
file(DOWNLOAD https://www.w3.org/TR/xml/REC-xml-20081126.xml ${CMAKE_CURRENT_BINARY_DIR}/REC-xml-20081126.xml)
Expand Down
Loading

0 comments on commit 6008cf6

Please sign in to comment.