From: Marek VavruĊĦa Date: Sun, 26 Nov 2017 01:05:08 +0000 (-0800) Subject: CI: Add coverage CI target to parse code coverage and display it in MRs X-Git-Tag: v1.5.1~12^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d51659b7dc56a68e3b4a4bc629c7c4ebece08b6;p=thirdparty%2Fknot-resolver.git CI: Add coverage CI target to parse code coverage and display it in MRs --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0abd53ccb..c19cc3ed7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,7 @@ variables: DEBIAN_FRONTEND: noninteractive LC_ALL: C.UTF-8 GIT_SUBMODULE_STRATEGY: recursive + COVERAGE: '1' build:linux:amd64: stage: build @@ -29,8 +30,13 @@ test:linux:amd64: stage: test script: - PREFIX=$(pwd)/.local make -k check + - make coverage-c COVERAGE_STAGE=gcov-check dependencies: - build:linux:amd64 + artifacts: + expire_in: 1 hour + paths: + - ./*.info tags: - docker - linux @@ -40,8 +46,13 @@ installcheck:linux:amd64: stage: test script: - PREFIX=$(pwd)/.local make -k installcheck + - make coverage-c coverage-lua COVERAGE_STAGE=gcov-installcheck dependencies: - build:linux:amd64 + artifacts: + expire_in: 1 hour + paths: + - ./*.info tags: - docker - linux @@ -51,8 +62,13 @@ deckard:linux:amd64: stage: test script: - PREFIX=$(pwd)/.local MAKEFLAGS="--jobs $(nproc) --keep-going" make check-integration + - make coverage-c coverage-lua COVERAGE_STAGE=gcov-deckard dependencies: - build:linux:amd64 + artifacts: + expire_in: 1 hour + paths: + - ./*.info tags: - docker - linux @@ -128,6 +144,20 @@ respdiff:linux:amd64: - linux - amd64 +coverage:linux:amd64: + stage: deploy + script: + - make coverage + coverage: '/lines\.+:\s(\d+.\d+\%)/' + dependencies: + - test:linux:amd64 + - installcheck:linux:amd64 + - deckard:linux:amd64 + tags: + - docker + - linux + - amd64 + #arm_build: # image: cznic/armhf-ubuntu:16.04 # stage: build diff --git a/Makefile b/Makefile index d0381193a..40f47bbf4 100644 --- a/Makefile +++ b/Makefile @@ -10,17 +10,14 @@ clean: contrib-clean lib-clean daemon-clean client-clean modules-clean \ doc: doc-html lint: $(patsubst %.lua.in,%.lua,$(wildcard */*/*.lua.in)) luacheck --codes --formatter TAP . -coverage: $(wildcard */*/luacov.stats.out) - @echo "# C coverage in gcov.c.info" - @lcov --no-external --capture --directory . --output-file gcov.c.info > /dev/null - @if [ ! -z "$^" ]; then \ - echo "# Lua coverage in luacov.stats.out and gcov.lua.info"; \ - cat $^ > luacov.stats.out; \ - ./scripts/luacov_to_info.lua $^ > gcov.lua.info; \ - lcov --add-tracefile gcov.c.info --add-tracefile gcov.lua.info --output-file gcov.total.info; \ - else \ - lcov --add-tracefile gcov.c.info --output-file gcov.total.info; \ - fi +coverage-c: + @echo "# C coverage in $(COVERAGE_STAGE).c.info" + @$(LCOV) --no-external --capture --directory . --output-file $(COVERAGE_STAGE).c.info > /dev/null +coverage-lua: $(wildcard */*/luacov.stats.out) + @echo "# Lua coverage in $(COVERAGE_STAGE).lua.info" + @if [ ! -z "$^" ]; then ./scripts/luacov_to_info.lua $^ > $(COVERAGE_STAGE).lua.info; fi +coverage: + @$(LCOV) $(addprefix --add-tracefile ,$(wildcard $(COVERAGE_STAGE)*.info)) --output-file coverage.info .PHONY: all install check clean doc info diff --git a/config.mk b/config.mk index 040b09670..9b7930bcb 100644 --- a/config.mk +++ b/config.mk @@ -20,6 +20,7 @@ INCLUDEDIR ?= $(PREFIX)/include MODULEDIR ?= $(LIBDIR)/kdns_modules ETCDIR ?= $(PREFIX)/etc/kresd ROOTHINTS ?= $(ETCDIR)/root.hints +COVERAGE_STAGE ?= gcov # Tools CC ?= cc diff --git a/platform.mk b/platform.mk index 03669a131..6df6ee9ed 100644 --- a/platform.mk +++ b/platform.mk @@ -8,6 +8,7 @@ CGO := go tool cgo GO := go CAT := cat SED := sed +LCOV := lcov LIBEXT := .so AREXT := .a LIBTYPE := shared