Commit 0d51659b authored by Marek Vavruša's avatar Marek Vavruša Committed by Petr Špaček

CI: Add coverage CI target to parse code coverage and display it in MRs

parent 6c0b9868
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -8,6 +8,7 @@ CGO := go tool cgo
GO := go
CAT := cat
SED := sed
LCOV := lcov
LIBEXT := .so
AREXT := .a
LIBTYPE := shared
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment