[FEATURE] 👷 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.
This commit is contained in:
Klaus Weidenbach 2016-10-22 22:43:25 +02:00
parent bdfdd23b36
commit 33153b8f3a
10 changed files with 379 additions and 28 deletions

3
.gitignore vendored
View File

@ -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

View File

@ -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
# use docker based containers
sudo: false
# Git branches whitelist to build on Travis CI
branches:
only:
- master
- dev
# Install additional software
addons:
# Install dependencies for generating API documentation with doxygen
apt:
packages:
- doxygen
- doxygen-latex
- graphviz
- ttf-liberation
# enable and start databases?
#services:
# - mariadb
# - postgresql
# any PHP version we want to test against, our unit tests require PHP>=5.6
php:
# using major version aliases
- '5.6'
- '7.0'
#- hhvm
# 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
# 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
# optionally specify a list of environments, for example to test different RDBMS
#env:
# - DB=mysql
# - DB=pgsql
# optionally set up exclutions and allowed failures in the matrix
# 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
# cache composer downloads between runs
cache:
directories:
- $HOME/.composer/cache
#
## execute things
#
before_install:
- travis_retry composer self-update
# Install composer dev libs
install:
- travis_retry composer install --optimize-autoloader
# 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
install:
- composer install --optimize-autoloader
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

View File

@ -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"

1
tests/phpunit-mariadb.xml Symbolic link
View File

@ -0,0 +1 @@
phpunit-mysql.xml

37
tests/phpunit-mysql.xml Normal file
View File

@ -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>

34
tests/phpunit-pgsql.xml Normal file
View File

@ -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>

86
tests/travis/gen_apidocs.sh Executable file
View File

@ -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

35
tests/travis/prepare.sh Executable file
View File

@ -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"

37
tests/travis/prepare_mysql.sh Executable file
View File

@ -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;

37
tests/travis/prepare_pgsql.sh Executable file
View File

@ -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