From 74664a3e2c4ab56d8c8ab136177356be0b7e3de5 Mon Sep 17 00:00:00 2001 From: David Holdeman Date: Tue, 16 Jun 2020 14:39:50 -0700 Subject: [PATCH] Move gcov to Github Actions (#1500) * Add gcov generation * Install missing software * Change working directory * typo * Added echo statements * Enquote args * add test for args * add error message * replace return with exit * added extra line returns --- .github/workflows/build-unit-tests.yaml | 7 +++++ unit_tests/ci_gcov.sh | 35 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 unit_tests/ci_gcov.sh diff --git a/.github/workflows/build-unit-tests.yaml b/.github/workflows/build-unit-tests.yaml index 51ac3887eb..839a9e4b97 100644 --- a/.github/workflows/build-unit-tests.yaml +++ b/.github/workflows/build-unit-tests.yaml @@ -18,3 +18,10 @@ jobs: - name: Run Tests run: ./unit_tests/build/rusefi_test + + - name: Install Coverage Tools + run: sudo apt-get install ncftp lcov + + - name: Generate Code Coverage + working-directory: ./unit_tests/ + run: ./ci_gcov.sh ${{ secrets.RUSEFI_DOXYGEN_FTP_USER }} ${{ secrets.RUSEFI_DOXYGEN_FTP_PASS }} ${{ secrets.RUSEFI_FTP_SERVER }} diff --git a/unit_tests/ci_gcov.sh b/unit_tests/ci_gcov.sh new file mode 100755 index 0000000000..d36e1b5c82 --- /dev/null +++ b/unit_tests/ci_gcov.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +rm -rf gcov_working_area + +mkdir gcov_working_area +cd gcov_working_area + +echo "Looking for source code" +find .. -name *.c* > source_files.txt +find ../../firmware/console/ -name *.c* >> source_files.txt +find ../../firmware/controllers/ -name *.c* >> source_files.txt + +wc -l source_files.txt + +xargs -L 1 -I {} cp {} . < source_files.txt + +cp ../build/obj/* . + +echo -e "\nGenerating coverage" +gcov *.c* > gcov.log 2>gcov.err + +echo -e "\nCollecting coverage" +lcov --capture --directory . --output-file coverage.info + +echo -e "\nGenerating HTML" +genhtml coverage.info --output-directory gcov + +echo -e "\nUploading HTML" +if [ $1 ] && [ $2 ] && [ $3 ]; then + ncftpput -m -R -v -u "$1" -p "$2" "$3" /unit_tests_coverage gcov/* +else + echo "Error: FTP server details seem to be missing" + exit 1 +fi +