diff options
author | Klaus Weidenbach <Klaus.Weidenbach@gmx.net> | 2016-10-22 22:43:25 +0200 |
---|---|---|
committer | Klaus Weidenbach <Klaus.Weidenbach@gmx.net> | 2017-03-14 20:31:13 +0100 |
commit | 33153b8f3a2e4974ae5b1e9f4017f669e35207fe (patch) | |
tree | e4d67029439358c6decb25d04a79e1c65245a99f | |
parent | bdfdd23b36cac0881ef4096180e1c9242753dd49 (diff) | |
download | volse-hubzilla-33153b8f3a2e4974ae5b1e9f4017f669e35207fe.tar.gz volse-hubzilla-33153b8f3a2e4974ae5b1e9f4017f669e35207fe.tar.bz2 volse-hubzilla-33153b8f3a2e4974ae5b1e9f4017f669e35207fe.zip |
[FEATURE] :construction_worker: Extend Travis CI integration.
Testing several Travis CI features.
Add DBs to travis execution matrix.
Doxygen API docu generation and deployment to gh-pages.
Update phpunit to 5.7.
-rwxr-xr-x | .gitignore | 3 | ||||
-rw-r--r-- | .travis.yml | 133 | ||||
-rw-r--r-- | composer.json | 2 | ||||
l--------- | tests/phpunit-mariadb.xml | 1 | ||||
-rw-r--r-- | tests/phpunit-mysql.xml | 37 | ||||
-rw-r--r-- | tests/phpunit-pgsql.xml | 34 | ||||
-rwxr-xr-x | tests/travis/gen_apidocs.sh | 86 | ||||
-rwxr-xr-x | tests/travis/prepare.sh | 35 | ||||
-rwxr-xr-x | tests/travis/prepare_mysql.sh | 37 | ||||
-rwxr-xr-x | tests/travis/prepare_pgsql.sh | 37 |
10 files changed, 378 insertions, 27 deletions
diff --git a/.gitignore b/.gitignore index 039a8f530..050902f17 100755 --- a/.gitignore +++ b/.gitignore @@ -44,7 +44,8 @@ doc/html/ .zotshrc # external repositories for themes/addons extend/ - +# files generated by phpunit +tests/results/ ## exclude IDE files # config files and folders from Eclipse diff --git a/.travis.yml b/.travis.yml index 3570fe411..6938033ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,44 +1,127 @@ +# +# Travis-CI configuration file +# +## configure things +# + # see http://about.travis-ci.org/docs/user/languages/php/ for more hints language: php -# list any PHP version you want to test against -php: - # using major version aliases +# use docker based containers +sudo: false + +# Git branches whitelist to build on Travis CI +branches: + only: + - master + - dev - # aliased to a recent 5.6.x version - - 5.6 - # aliased to a recent 7.x version - - 7.0 - # aliased to a recent hhvm version - - hhvm +# Install additional software +addons: + # Install dependencies for generating API documentation with doxygen + apt: + packages: + - doxygen + - doxygen-latex + - graphviz + - ttf-liberation -# optionally specify a list of environments, for example to test different RDBMS -#env: -# - DB=mysql -# - DB=pgsql +# enable and start databases? +#services: +# - mariadb +# - postgresql + +# any PHP version we want to test against, our unit tests require PHP>=5.6 +php: + - '5.6' + - '7.0' + #- hhvm -# optionally set up exclutions and allowed failures in the matrix +# list of environments to test +env: + global: + # used for doxygen deployment script + - DOXYFILE: $TRAVIS_BUILD_DIR/util/Doxyfile + - GHP_REPO_REF: github.com/redmatrix/hubzilla.git + # Uncomment if a newer/specific version of Doxygen should be used + #- DOXY_VER: 1.8.12 + # use matrix only for PHP and MySQL, all other combinations added through includes + matrix: + - DB=mysql + +# Matrix configuration details matrix: + fast_finish: true + # Additional check combinations + include: + # PHP7, mariadb 10.1 + - php: '7.0' + env: DB=mariadb MARIADB_VERSION=10.1 + # use mariadb instead of MySQL + addons: + mariadb: '10.1' + # PHP7, PostgreSQL 9.4 + - php: '7.0' + env: DB=pgsql POSTGRESQL_VERSION=9.4 + # Use newer postgres than 9.1 default + addons: + postgresql: '9.4' + # Exclude from default matrix combinations # exclude: # - php: hhvm # env: DB=pgsql # PDO driver for pgsql is unsupported by HHVM (3rd party install for support) - allow_failures: - - php: hhvm -# execute any number of scripts before the test run, custom env's are available as variables -#before_script: -# - if [[ "$DB" == "pgsql" ]]; then psql -c "DROP DATABASE IF EXISTS hello_world_test;" -U postgres; fi -# - if [[ "$DB" == "pgsql" ]]; then psql -c "create database hello_world_test;" -U postgres; fi -# - if [[ "$DB" == "mysql" ]]; then mysql -e "create database IF NOT EXISTS hello_world_test;" -uroot; fi +# cache composer downloads between runs +cache: + directories: + - $HOME/.composer/cache + + +# +## execute things +# + +before_install: + - travis_retry composer self-update + +# Install composer dev libs install: - - composer install --optimize-autoloader + - travis_retry composer install --optimize-autoloader + +# execute any number of scripts before the test run, custom env's are available as variables +before_script: + # Some preparation tasks of environment + - ./tests/travis/prepare.sh + # DB specific prepare scripts + - if [[ "$DB" == "mysql" ]]; then ./tests/travis/prepare_mysql.sh; fi + - if [[ "$DB" == "mariadb" ]]; then ./tests/travis/prepare_mysql.sh; fi + - if [[ "$DB" == "pgsql" ]]; then ./tests/travis/prepare_pgsql.sh; fi # omitting "script:" will default to phpunit -# use the $DB env variable to determine the phpunit.xml to use -script: vendor/bin/phpunit tests/unit/ +script: ./vendor/bin/phpunit -c tests/phpunit-$DB.xml + +after_success: + # Generate API documentation and deploy it to gh-pages + - ./tests/travis/gen_apidocs.sh +#after_failure: + +# Deploying a release to GitHub when tagging in master +# Waiting for upcoming 'Build Stages' Q1/Q2 2017 to make generation of API docs +# and release packages cleaner. https://github.com/travis-ci/travis-ci/issues/929 +#before_deploy: +#deploy: +# skip_cleaning: true +# provider: releases +# on: +# tags: true +#after_deploy: + +#after_script: + + # configure notifications (email, IRC, campfire etc) -notifications: +#notifications: # irc: "irc.freenode.org#yourfavouriteroomfortravis" # a plugin/script to post to a hubzilla channel would be neat here diff --git a/composer.json b/composer.json index b59c81bba..f355566f2 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ }, "require-dev" : { "php" : ">=5.6", - "phpunit/phpunit" : "^5.6", + "phpunit/phpunit" : "^5.7", "behat/behat" : "@stable", "behat/mink-extension": "@stable", "behat/mink-goutte-driver": "@stable" diff --git a/tests/phpunit-mariadb.xml b/tests/phpunit-mariadb.xml new file mode 120000 index 000000000..63656b78b --- /dev/null +++ b/tests/phpunit-mariadb.xml @@ -0,0 +1 @@ +phpunit-mysql.xml
\ No newline at end of file diff --git a/tests/phpunit-mysql.xml b/tests/phpunit-mysql.xml new file mode 100644 index 000000000..b421d7a7b --- /dev/null +++ b/tests/phpunit-mysql.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd" + backupGlobals="false" + beStrictAboutCoversAnnotation="true" + beStrictAboutOutputDuringTests="true" + beStrictAboutTestsThatDoNotTestAnything="true" + beStrictAboutTodoAnnotatedTests="true" + processIsolation="true" + verbose="true"> + <testsuite name="Hubzilla default Test Suite"> + <directory suffix="Test.php">./unit/</directory> + </testsuite> + <testsuite name="API Test Suite"> + <directory suffix="Test.php" prefix="API">./unit/</directory> + </testsuite> + <testsuite name="Ex-/Import Test Suite"> + <directory suffix="Test.php">./unit/eximport/</directory> + </testsuite> + <groups> + <exclude> + <group>postgresql</group> + </exclude> + </groups> + <!--cover reporting--> + <filter> + <whitelist processUncoveredFilesFromWhitelist="true"> + <directory suffix=".php">../Zotlabs/</directory> + <directory suffix=".php">../include/</directory> + </whitelist> + </filter> + <logging> + <log type="junit" target="./results/junit.xml" logIncompleteSkipped="false"/> + <log type="coverage-html" target="./results/report/" lowUpperBound="35" + highLowerBound="70"/> + </logging> +</phpunit> diff --git a/tests/phpunit-pgsql.xml b/tests/phpunit-pgsql.xml new file mode 100644 index 000000000..f59dd05ad --- /dev/null +++ b/tests/phpunit-pgsql.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd" + backupGlobals="false" + beStrictAboutCoversAnnotation="true" + beStrictAboutOutputDuringTests="true" + beStrictAboutTestsThatDoNotTestAnything="true" + beStrictAboutTodoAnnotatedTests="true" + processIsolation="true" + verbose="true"> + <testsuite name="Hubzilla default Test Suite"> + <directory suffix="Test.php">./unit/</directory> + </testsuite> + <testsuite name="API Test Suite"> + <directory suffix="Test.php" prefix="API">./unit/</directory> + </testsuite> + <groups> + <exclude> + <group>mysql</group> + </exclude> + </groups> + <!--cover reporting--> + <filter> + <whitelist processUncoveredFilesFromWhitelist="true"> + <directory suffix=".php">../Zotlabs/</directory> + <directory suffix=".php">../include/</directory> + </whitelist> + </filter> + <logging> + <log type="junit" target="./results/junit.xml" logIncompleteSkipped="false"/> + <log type="coverage-html" target="./results/report/" lowUpperBound="35" + highLowerBound="70"/> + </logging> +</phpunit> diff --git a/tests/travis/gen_apidocs.sh b/tests/travis/gen_apidocs.sh new file mode 100755 index 000000000..dc25347c6 --- /dev/null +++ b/tests/travis/gen_apidocs.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2016 Hubzilla +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +# Exit if anything fails +set -e + +# Only create and deploy API documentation once, on first build job. +# Waiting for upcoming 'Build Stages' Q1/Q2 2017 to make this cleaner. +# https://github.com/travis-ci/travis-ci/issues/929 +if [[ "$TRAVIS_JOB_NUMBER" != "${TRAVIS_BUILD_NUMBER}.1" ]]; then + echo "Not the first build job. Creating API documentation only once is enough." + echo "We are finished ..." + exit +fi + +# @TODO get newer doxygen +echo "Doxygen version 1.7 is too old for us :(" +doxygen --version + +# Only build API documentation for master branch push +if [[ "$TRAVIS_EVENT_TYPE" != "push" ]] || [[ "$TRAVIS_BRANCH" != "master" ]]; then + echo "Conditions not met to build API documentation." + echo "We are finished ..." + exit +fi + +echo "Generating Doxygen API documentation for master ..." + +cd $TRAVIS_BUILD_DIR +mkdir -p ./doc/html + +# Redirect stderr and stdout to log file and console +doxygen $DOXYFILE 2>&1 | tee ./doc/html/doxygen.log + +# Check if GitHub token is configured in Travis to be able to push to the repo +if [ -z "$GHP_TOKEN" ]; then + echo "No GitHub token configured in Travis, can not deploy to gh-pages ..." + echo "Add Environment Variable 'GHP_TOKEN' in Travis CI project settings" + echo "with a 'Personal access token' from GitHub with 'repo:public_repo'." + exit +fi + +# Upload the API documentation to the gh-pages branch of the GitHub repository. +# Only upload if Doxygen successfully created the documentation. +if [ -d "doc/html" ] && [ -f "doc/html/index.html" ]; then + echo "Uploading API documentation to the gh-pages branch ..." + + # Add the new API documentation as a Git commit + cd ./doc/html + + # Create and configure a new git repo for committing to gh-pages + git init + # Add a fake Travis CI user + git config user.name "Travis CI" + git config user.email "travis@travis-ci.org" + # Add the generated API documentation + git add --all + git commit -q -m "API documentation generated by Travis build: ${TRAVIS_BUILD_NUMBER}" -m "From commit: ${TRAVIS_COMMIT}" + + # No need for a history, force push to the remote gh-pages branch + git push -f "https://${GHP_TOKEN}@${GHP_REPO_REF}" master:gh-pages > /dev/null 2>&1 +else + echo "No API documentation files have been found" >&2 + exit 1 +fi diff --git a/tests/travis/prepare.sh b/tests/travis/prepare.sh new file mode 100755 index 000000000..267b4ec46 --- /dev/null +++ b/tests/travis/prepare.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2016 Hubzilla +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +# Exit if anything fails +set -e + +# gd is required, show some info about the used one +php -r "var_dump(gd_info());" + + +echo "Creating required folders for Hubzilla ..." +mkdir -p ./store/\[data\]/smarty3 + +echo "TODO: create .htconfig" diff --git a/tests/travis/prepare_mysql.sh b/tests/travis/prepare_mysql.sh new file mode 100755 index 000000000..96a562ac3 --- /dev/null +++ b/tests/travis/prepare_mysql.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2016 Hubzilla +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +# Exit if anything fails +set -e + +echo "Preparing for MySQL ..." + +# Print out some MySQL information +mysql --version +mysql -e "SELECT VERSION();" +mysql -e "SHOW VARIABLES LIKE 'max_allowed_packet';" +mysql -e "SELECT @@sql_mode;" + +# Create Hubzilla database +mysql -e "CREATE DATABASE IF NOT EXISTS hubzilla;" -uroot; diff --git a/tests/travis/prepare_pgsql.sh b/tests/travis/prepare_pgsql.sh new file mode 100755 index 000000000..64c3524e7 --- /dev/null +++ b/tests/travis/prepare_pgsql.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2016 Hubzilla +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +# Exit if anything fails +set -e + +echo "Preparing for PostgreSQL ..." + +# Print out some PostgreSQL information +psql --version +# Why does this hang further execution of the job? +#psql -c "SELECT VERSION();" -U postgres + +# Create Hubzilla database +psql -c "DROP DATABASE IF EXISTS hubzilla;" -U postgres +psql -c "CREATE DATABASE hubzilla;" -U postgres |