Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Simplified travis builds (using external script)

  • Loading branch information...
commit 7f9dd3e17ed49c93ab786e8eac9d387d08116101 1 parent 0676281
@chillu chillu authored
View
5 .travis.yml
@@ -1,4 +1,4 @@
-# See https://gist.github.com/chillu/5262316 for setup details
+# See https://github.com/silverstripe-labs/silverstripe-travis-support for setup details
language: php
php:
@@ -17,7 +17,8 @@ matrix:
before_script:
- pear -q install --onlyreqdeps pear/PHP_CodeSniffer
- phpenv rehash
- - ./tests/travis/travis_setup.php --target ~/builds/ss
+ - git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
+ - php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
- cd ~/builds/ss
script:
View
50 tests/travis/_config.php
@@ -1,50 +0,0 @@
-<?php
-
-global $project;
-$project = 'mysite';
-
-global $databaseConfig;
-switch(getenv('DB')) {
-case "PGSQL";
- $databaseConfig = array(
- "type" => "PostgreSQLDatabase",
- "server" => 'localhost',
- "username" => 'postgres',
- "password" => '',
- "database" => 'SS_travis'
- );
- break;
-case "MYSQL":
- $databaseConfig = array(
- "type" => "MySQLDatabase",
- "server" => 'localhost',
- "username" => 'root',
- "password" => '',
- "database" => 'SS_travis'
- );
- break;
-default:
- $databaseConfig = array(
- "type" => "SQLitePDODatabase",
- "server" => 'localhost',
- "memory" => true,
- "database" => 'SS_travis',
- 'path' => dirname(dirname(__FILE__)) .'/assets/'
- );
-}
-
-echo $databaseConfig['type'];
-
-Security::setDefaultAdmin('username', 'password');
-
-// Fake hostname on CLI to stop framework from complaining
-$_SERVER['HTTP_HOST'] = 'http://localhost';
-
-// Version-specific configuration
-$version = getenv('CORE_RELEASE');
-if($version != 'master' && version_compare('3.1', $version) == -1) {
- MySQLDatabase::set_connection_charset('utf8');
- SSViewer::set_theme('simple');
-} else {
- Config::inst()->update('SSViewer', 'theme', 'simple');
-}
View
91 tests/travis/travis_setup.php
@@ -1,91 +0,0 @@
-#!/usr/bin/env php
-<?php
-/**
- * Initialises a test project that can be built by travis.
- *
- * Travis downloads the module, but in order to run unit tests it needs
- * to be part of a SilverStripe "installer" project.
- * This script generates a custom composer.json with the required dependencies
- * and installs it into a separate webroot. The originally downloaded module
- * code is re-installed via composer.
- */
-
-if (php_sapi_name() != 'cli') {
- header('HTTP/1.0 404 Not Found');
- exit;
-}
-
-$opts = getopt('', array(
- 'target:',
-));
-
-if (!$opts) {
- echo "Invalid arguments specified\n";
- exit(1);
-}
-
-extract($opts);
-
-$dir = __DIR__;
-$modulePath = dirname(dirname($dir));
-$moduleName = basename($modulePath);
-$parent = dirname($modulePath);
-
-// Get exact version of downloaded module so we can re-download via composer
-$moduleRevision = getenv('TRAVIS_COMMIT');
-$moduleBranch = getenv('TRAVIS_BRANCH');
-$moduleBranchComposer = (preg_match('/^\d\.\d/', $moduleBranch)) ? $moduleBranch . '.x-dev' : 'dev-' . $moduleBranch;
-$coreBranch = getenv('CORE_RELEASE');
-$coreBranchComposer = (preg_match('/^\d\.\d/', $coreBranch)) ? $coreBranch . '.x-dev' : 'dev-' . $moduleBranch;
-
-// Print out some environment information.
-printf("Environment:\n");
-printf(" * MySQL: %s\n", trim(`mysql --version`));
-printf(" * PostgreSQL: %s\n", trim(`pg_config --version`));
-printf(" * SQLite: %s\n\n", trim(`sqlite3 -version`));
-
-// Extract the package info from the module composer file, and build a
-// custom project composer file with the local package explicitly defined.
-echo "Reading composer information...\n";
-
-$package = json_decode(file_get_contents("$modulePath/composer.json"), true);
-
-// Generate a custom composer file.
-$packageNew = array(
- 'require' => array_merge(
- isset($package['require']) ? $package['require'] : array(),
- array($package['name'] => $moduleBranchComposer . '#' . $moduleRevision,)
- ),
- // Always include DBs, allow module specific version dependencies though
- 'require-dev' => array_merge(
- array('silverstripe/postgresql' => '*','silverstripe/sqlite3' => '*'),
- isset($package['require-dev']) ? $package['require-dev'] : array()
- ),
- 'minimum-stability' => 'dev'
-);
-// Override module dependencies in order to test with specific core branch.
-// This might be older than the latest permitted version based on the module definition.
-// Its up to the module author to declare compatible CORE_RELEASE values in the .travis.yml.
-if(isset($packageNew['require']['silverstripe/framework'])) {
- $packageNew['require']['silverstripe/framework'] = $coreBranchComposer;
-}
-if(isset($packageNew['require']['silverstripe/cms'])) {
- $packageNew['require']['silverstripe/cms'] = $coreBranchComposer;
-}
-$composer = json_encode($packageNew);
-
-echo "Generated composer file:\n";
-echo "$composer\n\n";
-
-echo "Cloning installer@$coreBranch...\n";
-`git clone --depth=100 --quiet -b $coreBranch git://github.com/silverstripe/silverstripe-installer.git $target`;
-
-echo "Setting up project...\n";
-`cp $dir/_config.php $target/mysite`;
-
-echo "Replacing composer file...\n";
-unlink("$target/composer.json");
-file_put_contents("$target/composer.json", $composer);
-
-echo "Running composer...\n";
-passthru("composer install --prefer-dist --dev -d $target");
Please sign in to comment.
Something went wrong with that request. Please try again.