Verified Commit 57c3f8db authored by Karel Koci's avatar Karel Koci 🤘 Committed by Karel Koci

Add Gitlab CI

This includes test to compile project, to run tests in various
environments and code coverage.
parent 07638e0a
Pipeline #69005 passed with stages
in 1 minute and 37 seconds
......@@ -7,6 +7,8 @@
*.pc
.libs
*.gperf.c
logc-*.tar.gz
logc-*.zip
# Test outputs
tests/unittests
......@@ -14,6 +16,11 @@ test-suite*.log
tests/*.log
tests/*.trs
# Coverage output
*.gcno
*-coverage
*-coverage.info
## Autotools
/m4
/aux
......
image: registry.labs.nic.cz/turris/logc
stages:
- build
- test
- coverage
- release
## Build stage ###################################################################
build:
stage: build
script:
- ./bootstrap
- ./configure --disable-tests --disable-valgrind --disable-linters
- make
artifacts:
when: on_failure
expire_in: 1 week
paths:
- config.log
dist:
stage: build
script:
- ./bootstrap
- ./configure
- make dist
artifacts:
expire_in: 1 month
paths:
- logc-*.tar.gz
- logc-*.zip
## Test stage ####################################################################
.test:
stage: test
needs: [build]
before_script:
- ./bootstrap
- ./configure
.test-check:
extends: .test
artifacts:
when: on_failure
expire_in: 1 week
paths:
- 'test-suite*.log'
- 'tests/*/*.log'
- 'tests/*/*.trs'
check:
extends: .test-check
script:
- make check
valgrind:
extends: .test-check
script:
- make check-valgrind
lint:
allow_failure: true
extends: .test
script:
- make lint
## Code Coverage stage ###########################################################
coverage:
stage: coverage
needs: [check]
script:
- ./bootstrap
- ./configure --enable-code-coverage
- make check-code-coverage V=1
coverage: '/lines\.\.\.\.\.\.: (\d+.\d+%)/'
artifacts:
expire_in: 1 month
expose_as: 'Code Coverage'
paths:
- 'logc-0.1.0-coverage/'
## Release creation ##############################################################
# TODO
# Wee need unstable for now because of check version
FROM debian:unstable
ENV HOME /root
RUN \
apt-get update && \
apt-get -y upgrade && \
apt-get -y install --no-install-recommends \
autoconf autoconf-archive automake libtool \
make pkg-config gcc gperf \
check cppcheck valgrind lcov \
zip \
&& \
apt-get clean
CMD [ "bash" ]
# vim: ft=dockerfile
......@@ -3,10 +3,16 @@ ACLOCAL_AMFLAGS = -I m4
lib_LTLIBRARIES = liblogc.la liblogc_argp.la
liblogc_la_SOURCES = logc.c
liblogc_la_CFLAGS = -isystem %reldir%
liblogc_la_CFLAGS = \
-isystem %reldir% \
$(CODE_COVERAGE_CFLAGS)
liblogc_la_LIBS = $(CODE_COVERAGE_LIBS)
liblogc_argp_la_SOURCES = logc_argp.c
liblogc_argp_la_CFLAGS = -isystem %reldir%
liblogc_argp_la_CFLAGS = \
-isystem %reldir% \
$(CODE_COVERAGE_CFLAGS)
liblogc_argp_la_LIBS = $(CODE_COVERAGE_LIBS)
include_HEADERS = logc.h logc_util.h logc_assert.h logc_argp.h
pkgconfig_DATA = logc.pc logc_argp.pc
......@@ -17,6 +23,9 @@ $(liblogc_la_OBJECTS): $(gperf_files)
include $(srcdir)/gperf.am
DIST_TARGETS := dist-gzip dist-zip
linted_files = $(liblogc_la_SOURCES) $(include_HEADERS)
include $(srcdir)/lint.am
......
......@@ -16,7 +16,7 @@ check_PROGRAMS = %reldir%/unittests
LOG_DRIVER = \
env AM_TAP_AWK='$(AWK)' TEST_OUTPUT_TAP=y \
env AM_TAP_AWK='$(AWK)' TEST_OUTPUT_TAP="/dev/stdout" \
'$(SHELL)' '$(srcdir)/aux/tap-driver.sh'
## Valgrind
......@@ -37,6 +37,9 @@ endef
$(foreach tool,$(valgrind_tools),$(eval $(call check_valgrind_rule,$(tool))))
## Coverage
CODE_COVERAGE_LCOV_OPTIONS := --no-external
CODE_COVERAGE_GENHTML_OPTIONS := --prefix $(dir $(abs_top_builddir))
include $(srcdir)/aminclude_static.am
clean-local: code-coverage-clean
......
......@@ -36,8 +36,11 @@ int main(void) {
SRunner *runner = srunner_create(suite);
char *test_output_tap = getenv("TEST_OUTPUT_TAP");
if (test_output_tap && !strcmp(test_output_tap, "y"))
srunner_set_tap(runner, "/dev/stdout");
if (test_output_tap && *test_output_tap != '\0')
srunner_set_tap(runner, test_output_tap);
char *test_output_xml = getenv("TEST_OUTPUT_XML");
if (test_output_xml && *test_output_xml != '\0')
srunner_set_xml(runner, test_output_xml);
srunner_set_fork_status(runner, CK_FORK); // We have to fork to catch signals
srunner_run_all(runner, CK_NORMAL);
......
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