If the unit test is successful, valgrind memory check is executed based on the test.
If a leak occurs in the test result, the bot notifies the PR as a comment.
This notify may not be directly related to the created current PR.
(Asan is on hold because it is not well tested in the github action CI environment.)
- name: Install Packages
run: |
sudo apt-get update
- sudo apt-get install ninja-build gcc-multilib g++-multilib libgtest-dev meson cmake cmake-data
+ sudo apt-get install ninja-build gcc-multilib g++-multilib libgtest-dev meson cmake cmake-data libasan5 valgrind
+ sudo apt-get install curl jq
+ sudo apt-get install software-properties-common
- name: Install TurboJPEG library
run: sudo apt-get install libturbojpeg0-dev libjpeg8-dev
with:
name: UnitTestReport
path: build/meson-logs/testlog.txt
+
+ - name: Run memcheck Script(valgrind)
+ run: |
+ export PATH=$PATH:~/.local/bin/
+ chmod +x "${GITHUB_WORKSPACE}/.github/workflows/memcheck_valgrind.sh"
+ "${GITHUB_WORKSPACE}/.github/workflows/memcheck_valgrind.sh"
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
--- /dev/null
+#!/bin/bash
+
+echo "Run Valgrind"
+echo "valgrind --leak-check=yes ./tvgUnitTests"
+cd ./build/test
+
+valgrind --leak-check=yes ./tvgUnitTests > memcheck_valgrind.txt 2>&1
+
+
+PAYLOAD_MEMCHECK=`cat memcheck_valgrind.txt`
+COMMENTS_URL=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.comments_url)
+
+echo $COMMENTS_URL
+echo "MEMCHECK errors:"
+echo $PAYLOAD_MEMCHECK
+
+if [[ $PAYLOAD_MEMCHECK == *"definitely lost:"* || $PAYLOAD_MEMCHECK == *"Invalid read "* || $PAYLOAD_MEMCHECK == *"Invalid write "* ]]; then
+ OUTPUT+=$'\n**MEMCHECK(VALGRIND) RESULT**:\n'
+ OUTPUT+=$'\n`valgrind --leak-check=yes ./tvgUnitTests`\n'
+ OUTPUT+=$'\n```\n'
+ OUTPUT+="$PAYLOAD_MEMCHECK"
+ OUTPUT+=$'\n```\n'
+fi
+
+PAYLOAD=$(echo '{}' | jq --arg body "$OUTPUT" '.body = $body')
+
+curl -s -S -H "Authorization: token $GITHUB_TOKEN" --header "Content-Type: application/vnd.github.VERSION.text+json" --data "$PAYLOAD" "$COMMENTS_URL"