Skip to content

Commit d1a05ba

Browse files
Ngalstyan4cevian
authored andcommitted
integrate code coverage through codecov.io
1 parent cb9004c commit d1a05ba

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ before_install:
1414
- git clone --branch ${PG_GIT_TAG} --depth 1 https://github.com/postgres/postgres.git /tmp/postgres
1515
- docker run -d --name pgbuild -v ${TRAVIS_BUILD_DIR}:/build -v /tmp/postgres:/postgres postgres:${PG_VERSION}-alpine
1616
install:
17-
- docker exec -it pgbuild /bin/sh -c "apk add --no-cache --virtual .build-deps coreutils dpkg-dev gcc libc-dev make util-linux-dev diffutils cmake bison flex && mkdir -p /build/debug"
17+
- docker exec -it pgbuild /bin/sh -c "apk add --no-cache --virtual .build-deps coreutils dpkg-dev gcc libc-dev make util-linux-dev diffutils cmake bison flex curl git && mkdir -p /build/debug"
18+
- docker exec -it pgbuild /bin/sh -c "apk add --no-cache --virtual --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted lcov"
1819
# We only need to build the regress stuff
19-
- docker exec -it pgbuild /bin/sh -c "cd /postgres && ./configure --enable-debug --enable-cassert --without-readline --without-zlib && make -C /postgres/src/test/regress"
20-
- docker exec -it pgbuild /bin/sh -c "cd /build/debug && CFLAGS=-Werror cmake .. -DCMAKE_BUILD_TYPE=Debug -DPG_SOURCE_DIR=/postgres && make install && chown -R postgres:postgres /build/"
20+
- docker exec -it pgbuild /bin/sh -c "cd /postgres && ./configure --enable-coverage --enable-debug --enable-cassert --without-readline --without-zlib && make -C /postgres/src/test/regress"
21+
- docker exec -it pgbuild /bin/sh -c "cd /build/debug && CFLAGS=-Werror cmake .. -DCMAKE_BUILD_TYPE=Debug -DENABLE_CODECOVERAGE=TRUE -DPG_SOURCE_DIR=/postgres && make install && chown -R postgres:postgres /build/"
2122
script:
2223
- docker exec -u postgres -it pgbuild /bin/sh -c "make -C /build/debug installcheck pginstallcheck PG_REGRESS_OPTS='--temp-instance=/tmp/pgdata'"
24+
- ci_env=`bash <(curl -s https://codecov.io/env)`
25+
- docker exec -it $ci_env pgbuild /bin/bash -c "cd /build/debug && bash <(curl -s https://codecov.io/bash) || echo \"Codecov did not collect coverage reports\" "
2326
after_failure:
2427
- docker exec -it pgbuild cat /build/debug/test/regression.diffs /build/debug/test/pgtest/regressions.diffs
2528
after_script:

CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,29 @@ if (WIN32)
3030
set(CMAKE_CONFIGURATION_TYPES Release CACHE STRING "Semicolon separated list of supported configuration types, only supports Debug, Release, MinSizeRel, and RelWithDebInfo, anything else will be ignored." FORCE)
3131
endif ()
3232
endif (WIN32)
33+
if (ENABLE_CODECOVERAGE)
34+
message(STATUS "Running code coverage")
35+
36+
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
37+
message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading")
38+
endif (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
39+
40+
if (NOT DEFINED CODECOV_OUTPUTFILE)
41+
set(CODECOV_OUTPUTFILE cmake_coverage.output)
42+
endif (NOT DEFINED CODECOV_OUTPUTFILE)
43+
44+
if (NOT DEFINED CODECOV_HTMLOUTPUTDIR)
45+
set(CODECOV_HTMLOUTPUTDIR coverage_results)
46+
endif (NOT DEFINED CODECOV_HTMLOUTPUTDIR)
47+
48+
find_program(CODECOV_GCOV gcov)
49+
find_program(CODECOV_LCOV lcov)
50+
add_definitions(-fprofile-arcs -ftest-coverage)
51+
link_libraries(gcov)
52+
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} --coverage -fprofile-arcs)
53+
add_custom_target(coverage_init ALL ${CODECOV_LCOV} --base-directory . --directory ${CMAKE_BINARY_DIR} --output-file ${CODECOV_OUTPUTFILE} --capture --initial)
54+
55+
endif (ENABLE_CODECOVERAGE)
3356

3457
project(timescaledb VERSION ${VERSION} LANGUAGES C)
3558

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
|Linux/macOS|Windows|Coverity|
2-
|:---:|:---:|:---:|
3-
|[![Build Status](https://travis-ci.org/timescale/timescaledb.svg?branch=master)](https://travis-ci.org/timescale/timescaledb)|[![Windows build status](https://ci.appveyor.com/api/projects/status/15sqkl900t04hywu/branch/master?svg=true)](https://ci.appveyor.com/project/RobAtticus/timescaledb/branch/master)|[![Coverity Scan Build Status](https://scan.coverity.com/projects/timescale-timescaledb/badge.svg)](https://scan.coverity.com/projects/timescale-timescaledb)
1+
|Linux/macOS|Windows|Coverity|Code Coverage|
2+
|:---:|:---:|:---:|:---:|
3+
|[![Build Status](https://travis-ci.org/timescale/timescaledb.svg?branch=master)](https://travis-ci.org/timescale/timescaledb)|[![Windows build status](https://ci.appveyor.com/api/projects/status/15sqkl900t04hywu/branch/master?svg=true)](https://ci.appveyor.com/project/RobAtticus/timescaledb/branch/master)|[![Coverity Scan Build Status](https://scan.coverity.com/projects/timescale-timescaledb/badge.svg)](https://scan.coverity.com/projects/timescale-timescaledb)|[![Code Coverage](https://codecov.io/gh/timescale/timescaledb/branch/master/graphs/badge.svg?branch=master)](https://codecov.io/gh/timescale/timescaledb/branch/master/graphs/badge.svg?branch=master)
44

55

66
## TimescaleDB

0 commit comments

Comments
 (0)