Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add support for Travis CI #68

Merged
merged 6 commits into from

8 participants

@dshafik

This is more of a proof of concept; it configures, builds and tests PHP with each commit.

What doesn't work:

  • NOT A BUG It isn't mailing the results of the run to the php.qa.reports ML (the ML is no longer used, need to confirm they do show up at http://qa.php.net/reports/ however)
  • FIXED It isn't exiting with 1 when there are failed tests despite setting REPORT_EXIT_STATUS=1
  • FIXED It isn't connecting to MySQL to test the mysql extensions

I'd like to:

  • Get as many DB extensions testing as possible
    • Travis supports: MySQL, PostgreSQL, SQLite3, MongoDB, CouchDB, Redis, Riak, Memcached
  • Get as many other extensions testing as possible
    • Travis can install dependencies using apt-get
  • Also get it working for PECL extensions

I'm just throwing this out here right now to gauge interest, and to see if anyone else wants to contribute :)

You can see this in action here, or just look at: Build Status

@Palleas

This is awesome, thanks!

@svenfuchs

If this gets merged in and you guys are interested in pull-request testing then shoot us a note at contact@travis-ci.org. This feature is currently being rolled out manually but we'd love to turn it on for php.

@dshafik

With 355cf75 the tests are now running against MySQL, PgSQL, and SQLite, and covers 53 extensions, running 99.2% of the full test suite.

I'm thinking seeing as this is a PHP 5.4 box, that we can use php -s in the ext/curl/tests/responder directory to allow setting of PHP_CURL_HTTP_REMOTE_SERVER for ext/curl.

@reeze

Cool, Travis is awesome.

@dsp
Owner

FYI looking into it. General idea is great, have to read about travis, etc first.

@dsp dsp was assigned
run-tests.php
@@ -332,6 +332,7 @@ function write_information($show_html)
define('PHP_QA_EMAIL', 'qa-reports@lists.php.net');
define('QA_SUBMISSION_PAGE', 'http://qa.php.net/buildtest-process.php');
define('QA_REPORTS_PAGE', 'http://qa.php.net/reports');
+define('TRAVIS_CI' , !!getenv('TRAVIS_PHP_VERSION'));
@dsp Owner
dsp added a note

Looks like idomatic JavaScript code. If you want to convert it to a boolean use

