From 33153b8f3a2e4974ae5b1e9f4017f669e35207fe Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Sat, 22 Oct 2016 22:43:25 +0200 Subject: [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. --- tests/phpunit-mariadb.xml | 1 + tests/phpunit-mysql.xml | 37 +++++++++++++++++++ tests/phpunit-pgsql.xml | 34 +++++++++++++++++ tests/travis/gen_apidocs.sh | 86 +++++++++++++++++++++++++++++++++++++++++++ tests/travis/prepare.sh | 35 ++++++++++++++++++ tests/travis/prepare_mysql.sh | 37 +++++++++++++++++++ tests/travis/prepare_pgsql.sh | 37 +++++++++++++++++++ 7 files changed, 267 insertions(+) create mode 120000 tests/phpunit-mariadb.xml create mode 100644 tests/phpunit-mysql.xml create mode 100644 tests/phpunit-pgsql.xml create mode 100755 tests/travis/gen_apidocs.sh create mode 100755 tests/travis/prepare.sh create mode 100755 tests/travis/prepare_mysql.sh create mode 100755 tests/travis/prepare_pgsql.sh (limited to 'tests') 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 @@ + + + + ./unit/ + + + ./unit/ + + + ./unit/eximport/ + + + + postgresql + + + + + + ../Zotlabs/ + ../include/ + + + + + + + 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 @@ + + + + ./unit/ + + + ./unit/ + + + + mysql + + + + + + ../Zotlabs/ + ../include/ + + + + + + + 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 -- cgit v1.2.3 From 03db9833e833959bb2414b736fddb967763d0d4f Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Sun, 6 Nov 2016 21:31:02 +0100 Subject: :green_heart: Update Travis CI's Doxygen. Travis CI has Doxygen 1.7. We need 1.8 to generate our API documentation. Get a static version and use it. Always build API Documentation, but changed Doxygen configuration to only print out errors in the documentation generation, so these can be reviewed. --- tests/travis/gen_apidocs.sh | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/travis/gen_apidocs.sh b/tests/travis/gen_apidocs.sh index dc25347c6..248818117 100755 --- a/tests/travis/gen_apidocs.sh +++ b/tests/travis/gen_apidocs.sh @@ -34,25 +34,42 @@ if [[ "$TRAVIS_JOB_NUMBER" != "${TRAVIS_BUILD_NUMBER}.1" ]]; then exit fi -# @TODO get newer doxygen -echo "Doxygen version 1.7 is too old for us :(" -doxygen --version +# 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 +# Travis CI has an old Doxygen 1.7 build, so we fetch a recent static binary +export DOXY_BINPATH=$HOME/doxygen/doxygen-$DOXY_VER/bin +if [ ! -e "$DOXY_BINPATH/doxygen" ]; then + echo "Installing newer Doxygen $DOXY_VER ..." + mkdir -p $HOME/doxygen && cd $HOME/doxygen + wget -O - http://ftp.stack.nl/pub/users/dimitri/doxygen-$DOXY_VER.linux.bin.tar.gz | tar xz + export PATH=$PATH:$DOXY_BINPATH fi +echo "Doxygen version" +doxygen --version -echo "Generating Doxygen API documentation for master ..." - +echo "Generating Doxygen API documentation ..." cd $TRAVIS_BUILD_DIR mkdir -p ./doc/html - -# Redirect stderr and stdout to log file and console +# Redirect stderr and stdout to log file and console to be able to review documentation errors doxygen $DOXYFILE 2>&1 | tee ./doc/html/doxygen.log + +# There is no sane way yet, to prevent missuse of the push tokens in our workflow. +# We would need a way to limit a token to only push to gh-pages or a way to prevent +# manipulations to travis scripts which is not possible because we want it to run +# for pull requests. +# There are protected branches in GitHub, but they do not work for forced pushes. +exit + +# Only continue for master branch pushes +if [[ "$TRAVIS_EVENT_TYPE" != "push" ]] || [[ "$TRAVIS_BRANCH" != "master" ]]; then + echo "Conditions not met to build API documentation." + echo "We are finished ..." +# exit +fi + # 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 ..." -- cgit v1.2.3 From 8e80500ee68972eef7d9c004823d1a547270334f Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Mon, 5 Dec 2016 20:23:59 +0100 Subject: :construction_worker: use PHP7.1 and add PostgreSQL9.6 Use newer distro for Travis CI runs. New environment provides PostgreSQL9.6. Also no need to install custom Doxygen, made it optional. Changed default PHP environment from PHP7.0 to current PHP7.1. Changed codecoverage reporting. --- tests/travis/gen_apidocs.sh | 25 +++++++++++++------------ tests/travis/prepare_pgsql.sh | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/travis/gen_apidocs.sh b/tests/travis/gen_apidocs.sh index 248818117..ed5e429fa 100755 --- a/tests/travis/gen_apidocs.sh +++ b/tests/travis/gen_apidocs.sh @@ -34,20 +34,21 @@ if [[ "$TRAVIS_JOB_NUMBER" != "${TRAVIS_BUILD_NUMBER}.1" ]]; then exit fi -# Get newer Doxygen -#echo "Doxygen version 1.7 is too old for us :(" -#doxygen --version +echo "Doxygen version >= 1.8 is required" +doxygen --version -# Travis CI has an old Doxygen 1.7 build, so we fetch a recent static binary -export DOXY_BINPATH=$HOME/doxygen/doxygen-$DOXY_VER/bin -if [ ! -e "$DOXY_BINPATH/doxygen" ]; then - echo "Installing newer Doxygen $DOXY_VER ..." - mkdir -p $HOME/doxygen && cd $HOME/doxygen - wget -O - http://ftp.stack.nl/pub/users/dimitri/doxygen-$DOXY_VER.linux.bin.tar.gz | tar xz - export PATH=$PATH:$DOXY_BINPATH +# Check if newer version of Doxygen should be used +if [ ! -z "$DOXY_VER" ]; then + export DOXY_BINPATH=$HOME/doxygen/doxygen-$DOXY_VER/bin + if [ ! -e "$DOXY_BINPATH/doxygen" ]; then + echo "Installing newer Doxygen $DOXY_VER ..." + mkdir -p $HOME/doxygen && cd $HOME/doxygen + wget -O - http://ftp.stack.nl/pub/users/dimitri/doxygen-$DOXY_VER.linux.bin.tar.gz | tar xz + export PATH=$DOXY_BINPATH:$PATH + fi + echo "Doxygen version" + doxygen --version fi -echo "Doxygen version" -doxygen --version echo "Generating Doxygen API documentation ..." cd $TRAVIS_BUILD_DIR diff --git a/tests/travis/prepare_pgsql.sh b/tests/travis/prepare_pgsql.sh index 64c3524e7..dcd83f3be 100755 --- a/tests/travis/prepare_pgsql.sh +++ b/tests/travis/prepare_pgsql.sh @@ -30,7 +30,7 @@ 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 +psql -c "SELECT VERSION();" -U postgres # Create Hubzilla database psql -c "DROP DATABASE IF EXISTS hubzilla;" -U postgres -- cgit v1.2.3 From cb2eee1d2e82be62118482fb2668561c193a012b Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Fri, 27 Jan 2017 21:56:21 +0100 Subject: :construction_worker: Add old MySQL 5.5 to Travis CI again. The trusty distro contains MySQL 5.6. Add a precise distro with MySQL 5.5. Unfortunately 5.7 is not yet provided, which would be interesting because of the enabled strict SQL mode. --- tests/phpunit-mysql.xml | 2 +- tests/travis/prepare_mysql.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/phpunit-mysql.xml b/tests/phpunit-mysql.xml index b421d7a7b..9ba40f087 100644 --- a/tests/phpunit-mysql.xml +++ b/tests/phpunit-mysql.xml @@ -6,7 +6,7 @@ beStrictAboutOutputDuringTests="true" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutTodoAnnotatedTests="true" - processIsolation="true" + processIsolation="false" verbose="true"> ./unit/ diff --git a/tests/travis/prepare_mysql.sh b/tests/travis/prepare_mysql.sh index 96a562ac3..92c720205 100755 --- a/tests/travis/prepare_mysql.sh +++ b/tests/travis/prepare_mysql.sh @@ -31,6 +31,8 @@ echo "Preparing for MySQL ..." mysql --version mysql -e "SELECT VERSION();" mysql -e "SHOW VARIABLES LIKE 'max_allowed_packet';" +mysql -e "SHOW VARIABLES LIKE 'collation_%';" +mysql -e "SHOW VARIABLES LIKE 'character_set%';" mysql -e "SELECT @@sql_mode;" # Create Hubzilla database -- cgit v1.2.3 From 4a85726e5583e7de497077ded4e2ffbcd8b8a0b9 Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Sun, 5 Feb 2017 01:38:12 +0100 Subject: :construction_worker: :arrow_up: :heavy_plus_sign: Update PHPUnit to current stable 6. Update requirements to PHP7 for dev. Add php-mock-phpunit to mock and stub global functions in a better way. --- tests/phpunit-mysql.xml | 12 +-- tests/phpunit-pgsql.xml | 12 +-- tests/unit/Lib/PermissionDescriptionTest.php | 129 ++++++++++++--------------- 3 files changed, 69 insertions(+), 84 deletions(-) (limited to 'tests') diff --git a/tests/phpunit-mysql.xml b/tests/phpunit-mysql.xml index 9ba40f087..171211094 100644 --- a/tests/phpunit-mysql.xml +++ b/tests/phpunit-mysql.xml @@ -1,12 +1,11 @@ ./unit/ @@ -31,7 +30,8 @@ - + + diff --git a/tests/phpunit-pgsql.xml b/tests/phpunit-pgsql.xml index f59dd05ad..ace14e196 100644 --- a/tests/phpunit-pgsql.xml +++ b/tests/phpunit-pgsql.xml @@ -1,12 +1,11 @@ ./unit/ @@ -28,7 +27,8 @@ - + + diff --git a/tests/unit/Lib/PermissionDescriptionTest.php b/tests/unit/Lib/PermissionDescriptionTest.php index b1da5a0fd..97a39a2c8 100644 --- a/tests/unit/Lib/PermissionDescriptionTest.php +++ b/tests/unit/Lib/PermissionDescriptionTest.php @@ -1,6 +1,6 @@ assertEquals($permDesc, $permDesc2); + $this->assertNotEquals($permDesc, $permDesc3); + } - public function testFromDescription() { - $permDesc = PermissionDescription::fromDescription('test'); - $permDesc2 = PermissionDescription::fromDescription('test'); - $permDesc3 = PermissionDescription::fromDescription('test2'); + public function testFromStandalonePermission() { + // Create a stub for global function t() + $t = $this->getFunctionMock('Zotlabs\Lib', 't'); + $t->expects($this->atLeastOnce())->willReturnCallback( + function ($string) { + return $string; + } + ); + // Create a mock for global function logger() + $this->getFunctionMock('Zotlabs\Lib', 'logger'); - $this->assertEquals($permDesc, $permDesc2); - $this->assertNotEquals($permDesc, $permDesc3); - } + $permDescUnknown = PermissionDescription::fromStandalonePermission(-1); + $permDescSelf = PermissionDescription::fromStandalonePermission(0); - public function testFromStandalonePermission() { - $permDescUnknown = PermissionDescription::fromStandalonePermission(-1); - $permDescSelf = PermissionDescription::fromStandalonePermission(0); + $this->assertNull($permDescUnknown); + $this->assertNotNull($permDescSelf); + } - $this->assertNull($permDescUnknown); - $this->assertNotNull($permDescSelf); - } + public function testFromGlobalPermission() { + //$permDesc = PermissionDescription::fromGlobalPermission('view_profile'); - public function testFromGlobalPermission() { - //$permDesc = PermissionDescription::fromGlobalPermission('view_profile'); + $this->markTestIncomplete( + 'The method fromGlobalPermission() is not yet testable ...' + ); + } - $this->markTestIncomplete( - 'For this test we need more stubs...' - ); - } + public function testGetPermissionDescription() { + // Create a stub for global function t() + $t = $this->getFunctionMock('Zotlabs\Lib', 't'); + $t->expects($this->atLeastOnce())->willReturnCallback( + function ($string) { + return $string; + } + ); + // Create a mock for global function logger() + $this->getFunctionMock('Zotlabs\Lib', 'logger'); - public function testGetPermissionDescription() { + // Create a stub for the PermissionDescription class + $stub = $this->createMock(PermissionDescription::class); + $stub->method('get_permission_description') + ->will($this->returnArgument(0)); - // fromStandalonePermission uses get_permission_description(), so that will not help - //$permDescSelf = PermissionDescription::fromStandalonePermission(0); - //$permDescPublic = PermissionDescription::fromStandalonePermission(PERMS_PUBLIC); + $permDescSelf = PermissionDescription::fromStandalonePermission(0); + $this->assertInstanceOf(PermissionDescription::class, $permDescSelf); + $this->assertEquals($permDescSelf->get_permission_description(), 'Only me'); - $this->markTestIncomplete( - 'For this test we need a mock of PermissionDescription...' - ); - //$permDescSelf = - //$this->assertEquals($permDescSelf->, 'Only me'); - //$this->assertEquals($permDescPublic, 'Public'); - } + $permDescPublic = PermissionDescription::fromStandalonePermission(PERMS_PUBLIC); + $this->assertEquals($permDescPublic->get_permission_description(), 'Public'); } } -- cgit v1.2.3 From 5c080ca4e84d9c516d229b8a1248ad5aecf2fe0f Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Fri, 10 Mar 2017 01:01:35 +0100 Subject: :construction_worker: Add Travis' GitHub deployment steps. Changed API documentation deployment to gh_pages to Travis's GitHub Pages deployment. Also add Travis GitHub Release Deployment step to offer API documentation. Both steps are optional and need to be activated in Travis by setting GH_TOKEN. --- tests/travis/gen_apidocs.sh | 47 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 41 deletions(-) (limited to 'tests') diff --git a/tests/travis/gen_apidocs.sh b/tests/travis/gen_apidocs.sh index ed5e429fa..e5938e1e8 100755 --- a/tests/travis/gen_apidocs.sh +++ b/tests/travis/gen_apidocs.sh @@ -56,48 +56,13 @@ mkdir -p ./doc/html # Redirect stderr and stdout to log file and console to be able to review documentation errors doxygen $DOXYFILE 2>&1 | tee ./doc/html/doxygen.log - -# There is no sane way yet, to prevent missuse of the push tokens in our workflow. -# We would need a way to limit a token to only push to gh-pages or a way to prevent -# manipulations to travis scripts which is not possible because we want it to run -# for pull requests. -# There are protected branches in GitHub, but they do not work for forced pushes. -exit - -# Only continue for master branch pushes -if [[ "$TRAVIS_EVENT_TYPE" != "push" ]] || [[ "$TRAVIS_BRANCH" != "master" ]]; then - echo "Conditions not met to build API documentation." - echo "We are finished ..." -# exit -fi - -# 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. +# Check 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 + echo "API documentation generated" + if [ -n "${TRAVIS_TAG}" ]; then + echo "Generate API documentation archive for release deployment ..." + zip -9 -r -q doc/hubzilla-api-documentation.zip doc/html/ + fi else echo "No API documentation files have been found" >&2 exit 1 -- cgit v1.2.3