From e7da07ab0cacb0a5e89235a9c3d4ab807116b847 Mon Sep 17 00:00:00 2001 From: sgiehl Date: Sun, 17 Aug 2014 21:41:24 +0200 Subject: [PATCH 1/3] refs #4224, #4302 - added code coverage report using coveralls.io --- .coveralls.yml | 3 +++ .travis.yml | 22 +++++++++++++++++++ README.md | 2 ++ plugins/CoreConsole/templates/travis.yml.twig | 8 +++++++ tests/PHPUnit/phpunit.xml.dist | 13 +++++++++++ tests/travis/travis.sh | 14 +++++++++++- 6 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 00000000000..f289677959b --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1,3 @@ +service_name: travis-ci +src_dir: . +coverage_clover: build/logs/clover-*.xml \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 95003d4a409..5029c10ccaf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,20 @@ matrix: allow_failures: - php: hhvm - php: 5.6 + - php: 5.4 + env: MYSQL_ADAPTER=PDO_MYSQL COVERAGE=Core + - php: 5.4 + env: MYSQL_ADAPTER=PDO_MYSQL COVERAGE=Plugins + - php: 5.4 + env: MYSQL_ADAPTER=PDO_MYSQL COVERAGE=Integration + include: + # Code Coverage + - php: 5.4 + env: MYSQL_ADAPTER=PDO_MYSQL COVERAGE=Core + - php: 5.4 + env: MYSQL_ADAPTER=PDO_MYSQL COVERAGE=Plugins + - php: 5.4 + env: MYSQL_ADAPTER=PDO_MYSQL COVERAGE=Integration exclude: # Javascript tests need to run only on one PHP version - php: 5.4 @@ -91,6 +105,10 @@ install: - git checkout master -- ./tests/travis ./plugins/CoreConsole || true before_script: + - if [ -z "$TEST_SUITE" ]; + then composer require satooshi/php-coveralls dev-master; + fi + - ./tests/travis/configure_git.sh # print out mysql information @@ -139,6 +157,10 @@ after_script: # change directory back to root travis dir - cd $PIWIK_ROOT_DIR + - if [ -z "$TEST_SUITE" ]; + then php vendor/bin/coveralls -v; + fi + # output contents of files w/ debugging info to screen - cat /var/log/nginx/error.log - cat $PIWIK_ROOT_DIR/tmp/php-fpm.log diff --git a/README.md b/README.md index 89735fdc94e..d5ed6456d32 100644 --- a/README.md +++ b/README.md @@ -101,3 +101,5 @@ The Piwik project uses an ever-expanding comprehensive set of thousands of unit Build status (master branch) [![Build Status](https://travis-ci.org/piwik/piwik.png?branch=master)](https://travis-ci.org/piwik/piwik) - Screenshot tests Build [![Build Status](https://travis-ci.org/piwik/piwik-ui-tests.png?branch=master)](https://travis-ci.org/piwik/piwik-ui-tests) +Code Coverage: [![Coverage Status](https://coveralls.io/repos/piwik/piwik/badge.png?branch=master)](https://coveralls.io/r/piwik/piwik?branch=master) + diff --git a/plugins/CoreConsole/templates/travis.yml.twig b/plugins/CoreConsole/templates/travis.yml.twig index 6b52f225587..553f5ae7b44 100644 --- a/plugins/CoreConsole/templates/travis.yml.twig +++ b/plugins/CoreConsole/templates/travis.yml.twig @@ -96,6 +96,10 @@ install: {% endif %} before_script: + - if [ -z "$TEST_SUITE" ]; + then composer require satooshi/php-coveralls dev-master; + fi + - ./tests/travis/configure_git.sh # print out mysql information @@ -147,6 +151,10 @@ after_script: # change directory back to root travis dir - cd $PIWIK_ROOT_DIR + - if [ -z "$TEST_SUITE" ]; + then php vendor/bin/coveralls -v; + fi + # output contents of files w/ debugging info to screen - cat /var/log/nginx/error.log - cat $PIWIK_ROOT_DIR/tmp/php-fpm.log diff --git a/tests/PHPUnit/phpunit.xml.dist b/tests/PHPUnit/phpunit.xml.dist index d344206dd2a..26fbd60a596 100644 --- a/tests/PHPUnit/phpunit.xml.dist +++ b/tests/PHPUnit/phpunit.xml.dist @@ -47,4 +47,17 @@ + + + ../../core + ../../plugins + + ../../core/Updates + ../../plugins/*/Updates + ../../plugins/*/libs + ../../plugins/*/tests + + + + diff --git a/tests/travis/travis.sh b/tests/travis/travis.sh index b3d0a7f3754..2d1d9ebac1e 100755 --- a/tests/travis/travis.sh +++ b/tests/travis/travis.sh @@ -64,5 +64,17 @@ then fi fi else - travis_wait phpunit --configuration phpunit.xml --coverage-text --colors + if [ "$COVERAGE" = "Integration" ] + then + echo "Executing non Integration tests in test suite IntegrationTests..." + phpunit --configuration phpunit.xml --testsuite IntegrationTests --exclude-group Integration --colors --coverage-clover $TRAVIS_BUILD_DIR/build/logs/clover-integration.xml || true + elif [ "$COVERAGE" = "Core" ] + then + echo "Executing tests in test suite CoreTests..." + phpunit --configuration phpunit.xml --testsuite CoreTests --colors --coverage-clover $TRAVIS_BUILD_DIR/build/logs/clover-core.xml || true + elif [ "$COVERAGE" = "Plugins" ] + then + echo "Executing tests in test suite PluginTests..." + phpunit --configuration phpunit.xml --testsuite PluginTests --colors --coverage-clover $TRAVIS_BUILD_DIR/build/logs/clover-plugins.xml || true + fi; fi \ No newline at end of file From de0efdee4da991c6df214ed68dca3061023063da Mon Sep 17 00:00:00 2001 From: sgiehl Date: Tue, 19 Aug 2014 23:22:45 +0200 Subject: [PATCH 2/3] enable fast finish for travis builds --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5029c10ccaf..2b3e2a6ce75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,7 @@ env: - secure: "CW73pDjcaabpSL7bWiWIQLydKmvLzA1gWNv/zK0VcAKezQtCAQbqpIY1+B56wOhkaCWa7P+xdd2gUWEtvvdRKEC0sZcgCdHD5pQx390e5PWCMQTFO+doAElI4w4DMATCbH890Wcw2rotiZcjlkPYY+urIpUlcRsl6mMtBVQuQ9c=" matrix: + fast_finish: true allow_failures: - php: hhvm - php: 5.6 From f7509a59b042ab77de05daf105a71ae49fa0908b Mon Sep 17 00:00:00 2001 From: sgiehl Date: Wed, 20 Aug 2014 20:52:12 +0200 Subject: [PATCH 3/3] refs #4224 - exclude example plugins from codecoverage reports --- tests/PHPUnit/phpunit.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/PHPUnit/phpunit.xml.dist b/tests/PHPUnit/phpunit.xml.dist index 26fbd60a596..e9c403593f8 100644 --- a/tests/PHPUnit/phpunit.xml.dist +++ b/tests/PHPUnit/phpunit.xml.dist @@ -53,6 +53,7 @@ ../../plugins ../../core/Updates + ../../plugins/Example* ../../plugins/*/Updates ../../plugins/*/libs ../../plugins/*/tests