Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Travis CI #68

Merged
merged 6 commits into from
Jun 3, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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"
15 changes: 9 additions & 6 deletions run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,15 @@ 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()
{
global $sum_results, $just_save_results, $failed_test_summary,
$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.";
Expand All @@ -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
Expand All @@ -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));
Expand Down Expand Up @@ -424,15 +427,15 @@ 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) {
echo "\nThe test script was unable to automatically send the report to PHP's QA Team\n";
}

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);
}
Expand Down
39 changes: 39 additions & 0 deletions travis/compile.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions travis/ext/curl/setup.sh
Original file line number Diff line number Diff line change
@@ -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 -
2 changes: 2 additions & 0 deletions travis/ext/mysql/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
mysql -u root -e "CREATE DATABASE IF NOT EXISTS test"
2 changes: 2 additions & 0 deletions travis/ext/mysqli/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
mysql -u root -e "CREATE DATABASE IF NOT EXISTS test"
2 changes: 2 additions & 0 deletions travis/ext/pdo_mysql/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
mysql -u root -e "CREATE DATABASE IF NOT EXISTS test"
2 changes: 2 additions & 0 deletions travis/ext/pdo_pgsql/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
export PDO_PGSQL_TEST_DSN='pgsql:host=localhost port=5432 dbname=test user=postgres password='
4 changes: 4 additions & 0 deletions travis/ext/pgsql/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
echo '
<?php $conn_str .= " user=postgres"; ?>' >> "./ext/pgsql/tests/config.inc"
psql -c 'create database test;' -U postgres