Skip to content

Commit

Permalink
WIP add Travis support
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed Apr 28, 2018
1 parent b9cce2f commit e3af7e6
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 0 deletions.
116 changes: 116 additions & 0 deletions .travis.yml
@@ -0,0 +1,116 @@
# A Travis configuration file for a bundle which aims to be compatible with both eZPublish 5 and eZPlatform

language: php

# use the docker-based Travis images for a tiny speed boost
sudo: false

# NB: see https://support.ez.no/Public/Service-Life for EOL dates of eZPublish versions
# and http://php.net/supported-versions.php for EOL dates of PHP versions
# but don't foget that php 5.3 is still supported by RedHat: https://access.redhat.com/support/policy/updates/errata.
# We limit the matrix to one version of eZPublish for each version of PHP
matrix:
include:
# The last version of eZPublish Community Project, aka eZPublish 5, corresponds to eZPublish Platform (Enterprise) 5.4
# About php versions:
# - php 5.6 can be installed on RHEL/CentOS 6, which is the oldest currently supported
# - Debian 8 comes with php 5.6 too (Debian 7 has php 5.4 but it is only in LTS support by now)
# We thus only test on php 5.6
- php: 5.6
env: EZ_PACKAGES='ezsystems/ezpublish-community:~2014.11.0 ezsystems/behatbundle:~5.4 netgen/tagsbundle:~2.0' EZ_VERSION=ezpublish-community EZ_APP_DIR=ezpublish EZ_KERNEL=EzPublishKernel CODE_COVERAGE=0 INSTALL_TAGSBUNDLE=1

# earliest stable version of eZPlatform aka eZPublish 6: 15.12 = 1.0
#- php: 5.6
# env: EZ_PACKAGES='ezsystems/ezplatform:~1.0.0 ezsystems/ezplatform-xmltext-fieldtype:^1.1 ezsystems/behatbundle:^6.3 netgen/tagsbundle:~2.0' EZ_VERSION=ezplatform EZ_APP_DIR=app EZ_KERNEL=AppKernel CODE_COVERAGE=0 INSTALL_TAGSBUNDLE=1
# latest version currently available of eZPlatform aka eZPublish 6
- php: 7.0
env: EZ_PACKAGES='ezsystems/ezplatform:~1.13.0 ezsystems/ezplatform-xmltext-fieldtype:^1.1 ezsystems/behatbundle:^6.3 netgen/tagsbundle:~2.0' EZ_VERSION=ezplatform EZ_APP_DIR=app EZ_KERNEL=AppKernel CODE_COVERAGE=0 INSTALL_TAGSBUNDLE=1
- php: 7.1
env: EZ_PACKAGES='ezsystems/ezplatform:~1.13.0 ezsystems/ezplatform-xmltext-fieldtype:^1.2 ezsystems/behatbundle:^6.4 netgen/tagsbundle:~2.2' EZ_VERSION=ezplatform EZ_APP_DIR=app EZ_KERNEL=AppKernel CODE_COVERAGE=1 INSTALL_TAGSBUNDLE=1
# latest version currently available of eZPlatform 2
- php: 7.2
env: EZ_PACKAGES='ezsystems/ezplatform:^2.0 ezsystems/ezplatform-xmltext-fieldtype:^1.3 ezsystems/behatbundle:^6.5 netgen/tagsbundle:~3.0' EZ_VERSION=ezplatform EZ_APP_DIR=app EZ_KERNEL=AppKernel CODE_COVERAGE=0 INSTALL_TAGSBUNDLE=1

allow_failures:
# this is failing because of composer running out of memory :-(
- php: 5.6

before_install:
# No need for a web server, until we start testing using Selenium
#- sudo apt-get update -qq
#- sudo apt-get install -qq -y --force-yes apache2 libapache2-mod-fastcgi

install:
# Latest version of composer breaks downloading eZ, so we can not run self-update. See https://github.com/composer/composer/issues/4582
#- composer self-update

# Increase php memory limit (need to do this now or we risk composer failing)
- phpenv config-add Tests/travis/zzz_php.ini

