Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Add support for Travis CI #68

Merged
merged 6 commits into from almost 2 years ago

8 participants

Davey Shafik Romain Pouclet Sven Fuchs Reeze Xia David Soria Parra Ferenc Kovacs Michael C. Account for PHP Pull Requests
Davey Shafik

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

Romain Pouclet

This is awesome, thanks!

Sven Fuchs

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.

Davey Shafik

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 Xia
reeze commented April 27, 2012

Cool, Travis is awesome.

David Soria Parra
Owner
dsp commented April 30, 2012

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

run-tests.php
... ...
@@ -332,6 +332,7 @@ function write_information($show_html)
332 332
 define('PHP_QA_EMAIL', 'qa-reports@lists.php.net');
333 333
 define('QA_SUBMISSION_PAGE', 'http://qa.php.net/buildtest-process.php');
334 334
 define('QA_REPORTS_PAGE', 'http://qa.php.net/reports');
  335
+define('TRAVIS_CI' , !!getenv('TRAVIS_PHP_VERSION')); 
1
David Soria Parra Owner
dsp added a note May 25, 2012

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()
369 370
 			}
370 371
 
371 372
 			/* Ask the user to provide an email address, so that QA team can contact the user */
372  
-			if (!strncasecmp($user_input, 'y', 1) || strlen(trim($user_input)) == 0) {
  373
+            if (TRAVIS_CI) {
1
David Soria Parra Owner
dsp added a note May 25, 2012

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
David Soria Parra
Owner
dsp commented May 25, 2012

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

Ferenc Kovacs
Owner
Tyrael commented May 25, 2012

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

Michael C.

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

Davey Shafik dshafik referenced this pull request from a commit May 28, 2012
Commit has since been removed from the repository and is no longer available.
Davey Shafik
dshafik commented May 28, 2012

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

David Soria Parra
Owner
dsp commented June 03, 2012

@Tyrael would be great to have that fixed :)

David Soria Parra dsp referenced this pull request from a commit June 03, 2012
David Soria Parra 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
Account for PHP Pull Requests php-pulls merged commit 5ef46fe into from June 03, 2012
Account for PHP Pull Requests php-pulls closed this June 03, 2012
David Soria Parra
Owner
dsp commented June 03, 2012

Merged. Let's see how it works out

David Soria Parra
Owner
dsp commented June 03, 2012

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.
21  .travis.yml
... ...
@@ -0,0 +1,21 @@
  1
+language: php
  2
+
  3
+php:
  4
+    # We only specify one version so we only get one worker
  5
+    - 5.4
  6
+
  7
+env:
  8
+    - REPORT_EXIT_STATUS=1 TEST_PHP_EXECUTABLE=./sapi/cli/php
  9
+
  10
+before_script:
  11
+    # Compile PHP
  12
+    - ./travis/compile.sh
  13
+    # Setup Extensions 
  14
+    - . ./travis/ext/mysql/setup.sh
  15
+    - . ./travis/ext/mysqli/setup.sh
  16
+    - . ./travis/ext/pdo_mysql/setup.sh
  17
+    - . ./travis/ext/pgsql/setup.sh
  18
+    - . ./travis/ext/pdo_pgsql/setup.sh
  19
+
  20
+# Run PHPs run-tests.php 
  21
+script: ./sapi/cli/php run-tests.php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP"
15  run-tests.php
@@ -311,6 +311,7 @@ function write_information($show_html)
311 311
 define('PHP_QA_EMAIL', 'qa-reports@lists.php.net');
312 312
 define('QA_SUBMISSION_PAGE', 'http://qa.php.net/buildtest-process.php');
313 313
 define('QA_REPORTS_PAGE', 'http://qa.php.net/reports');
  314
+define('TRAVIS_CI' , (bool) getenv('TRAVIS_PHP_VERSION'));
314 315
 
315 316
 function save_or_mail_results()
316 317
 {
@@ -318,7 +319,7 @@ function save_or_mail_results()
318 319
 		   $PHP_FAILED_TESTS, $CUR_DIR, $php, $output_file, $compression;
319 320
 
320 321
 	/* We got failed Tests, offer the user to send an e-mail to QA team, unless NO_INTERACTION is set */
321  
-	if (!getenv('NO_INTERACTION')) {
  322
+	if (!getenv('NO_INTERACTION') && !TRAVIS_CI) {
322 323
 		$fp = fopen("php://stdin", "r+");
323 324
 		if ($sum_results['FAILED'] || $sum_results['BORKED'] || $sum_results['WARNED'] || $sum_results['LEAKED'] || $sum_results['XFAILED']) {
324 325
 			echo "\nYou may have found a problem in PHP.";
@@ -335,8 +336,8 @@ function save_or_mail_results()
335 336
 		$just_save_results = (strtolower($user_input[0]) == 's');
336 337
 	}
337 338
 
338  
-	if ($just_save_results || !getenv('NO_INTERACTION')) {
339  
-		if ($just_save_results || strlen(trim($user_input)) == 0 || strtolower($user_input[0]) == 'y') {
  339
+	if ($just_save_results || !getenv('NO_INTERACTION') || TRAVIS_CI) {
  340
+		if ($just_save_results || TRAVIS_CI || strlen(trim($user_input)) == 0 || strtolower($user_input[0]) == 'y') {
340 341
 			/*
341 342
 			 * Collect information about the host system for our report
342 343
 			 * Fetch phpinfo() output so that we can see the PHP enviroment
@@ -348,7 +349,9 @@ function save_or_mail_results()
348 349
 			}
349 350
 
350 351
 			/* Ask the user to provide an email address, so that QA team can contact the user */
351  
-			if (!strncasecmp($user_input, 'y', 1) || strlen(trim($user_input)) == 0) {
  352
+			if (TRAVIS_CI) {
  353
+				$user_email = 'travis at php dot net';
  354
+			} elseif (!strncasecmp($user_input, 'y', 1) || strlen(trim($user_input)) == 0) {
352 355
 				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): ";
353 356
 				flush();
354 357
 				$user_email = trim(fgets($fp, 1024));
@@ -424,7 +427,7 @@ function save_or_mail_results()
424 427
 			$failed_tests_data .= $sep . "PHPINFO" . $sep;
425 428
 			$failed_tests_data .= shell_exec($php . ' -ddisplay_errors=stderr -dhtml_errors=0 -i 2> /dev/null');
426 429
 
427  
-			if ($just_save_results || !mail_qa_team($failed_tests_data, $compression, $status)) {
  430
+			if ($just_save_results || !mail_qa_team($failed_tests_data, $compression, $status) && !TRAVIS_CI) {
428 431
 				file_put_contents($output_file, $failed_tests_data);
429 432
 
430 433
 				if (!$just_save_results) {
@@ -432,7 +435,7 @@ function save_or_mail_results()
432 435
 				}
433 436
 
434 437
 				echo "Please send " . $output_file . " to " . PHP_QA_EMAIL . " manually, thank you.\n";
435  
-			} else {
  438
+			} elseif (!getenv('NO_INTERACTION') && !TRAVIS_CI) {
436 439
 				fwrite($fp, "\nThank you for helping to make PHP better.\n");
437 440
 				fclose($fp);
438 441
 			}
39  travis/compile.sh
... ...
@@ -0,0 +1,39 @@
  1
+#!/bin/bash
  2
+./buildconf
  3
+./configure \
  4
+--with-pdo-mysql \
  5
+--with-mysql \
  6
+--with-mysqli \
  7
+--with-pgsql \
  8
+--with-pdo-pgsql \
  9
+--with-pdo-sqlite \
  10
+--enable-intl \
  11
+--without-pear \
  12
+--with-gd \
  13
+--with-jpeg-dir=/usr \
  14
+--with-png-dir=/usr \
  15
+--enable-exif \
  16
+--enable-zip \
  17
+--with-zlib \
  18
+--with-zlib-dir=/usr \
  19
+--with-mcrypt=/usr \
  20
+--enable-soap \
  21
+--enable-xmlreader \
  22
+--with-xsl \
  23
+--with-curl=/usr \
  24
+--with-tidy \
  25
+--with-xmlrpc \
  26
+--enable-sysvsem \
  27
+--enable-sysvshm \
  28
+--enable-shmop \
  29
+--enable-pcntl \
  30
+--with-readline \
  31
+--enable-mbstring \
  32
+--with-curl \
  33
+--with-gettext \
  34
+--enable-sockets \
  35
+--with-bz2 \
  36
+--enable-bcmath \
  37
+--enable-fastcgi \
  38
+--with-mime-magic
  39
+make
5  travis/ext/curl/setup.sh
... ...
@@ -0,0 +1,5 @@
  1
+#!/bin/bash
  2
+export PHP_CURL_HTTP_REMOTE_SERVER="http://localhost"
  3
+cd ./ext/curl/tests/responder
  4
+sudo php -S localhost:80 &
  5
+cd -
2  travis/ext/mysql/setup.sh
... ...
@@ -0,0 +1,2 @@
  1
+#!/bin/bash
  2
+mysql -u root -e "CREATE DATABASE IF NOT EXISTS test"
2  travis/ext/mysqli/setup.sh
... ...
@@ -0,0 +1,2 @@
  1
+#!/bin/bash
  2
+mysql -u root -e "CREATE DATABASE IF NOT EXISTS test"
2  travis/ext/pdo_mysql/setup.sh
... ...
@@ -0,0 +1,2 @@
  1
+#!/bin/bash
  2
+mysql -u root -e "CREATE DATABASE IF NOT EXISTS test"
2  travis/ext/pdo_pgsql/setup.sh
... ...
@@ -0,0 +1,2 @@
  1
+#!/bin/bash
  2
+export PDO_PGSQL_TEST_DSN='pgsql:host=localhost port=5432 dbname=test user=postgres password='
4  travis/ext/pgsql/setup.sh
... ...
@@ -0,0 +1,4 @@
  1
+#!/bin/bash
  2
+echo '                         
  3
+<?php $conn_str .= " user=postgres"; ?>' >> "./ext/pgsql/tests/config.inc"
  4
+psql -c 'create database test;' -U postgres
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.