From 6754c28ca85e676c918251aff1687528b280b264 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sat, 25 Jan 2020 16:30:23 +0100 Subject: [PATCH] travis: Added coverage for plugins and coveralls integration --- .gitignore | 1 + .travis.yml | 2 ++ .travis/bin/python3 | 3 +++ .travis/build.sh | 14 +++++++++++++- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100755 .travis/bin/python3 diff --git a/.gitignore b/.gitignore index bee8a64..d8a1bb0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ __pycache__ +.coverage diff --git a/.travis.yml b/.travis.yml index ac45dec..e3faa43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,3 +24,5 @@ before_install: script: .travis/build.sh +after_success: + - coveralls diff --git a/.travis/bin/python3 b/.travis/bin/python3 new file mode 100755 index 0000000..3b3757c --- /dev/null +++ b/.travis/bin/python3 @@ -0,0 +1,3 @@ +#!/bin/bash +export COVERAGE_FILE=/tmp/.coverage +coverage run --omit='/home/travis/.local/,*/.direnv/*' --parallel-mode "$@" diff --git a/.travis/build.sh b/.travis/build.sh index 50a546b..4690720 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -26,7 +26,9 @@ pip3 install --user --quiet \ mako==1.0.14 \ psycopg2-binary==2.8.3 \ pytest-timeout==1.3.3 \ - pytest-xdist==1.30.0 + pytest-xdist==1.30.0 \ + coverage \ + coveralls # Install the pyln-client and testing library matching c-lightning `master` @@ -49,4 +51,14 @@ fi # Collect libraries that the plugins need and install them find . -name requirements.txt -exec pip3 install --user -r {} \; +# Enable coverage reporting from inside the plugin. This is done by adding a +# wrapper called python3 that internally just calls `coverage run` and stores +# the coverage output in `/tmp/.coverage.*` from where we can pick the details +# up again. +PATH="$(pwd)/.travis/bin:$PATH" +export PATH + pytest -vvv --timeout=550 --timeout_method=thread -p no:logging -n 10 + +# Now collect the results in a single file so coveralls finds them +coverage combine /tmp/.coverage.*