define('TRAVIS_CI', (boolean) getenv('TRAVIS_PHP_VERSION'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
run-tests.php
@@ -369,7 +370,9 @@ function save_or_mail_results()
}
/* Ask the user to provide an email address, so that QA team can contact the user */
- if (!strncasecmp($user_input, 'y', 1) || strlen(trim($user_input)) == 0) {
+ if (TRAVIS_CI) {
@dsp Owner
dsp added a note

Indention looks wrong on github. You probably used spaced, while the rest of the script uses tabs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@dsp
Owner

I like the idea. If there are no objections from internals I will go ahead and merge that once you squelched the little issues.

@Tyrael
Owner

for the REPORT_EXIT_STATUS problem see https://bugs.php.net/bug.php?id=60285

@michaelcullum

I know someone who is working on firebird support for travis but I have no idea how long that will take him.

@dshafik dshafik referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@dshafik

@dsp 5ef46fe should solve both the issues you raised.

@dsp
Owner
dsp commented

@Tyrael would be great to have that fixed :)

@dsp dsp referenced this pull request from a commit
@dsp dsp Merge branch 'pull-request/68'
By Davey Shafik
via Davey Shafik
* pull-request/68:
  Fix boolean casting and whitespace (@dsp / #68)
  Add curl extension config, uses cli-server to test
  Source all extension scripts for ENV vars
  Add extension configs, compile more extensions
  Reformat, setup MySQL DB, call run-tests directly
  Add support for Travis CI
8b0da0b
@php-pulls php-pulls merged commit 5ef46fe into php:master
@dsp
Owner
dsp commented

Merged. Let's see how it works out

@dsp
Owner
dsp commented

looks like tests on masters are currently failing, ci.qa.php.net shows 13 failing while travis has 52 failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
21 .travis.yml
@@ -0,0 +1,21 @@
+language: php
+
+php:
+ # We only specify one version so we only get one worker
+ - 5.4
+
+env:
+ - REPORT_EXIT_STATUS=1 TEST_PHP_EXECUTABLE=./sapi/cli/php
+
+before_script:
+ # Compile PHP
+ - ./travis/compile.sh
+ # Setup Extensions
+ - . ./travis/ext/mysql/setup.sh
+ - . ./travis/ext/mysqli/setup.sh
+ - . ./travis/ext/pdo_mysql/setup.sh
+ - . ./travis/ext/pgsql/setup.sh
+ - . ./travis/ext/pdo_pgsql/setup.sh
+
+# Run PHPs run-tests.php
+script: ./sapi/cli/php run-tests.php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP"
View
15 run-tests.php
@@ -311,6 +311,7 @@ function write_information($show_html)
define('PHP_QA_EMAIL', 'qa-reports@lists.php.net');
define('QA_SUBMISSION_PAGE', 'http://qa.php.net/buildtest-process.php');
define('QA_REPORTS_PAGE', 'http://qa.php.net/reports');
+define('TRAVIS_CI' , (bool) getenv('TRAVIS_PHP_VERSION'));
function save_or_mail_results()
{
@@ -318,7 +319,7 @@ function save_or_mail_results()
$PHP_FAILED_TESTS, $CUR_DIR, $php, $output_file, $compression;
/* We got failed Tests, offer the user to send an e-mail to QA team, unless NO_INTERACTION is set */
- if (!getenv('NO_INTERACTION')) {
+ if (!getenv('NO_INTERACTION') && !TRAVIS_CI) {
$fp = fopen("php://stdin", "r+");
if ($sum_results['FAILED'] || $sum_results['BORKED'] || $sum_results['WARNED'] || $sum_results['LEAKED'] || $sum_results['XFAILED']) {
echo "\nYou may have found a problem in PHP.";
@@ -335,8 +336,8 @@ function save_or_mail_results()
$just_save_results = (strtolower($user_input[0]) == 's');
}
- if ($just_save_results || !getenv('NO_INTERACTION')) {
- if ($just_save_results || strlen(trim($user_input)) == 0 || strtolower($user_input[0]) == 'y') {
+ if ($just_save_results || !getenv('NO_INTERACTION') || TRAVIS_CI) {
+ if ($just_save_results || TRAVIS_CI || strlen(trim($user_input)) == 0 || strtolower($user_input[0]) == 'y') {
/*
* Collect information about the host system for our report
* Fetch phpinfo() output so that we can see the PHP enviroment
@@ -348,7 +349,9 @@ function save_or_mail_results()
}
/* Ask the user to provide an email address, so that QA team can contact the user */
- if (!strncasecmp($user_input, 'y', 1) || strlen(trim($user_input)) == 0) {
+ if (TRAVIS_CI) {
+ $user_email = 'travis at php dot net';
+ } elseif (!strncasecmp($user_input, 'y', 1) || strlen(trim($user_input)) == 0) {
echo "\nPlease enter your email address.\n(Your address will be mangled so that it will not go out on any\nmailinglist in plain text): ";
flush();
$user_email = trim(fgets($fp, 1024));
@@ -424,7 +427,7 @@ function save_or_mail_results()
$failed_tests_data .= $sep . "PHPINFO" . $sep;
$failed_tests_data .= shell_exec($php . ' -ddisplay_errors=stderr -dhtml_errors=0 -i 2> /dev/null');
- if ($just_save_results || !mail_qa_team($failed_tests_data, $compression, $status)) {
+ if ($just_save_results || !mail_qa_team($failed_tests_data, $compression, $status) && !TRAVIS_CI) {
file_put_contents($output_file, $failed_tests_data);
if (!$just_save_results) {
@@ -432,7 +435,7 @@ function save_or_mail_results()
}
echo "Please send " . $output_file . " to " . PHP_QA_EMAIL . " manually, thank you.\n";
- } else {
+ } elseif (!getenv('NO_INTERACTION') && !TRAVIS_CI) {
fwrite($fp, "\nThank you for helping to make PHP better.\n");
fclose($fp);
}
View
39 travis/compile.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+./buildconf
+./configure \
+--with-pdo-mysql \
+--with-mysql \
+--with-mysqli \
+--with-pgsql \
+--with-pdo-pgsql \
+--with-pdo-sqlite \
+--enable-intl \
+--without-pear \
+--with-gd \
+--with-jpeg-dir=/usr \
+--with-png-dir=/usr \
+--enable-exif \
+--enable-zip \
+--with-zlib \
+--with-zlib-dir=/usr \
+--with-mcrypt=/usr \
+--enable-soap \
+--enable-xmlreader \
+--with-xsl \
+--with-curl=/usr \
+--with-tidy \
+--with-xmlrpc \
+--enable-sysvsem \
+--enable-sysvshm \
+--enable-shmop \
+--enable-pcntl \
+--with-readline \
+--enable-mbstring \
+--with-curl \
+--with-gettext \
+--enable-sockets \
+--with-bz2 \
+--enable-bcmath \
+--enable-fastcgi \
+--with-mime-magic
+make
View
5 travis/ext/curl/setup.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+export PHP_CURL_HTTP_REMOTE_SERVER="http://localhost"
+cd ./ext/curl/tests/responder
+sudo php -S localhost:80 &
+cd -
View
2  travis/ext/mysql/setup.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+mysql -u root -e "CREATE DATABASE IF NOT EXISTS test"
View
2  travis/ext/mysqli/setup.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+mysql -u root -e "CREATE DATABASE IF NOT EXISTS test"
View
2  travis/ext/pdo_mysql/setup.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+mysql -u root -e "CREATE DATABASE IF NOT EXISTS test"
View
2  travis/ext/pdo_pgsql/setup.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+export PDO_PGSQL_TEST_DSN='pgsql:host=localhost port=5432 dbname=test user=postgres password='
View
4 travis/ext/pgsql/setup.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+echo '
+<?php $conn_str .= " user=postgres"; ?>' >> "./ext/pgsql/tests/config.inc"
+psql -c 'create database test;' -U postgres
Something went wrong with that request. Please try again.