Skip to content

Commit dfab545

Browse files
authored
Add valgrind checks to all of the samples (#484)
* Add valgrind checks to all of the samples * Install valgrind * Adjust the log file name * Ignore possibly lost * Undo extra space
1 parent 375650e commit dfab545

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

.github/workflows/samples.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
if: runner.os == 'Linux'
6464
run: |
6565
apt-get update
66-
apt-get install -y git cmake build-essential pkg-config libssl-dev libcurl4-openssl-dev mkvtoolnix curl unzip
66+
apt-get install -y git cmake build-essential pkg-config libssl-dev libcurl4-openssl-dev mkvtoolnix curl unzip valgrind
6767
6868
- name: Build repository
6969
run: |
@@ -74,7 +74,7 @@ jobs:
7474
fi
7575
7676
mkdir build && cd build
77-
cmake .. -DBUILD_DEPENDENCIES=OFF
77+
cmake .. -DBUILD_DEPENDENCIES=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo
7878
make -j$num_procs
7979
8080
- name: Change token rotation to 30s
@@ -266,3 +266,34 @@ jobs:
266266
267267
exit $failed
268268
shell: bash
269+
- name: Run Valgrind on ${{ matrix.sample-executable.name }} (Linux)
270+
if: runner.os == 'Linux'
271+
working-directory: ./build
272+
run: |
273+
set -o pipefail
274+
set +e
275+
276+
mkdir -p valgrind_logs
277+
278+
LOG_FILE="valgrind_logs/${{ matrix.sample-executable.name }}.log"
279+
280+
echo "::group::Application logs for ${{ matrix.sample-executable.name }}"
281+
valgrind \
282+
--leak-check=full \
283+
--show-leak-kinds=all \
284+
--track-origins=yes \
285+
--error-exitcode=1 \
286+
--log-file="$LOG_FILE" \
287+
./${{ matrix.sample-executable.name }} "$KVS_STREAM_NAME" ${{ matrix.sample-executable.args }}
288+
echo "::endgroup::"
289+
290+
echo "========== Valgrind Output =========="
291+
cat "$LOG_FILE"
292+
echo "====================================="
293+
294+
if grep -qE "definitely lost: [^0]" "$LOG_FILE" || grep -qE "indirectly lost: [^0]" "$LOG_FILE"; then
295+
echo "❌ Valgrind found something definitely or indirectly lost"
296+
exit 1
297+
fi
298+
299+
shell: bash

0 commit comments

Comments
 (0)