From 7db446dd8db54af879f426b9b7ded03dd4e4b422 Mon Sep 17 00:00:00 2001 From: zvon Date: Thu, 16 Apr 2020 15:06:15 +0200 Subject: [PATCH] Add badges to README, add code coverage to pipeline --- .gitlab-ci.yml | 19 ++++++++++++++++++- Makefile | 27 ++++++++++++++++++--------- README.md | 3 +++ 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 93b5bb0..d301f90 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,6 +31,23 @@ linux:test: script: - ./tv_rename --help +linux:codacy: + image: debian + stage: test + needs: [] + before_script: + - apt update + - apt install -y libsqlite3-dev libcurl4-openssl-dev g++ make build-essential gettext git gcovr + - export CXX=g++ + - git submodule update --init rapidjson + script: + - make test.out + - make check + after_script: + - find . -type f -name "*.gcno" -execdir gcov -pb -r {} + + - gcovr --root . -k -j 2 --xml -o gcovr_report.xml --exclude-directories "tests" --exclude-directories "gtk" --exclude-directories "win*" --exclude-directories "sqlite-am*" --exclude-directories "rapidjson" + - bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r "gcovr_report.xml" --language CPP --force-language + formatting:test: image: debian stage: test @@ -41,7 +58,7 @@ formatting:test: - apt install -y clang-format script: - FORMAT="ok" - - while read f ; do clang-format -style=file "$f" > temp.pp ; if [ $(diff temp.pp "$f" | wc -l) -gt 0 ] ; then echo "$f needs reformatting" ; FORMAT="nok" ; fi ; done <<< $(find . -iname "*pp") + - while read f ; do clang-format -style=file "$f" > temp.pp ; if [ "$f" == "./tests/catch.hpp" ] ; then continue ; fi ; if [ $(diff temp.pp "$f" | wc -l) -gt 0 ] ; then echo "$f needs reformatting" ; FORMAT="nok" ; fi ; done <<< $(find . -iname "*pp") - rm temp.pp - 'if [ "$FORMAT" = "nok" ] ; then exit 1 ; fi' diff --git a/Makefile b/Makefile index e62b832..747a552 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,8 @@ default: tv_rename .PHONY: clean clean: - rm -Rf *.o tv_rename tv_rename_gui locale + rm -Rf *.o tv_rename tv_rename_gui locale *.gcda *.gcno *.gcov\ + gcovr_report.xml .PHONY: install install: tv_rename @@ -139,25 +140,25 @@ WINDOWS_GUI_OBJECTS = gui.obj mainwindow.obj\ progresswindow.obj seasonwindow.obj\ databasewindow.obj searchwindow.obj -gui.obj: windows/gui.cpp +gui.obj: win32/gui.cpp $(CXX) -MD -EHsc -Fo"$@" $^ -DGUI -D_WIN32 -DUNICODE -c -mainwindow.obj: windows/mainwindow.cpp +mainwindow.obj: win32/mainwindow.cpp $(CXX) -MD -EHsc -Fo"$@" $^ -DGUI -D_WIN32 -DUNICODE -c -gui_functions.obj: windows/gui_functions.cpp +gui_functions.obj: win32/gui_functions.cpp $(CXX) -MD -EHsc -Fo"$@" $^ -DGUI -D_WIN32 -DUNICODE -c filesystem.obj: windows/filesystem.cpp $(CXX) -MD -EHsc -Fo"$@" $^ -DGUI -D_WIN32 -DUNICODE -c network.obj: windows/network.cpp $(CXX) -MD -EHsc -Fo"$@" $^ -DGUI -D_WIN32 -DUNICODE -c -patternwindow.obj: windows/patternwindow.cpp +patternwindow.obj: win32/patternwindow.cpp $(CXX) -MD -EHsc -Fo"$@" $^ -DGUI -D_WIN32 -DUNICODE -c -progresswindow.obj: windows/progresswindow.cpp +progresswindow.obj: win32/progresswindow.cpp $(CXX) -MD -EHsc -Fo"$@" $^ -DGUI -D_WIN32 -DUNICODE -c -seasonwindow.obj: windows/seasonwindow.cpp +seasonwindow.obj: win32/seasonwindow.cpp $(CXX) -MD -EHsc -Fo"$@" $^ -DGUI -D_WIN32 -DUNICODE -c -databasewindow.obj: windows/databasewindow.cpp +databasewindow.obj: win32/databasewindow.cpp $(CXX) -MD -EHsc -Fo"$@" $^ -DGUI -D_WIN32 -DUNICODE -c -searchwindow.obj: windows/searchwindow.cpp +searchwindow.obj: win32/searchwindow.cpp $(CXX) -MD -EHsc -Fo"$@" $^ -DGUI -D_WIN32 -DUNICODE -c tv_rename.obj: tv_rename.cpp $(CXX) -MD -EHsc -Fo"$@" $^ -DGUI -D_WIN32 -DUNICODE -c @@ -184,3 +185,11 @@ locale/%/LC_MESSAGES: locale/%/LC_MESSAGES/tv_rename.mo: translations/%.po locale/%/LC_MESSAGES msgfmt -c $< -o $<.mo mv $<.mo $@ + +test.out: tests/test.cpp functions.cpp unix/network.cpp progress.cpp\ + unix/filesystem.cpp tv_rename.cpp + $(CXX) $^ -lcurl -lsqlite3 --coverage -o test.out + +.PHONY: check +check: test.out + ./test.out diff --git a/README.md b/README.md index e57681d..9eb8ef9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![pipeline status](https://gitlab.com/zvon/tv_rename_cpp/badges/tests/pipeline.svg)](https://gitlab.com/zvon/tv_rename_cpp/-/commits/tests) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/9aace967ca614da4bdb7a500f63858dd)](https://www.codacy.com/manual/tom.zvon/tv_rename_cpp?utm_source=gitlab.com&utm_medium=referral&utm_content=zvon/tv_rename_cpp&utm_campaign=Badge_Grade) +[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/9aace967ca614da4bdb7a500f63858dd)](https://www.codacy.com/manual/tom.zvon/tv_rename_cpp?utm_source=gitlab.com&utm_medium=referral&utm_content=zvon/tv_rename_cpp&utm_campaign=Badge_Coverage) # Rename TV Show files This program downloads episode names from and adds them as a suffix to the appropriate files