# Q: are all of these scripts ok here, or shall they be moved to the before_script step, when we add matrix combinations ???

# Disable xdebug for speed (executing composer), but allow us to e-enable it later
- export XDEBUG_INI=`php -i | grep xdebug.ini | grep home/travis | grep -v '=>' | head -1`
- export XDEBUG_INI=${XDEBUG_INI/,/}
- if [ "$XDEBUG_INI" != "" ]; then mv "$XDEBUG_INI" "$XDEBUG_INI.bak"; fi

# We do not rely on the requirements set in composer.json, but install a different eZ version depending on the test matrix
# For the moment, to install eZPlatform, a set of DEV packages have to be allowed; really ugly sed expression to alter composer.json follows
# TODO is this still needed?
- 'if [ "$EZ_VERSION" = "ezplatform" ]; then sed -i ''s/"license": "GPL-2.0",/"license": "GPL-2.0", "minimum-stability": "dev", "prefer-stable": true,/'' composer.json; fi'

# debugging memory problems with composer
#- sudo free -m -t
#- sudo service postgresql stop
#- sudo service memcached stop
#- sudo service --status-all
#- php -i

# TODO try enabling swap manually

- composer require --prefer-source --dev --no-update ${EZ_PACKAGES}
- composer update

# Re-enable xdebug for when we need to generate code coverage
- if [ "$CODE_COVERAGE" = "1" -a "$XDEBUG_INI" != "" ]; then mv "$XDEBUG_INI.bak" "$XDEBUG_INI"; fi

# Create the database from sql files present in either the legacy stack or kernel
- ./Tests/travis/create-db.sh ${EZ_VERSION} behattestdb ${INSTALL_TAGSBUNDLE} root

before_script:
# Set up configuration files
- ./Tests/travis/setup-config.sh ${EZ_VERSION} ${EZ_APP_DIR} ${EZ_KERNEL} ${INSTALL_TAGSBUNDLE}

- . ./Tests/travis/setup-env.sh ${EZ_VERSION}

# TODO are these needed at all?
#- php vendor/ezsystems/ezpublish-community/ezpublish/console --env=behat assetic:dump
#- php vendor/ezsystems/ezpublish-community/ezpublish/console --env=behat cache:clear --no-debug

# TODO for eZPlatform, do we need to set up SOLR as well ?
#- if [ "$EZ_VERSION" = "ezplatform" ]; then ./vendor/ezsystems/ezplatform-solr-search-engine:bin/.travis/init_solr.sh; fi

script:
# Finally! :-D
# Note: make sure we run the version of phpunit we installed, not the system one. See: https://github.com/sebastianbergmann/phpunit/issues/2014
- if [ "$CODE_COVERAGE" = "1" ]; then ./vendor/phpunit/phpunit/phpunit --stderr --colors --coverage-clover=coverage.clover Tests/phpunit; else ./vendor/phpunit/phpunit/phpunit --stderr --colors Tests/phpunit; fi

after_failure:
# Display as much info as we can to help developers
- php -i
#- cat composer.lock

