Skip to content

Commit

Permalink
ci: add steps to report valgrind memory results (#269)
Browse files Browse the repository at this point in the history
Signed-off-by: msclock <msclock@qq.com>
  • Loading branch information
msclock authored May 29, 2024
1 parent 674b9fa commit 822b394
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,23 @@ jobs:
run: cmake --build --preset=default --target all

- name: Valgrind
run: cmake --build --preset=default --target ExperimentalMemCheck
run: cmake --build --preset=default --target ExperimentalMemCheck | tee out/valgrind.log

- name: Check if valgrind found some errors
run: |
if grep -q "Memory Leak" out/valgrind.log; then
echo "# :error: Memory Leak found! Please fix it." >> $GITHUB_STEP_SUMMARY
echo -e "References: \n - <https://valgrind.org/docs/manual/manual.html>\n - <https://stackoverflow.com/a/44989219/23467261>" >> $GITHUB_STEP_SUMMARY
tar -czf out/valgrind-results.tar.gz out/build/default/Testing
exit 1
fi
- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: valgrind-results
path: out/valgrind-results.tar.gz

clang-tidy:
runs-on: ubuntu-22.04
Expand Down
10 changes: 10 additions & 0 deletions cmake/ConfigureWarningsAndHardening.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ include(cmake-modules/build/Sanitizer)
set(USE_VALGRIND
OFF
CACHE BOOL "Enable Valgrind")
set(USE_VALGRIND_OPTIONS
--leak-check=full # Each individual leak will be shown in detail.
--show-leak-kinds=all # Show all of "definite, indirect, possible,
# reachable" leak kinds in the "full" report.
--gen-suppressions=all # gen suppress info automatically.
--track-origins=yes # Favor useful output over speed. This tracks the
# origins of uninitialized values, which could be very
# useful for memory errors. Consider turning off if
# Valgrind is unacceptably slow.
CACHE STRING "valgrind options.")

include(cmake-modules/test/Valgrind)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,23 @@ jobs:
run: cmake --build --preset=default --target all

- name: Valgrind
run: cmake --build --preset=default --target ExperimentalMemCheck
run: cmake --build --preset=default --target ExperimentalMemCheck | tee out/valgrind.log

- name: Check if valgrind found some errors
run: |
if grep -q "Memory Leak" out/valgrind.log; then
echo "# :error: Memory Leak found! Please fix it." >> $GITHUB_STEP_SUMMARY
echo -e "References: \n - <https://valgrind.org/docs/manual/manual.html>\n - <https://stackoverflow.com/a/44989219/23467261>" >> $GITHUB_STEP_SUMMARY
tar -czf out/valgrind-results.tar.gz out/build/default/Testing
exit 1
fi

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: valgrind-results
path: out/valgrind-results.tar.gz

clang-tidy:
runs-on: ubuntu-22.04
Expand Down
10 changes: 10 additions & 0 deletions template/cmake/ConfigureWarningsAndHardening.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ include(cmake-modules/build/Sanitizer)
set(USE_VALGRIND
OFF
CACHE BOOL "Enable Valgrind")
set(USE_VALGRIND_OPTIONS
--leak-check=full # Each individual leak will be shown in detail.
--show-leak-kinds=all # Show all of "definite, indirect, possible,
# reachable" leak kinds in the "full" report.
--gen-suppressions=all # gen suppress info automatically.
--track-origins=yes # Favor useful output over speed. This tracks the
# origins of uninitialized values, which could be very
# useful for memory errors. Consider turning off if
# Valgrind is unacceptably slow.
CACHE STRING "valgrind options.")

include(cmake-modules/test/Valgrind)

Expand Down

0 comments on commit 822b394

Please sign in to comment.