Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Can Travis-CI test PHP based on Phalcon?

Is this possible to do? I have a lot to read about Travis-CI but it looks really cool. I have a totally bare-bones setup that shoudn't fail at all with:

language:
  - php

php:
  - 5.4
  - 5.5
  - 5.6

Which is really testing nothing. Anyone have any advice?



19.7k
Accepted
answer
edited Sep '14

You also need to tell travis what to do. Your yml file just tells Travis that it will test on PHP and the relevant versions (one VM per version)

Have a look at this file which we use for the core repo

https://github.com/phalcon/cphalcon/blob/master/.travis.yml

What services to install

services:
  - mongodb
  - memcached

Prerequisites

before_install:
 - ./unit-tests/ci/install_prereqs.sh
 - ./unit-tests/ci/setup_dbs.sh

Composer

install:
 - composer --prefer-source install

Update submodules

before_script:
 - git submodule --quiet update --init --recursive
 - (cd ext; export CFLAGS="-g3 -O1 -std=gnu90 -Wall -Werror -Wno-error=uninitialized"; phpize && ./configure --silent --enable-phalcon && make --silent -j4 > /dev/null && sudo make --silent install && phpenv config-add ../unit-tests/ci/phalcon.ini)
 - ulimit -c unlimited || true

Main script that runs the tests (PHPUnit) and its xml file

script:
 - ZEND_DONT_UNLOAD_MODULES=1 $(phpenv which php) ./unit-tests/ci/phpunit.php --debug -c unit-tests/phpunit.xml

In case there was a failure

after_failure:

- sudo apt-get -qq install gdb
 - ./unit-tests/ci/after_failure.sh

Who should be notified for this build

notifications:
  email:
    - [email protected]
    - [email protected]
    - [email protected]
    - [email protected]

If you are going to use Codeception, check this repo that I have been working with. It is the slow and painful path to converting all the tests to Codeception :)

https://github.com/niden/cphalcon/blob/2.0.0/.travis.yml

The runTests.sh file is:

#!/bin/sh

ZEND_DONT_UNLOAD_MODULES=1 $(phpenv which php) ./unit-tests/ci/phpunit.php --debug -c unit-tests/phpunit.xml --testsuite=stable

if [ "$(php -r 'echo substr(PHP_VERSION, 0, 3);')" = "5.3" ];
then
    # Not going to run any Codeception tests for 5.3
    echo ".."
else
   $(phpenv which php) codecept.phar build
   ZEND_DONT_UNLOAD_MODULES=1 $(phpenv which php) codecept.phar run
fi