after_script:
# Upload code-coverage to Scrutinizer
- if [ "$CODE_COVERAGE" = "1" -a -f coverage.clover ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- if [ "$CODE_COVERAGE" = "1" -a -f coverage.clover ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
# Upload code-coverage to CodeClimate. NB: this works only when the CODECLIMATE_REPO_TOKEN env var has been set (we do it in the Travis config via the GUI)
#- if [ "$CODE_COVERAGE" = "1" -a -f coverage.clover ]; then ./vendor/bin/test-reporter --coverage-report=coverage.clover; fi

# reduce depth (history) of git checkout
git:
depth: 5

cache:
directories:
- $COMPOSER_CACHE_DIR
35 changes: 35 additions & 0 deletions Tests/dsl/travis/create-db.sh
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

EZ_VERSION=$1
DB=$2
INSTALL_TAGSBUNDLE=$3
DB_USER=$4
DB_PWD=$5

if [ "$DB_PWD" != "" ]; then
DB_PWD="-p${DB_PWD}"
fi

mysql -u${DB_USER} ${DB_PWD} -e "DROP DATABASE IF EXISTS ${DB};"
mysql -u${DB_USER} ${DB_PWD} -e "CREATE DATABASE ${DB}; GRANT ALL ON ${DB}.* TO ezp@localhost IDENTIFIED BY 'ezp';"
# Create the database from sql files present in either the legacy stack or kernel
if [ "$EZ_VERSION" = "ezpublish-community" ]; then mysql -u${DB_USER} ${DB_PWD} ${DB} < vendor/ezsystems/ezpublish-legacy/kernel/sql/mysql/kernel_schema.sql; fi
if [ "$EZ_VERSION" = "ezpublish-community" ]; then mysql -u${DB_USER} ${DB_PWD} ${DB} < vendor/ezsystems/ezpublish-legacy/kernel/sql/common/cleandata.sql; fi
if [ "$EZ_VERSION" = "ezplatform" ]; then mysql -u${DB_USER} ${DB_PWD} ${DB} < vendor/ezsystems/ezpublish-kernel/data/mysql/schema.sql; fi
if [ "$EZ_VERSION" = "ezplatform" ]; then mysql -u${DB_USER} ${DB_PWD} ${DB} < vendor/ezsystems/ezpublish-kernel/data/cleandata.sql; fi

if [ "$INSTALL_TAGSBUNDLE" = "1" ]; then
if [ -f vendor/netgen/tagsbundle/Netgen/TagsBundle/Resources/sql/mysql/schema.sql ]; then
mysql -u${DB_USER} ${DB_PWD} ${DB} < vendor/netgen/tagsbundle/Netgen/TagsBundle/Resources/sql/mysql/schema.sql
else
if [ -f vendor/netgen/tagsbundle/bundle/Resources/sql/mysql/schema.sql ]; then
mysql -u${DB_USER} ${DB_PWD} ${DB} < vendor/netgen/tagsbundle/bundle/Resources/sql/mysql/schema.sql
else
if [ -f vendor/netgen/tagsbundle/Resources/sql/mysql/schema.sql ]; then
mysql -u${DB_USER} ${DB_PWD} ${DB} < vendor/netgen/tagsbundle/Resources/sql/mysql/schema.sql
else
echo "WARNING: should have loaded the Netgen TagsBundle db schema file but could not find it!"
fi
fi
fi
fi
37 changes: 37 additions & 0 deletions Tests/dsl/travis/setup-config.sh
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

EZ_VERSION=$1
EZ_APP_DIR=$2
EZ_KERNEL=$3
INSTALL_TAGSBUNDLE=$4

# Set up configuration files:
# eZ5 config files
cp vendor/ezsystems/${EZ_VERSION}/${EZ_APP_DIR}/config/parameters.yml.dist vendor/ezsystems/${EZ_VERSION}/${EZ_APP_DIR}/config/parameters.yml
cat Tests/ezpublish/config/config_behat_${EZ_VERSION}.yml >> vendor/ezsystems/${EZ_VERSION}/${EZ_APP_DIR}/config/config_behat.yml

# Load the migration bundle in the Sf kernel
sed -i 's/$bundles = array(/$bundles = array(new Kaliop\\eZMigrationBundle\\EzMigrationBundle(),/' vendor/ezsystems/${EZ_VERSION}/${EZ_APP_DIR}/${EZ_KERNEL}.php
# And optionally the Netgen tags bundle
if [ "$INSTALL_TAGSBUNDLE" = "1" ]; then
# we have to load netgen tags bundle after the Kernel bundles... hopefully OneupFlysystemBundle will stay there :-)
sed -i 's/OneupFlysystemBundle(),\?/OneupFlysystemBundle(), new Netgen\\TagsBundle\\NetgenTagsBundle(),/' vendor/ezsystems/${EZ_VERSION}/${EZ_APP_DIR}/${EZ_KERNEL}.php
fi
# And optionally the EzCoreExtraBundle bundle
if grep -q 'lolautruche/ez-core-extra-bundle' composer.lock; then
sed -i 's/OneupFlysystemBundle(),\?/OneupFlysystemBundle(), new Lolautruche\\EzCoreExtraBundle\\EzCoreExtraBundle(),/' vendor/ezsystems/${EZ_VERSION}/${EZ_APP_DIR}/${EZ_KERNEL}.php
fi
# For eZPlatform, load the xmltext bundle
if [ "$EZ_VERSION" = "ezplatform" ]; then
# we have to load netgen tags bundle after the Kernel bundles... hopefully OneupFlysystemBundle will stay there :-)
sed -i 's/AppBundle(),\?/AppBundle(), new EzSystems\\EzPlatformXmlTextFieldTypeBundle\\EzSystemsEzPlatformXmlTextFieldTypeBundle (),/' vendor/ezsystems/${EZ_VERSION}/${EZ_APP_DIR}/${EZ_KERNEL}.php
fi
# Fix the eZ5 autoload configuration for the unexpected directory layout
sed -i "s#'/../vendor/autoload.php'#'/../../../../vendor/autoload.php'#" vendor/ezsystems/${EZ_VERSION}/${EZ_APP_DIR}/autoload.php

# Generate legacy autoloads
if [ "$EZ_VERSION" != "ezplatform" ]; then cat Tests/ezpublish-legacy/config.php > vendor/ezsystems/ezpublish-legacy/config.php; fi
if [ "$EZ_VERSION" != "ezplatform" ]; then cd vendor/ezsystems/ezpublish-legacy && php bin/php/ezpgenerateautoloads.php && cd ../../..; fi

# Fix the phpunit configuration if needed
if [ "$EZ_VERSION" = "ezplatform" ]; then sed -i 's/"vendor\/ezsystems\/ezpublish-community\/ezpublish"/"vendor\/ezsystems\/ezplatform\/app"/' phpunit.xml; fi
13 changes: 13 additions & 0 deletions Tests/dsl/travis/setup-env.sh
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

EZ_VERSION=$1

# Set up env vars:

export SYMFONY_ENV=behat

if [ "$EZ_VERSION" = "ezplatform" ]; then
export KERNEL_DIR=vendor/ezsystems/ezplatform/app
else
export KERNEL_DIR=vendor/ezsystems/ezpublish-community/ezpublish
fi
8 changes: 8 additions & 0 deletions Tests/dsl/travis/zzz_php.ini
@@ -0,0 +1,8 @@
; This file is named funnily to make sure it gets loaded last after other config files in the same directory

; Make sure we do not run out of memory when running Composer
memory_limit = -1

; Avoid emitting php warnings
; This is needed to fix eZPublish code which emits warnings, such as: https://jira.ez.no/browse/EZP-26189
error_reporting = E_ALL & ~E_WARNING & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
52 changes: 52 additions & 0 deletions Tests/ezpublish/config/config_behat_ezplatform.yml
@@ -0,0 +1,52 @@

# This file will be appended to the equivalent one from eZPlatform distribution
# Used to set up an eZPlatform env from scratch for testing purposes (eg. on Travis)

parameters:
ezpublish.kernel.root_dir: %kernel.root_dir%/../../ezpublish-kernel

doctrine:
dbal:
connections:
default:
driver: pdo_mysql
host: localhost
user: root
dbname: behattestdb
charset: UTF8

ezpublish:
repositories:
behat: ~
siteaccess:
# Available siteaccesses
list:
- behat_site
- behat_site_admin
# Siteaccess groups. Use them to group common settings.
groups:
behat_group: [behat_site, behat_site_admin]
default_siteaccess: behat_site
match:
Map\URI:
behat_site_admin: behat_site_admin
Map\Host:
localhost: behat_site
system:
behat_group:
repository: behat
languages: [eng-GB]
var_dir: var/behat_site

stash:
caches:
default:
drivers: [ FileSystem ]
inMemory: true
registerDoctrineAdapter: false

swiftmailer:
disable_delivery: false
spool:
type: file
path: '%kernel.root_dir%/spool'
37 changes: 37 additions & 0 deletions Tests/ezpublish/config/config_behat_ezpublish-community.yml
@@ -0,0 +1,37 @@

# This file will be appended to the equivalent one from eZPublish Community distribution
# Used to set up an eZPublish env from scratch for testing purposes (eg. on Travis)

parameters:
# When installing eZPublish-Community as dependency, the directory where the eZ-Kernel package is changes, compared to where
# the SF Kernel class is...
ezpublish.kernel.root_dir: %kernel.root_dir%/../../ezpublish-kernel

# This is a fix for eZPublish 2014.03, backported from 2014.11: in 2014.03 the paths to these files are
# set relative to where the SF Kernel class is. We make them relative to where the eZ-Kernel package is
ezpublish.api.storage_engine.transformation_rules.resources:
- %ezpublish.kernel.root_dir%/eZ/Publish/Core/Persistence/Tests/TransformationProcessor/_fixtures/transformations/ascii.tr
- %ezpublish.kernel.root_dir%/eZ/Publish/Core/Persistence/Tests/TransformationProcessor/_fixtures/transformations/basic.tr
- %ezpublish.kernel.root_dir%/eZ/Publish/Core/Persistence/Tests/TransformationProcessor/_fixtures/transformations/cyrillic.tr
- %ezpublish.kernel.root_dir%/eZ/Publish/Core/Persistence/Tests/TransformationProcessor/_fixtures/transformations/greek.tr
- %ezpublish.kernel.root_dir%/eZ/Publish/Core/Persistence/Tests/TransformationProcessor/_fixtures/transformations/hebrew.tr
- %ezpublish.kernel.root_dir%/eZ/Publish/Core/Persistence/Tests/TransformationProcessor/_fixtures/transformations/latin.tr
- %ezpublish.kernel.root_dir%/eZ/Publish/Core/Persistence/Tests/TransformationProcessor/_fixtures/transformations/search.tr
ezpublish.api.storage_engine.preprocessed_transformation_rules.resources:
- %ezpublish.kernel.root_dir%/eZ/Publish/Core/Persistence/Tests/TransformationProcessor/_fixtures/transformations/ascii.tr.result
- %ezpublish.kernel.root_dir%/eZ/Publish/Core/Persistence/Tests/TransformationProcessor/_fixtures/transformations/basic.tr.result
- %ezpublish.kernel.root_dir%/eZ/Publish/Core/Persistence/Tests/TransformationProcessor/_fixtures/transformations/cyrillic.tr.result
- %ezpublish.kernel.root_dir%/eZ/Publish/Core/Persistence/Tests/TransformationProcessor/_fixtures/transformations/greek.tr.result
- %ezpublish.kernel.root_dir%/eZ/Publish/Core/Persistence/Tests/TransformationProcessor/_fixtures/transformations/hebrew.tr.result
- %ezpublish.kernel.root_dir%/eZ/Publish/Core/Persistence/Tests/TransformationProcessor/_fixtures/transformations/latin.tr.result
- %ezpublish.kernel.root_dir%/eZ/Publish/Core/Persistence/Tests/TransformationProcessor/_fixtures/transformations/search.tr.result
ezpublish.fieldType.ezrichtext.resources: %ezpublish.kernel.root_dir%/eZ/Publish/Core/FieldType/RichText/Resources

ez_publish_legacy:
root_dir: %kernel.root_dir%/../../ezpublish-legacy

swiftmailer:
disable_delivery: false
spool:
type: file
path: '%kernel.root_dir%/spool'
7 changes: 7 additions & 0 deletions Tests/ezpublish/config/services.yml
@@ -0,0 +1,7 @@

# NB: These services have to be loaded for the test suite to work. They should not be loaded for normal bundle operation
# The EzWorkflowEngineExtension class will take care of loading them automatically as long as the bootstrap.php file is run

parameters:

services:
5 changes: 5 additions & 0 deletions Tests/ezpublish_legacy/config.php
@@ -0,0 +1,5 @@
<?php

// Configuration needed for the legacy kernel to be able to bootstrap autoloading when the eZ5 application configuration
// is not in the root folder. The path to the eZ5 app is relative to the parent folder of the legacy kernel...
define('EZP_APP_FOLDER_NAME', 'ezpublish-community/ezpublish');

0 comments on commit e3af7e6

Please sign in to comment.