mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
More versatile travis script
This commit is contained in:
parent
68188a3ae8
commit
ec213efe76
16
.travis.yml
16
.travis.yml
@ -1,24 +1,22 @@
|
|||||||
|
# See https://gist.github.com/chillu/5262316 for setup details
|
||||||
|
|
||||||
language: php
|
language: php
|
||||||
php:
|
php:
|
||||||
- 5.3
|
- 5.3
|
||||||
- 5.4
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- TESTDB=MYSQL CORE_RELEASE=3.0
|
- DB=MYSQL CORE_RELEASE=3.0
|
||||||
- TESTDB=MYSQL CORE_RELEASE=master
|
- DB=PGSQL CORE_RELEASE=3.0
|
||||||
- TESTDB=PGSQL CORE_RELEASE=master
|
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
exclude:
|
include:
|
||||||
- php: 5.4
|
- php: 5.4
|
||||||
env: TESTDB=PGSQL CORE_RELEASE=master
|
env: DB=MYSQL CORE_RELEASE=3.0
|
||||||
- php: 5.4
|
|
||||||
env: TESTDB=MYSQL CORE_RELEASE=3.0
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- pear -q install --onlyreqdeps pear/PHP_CodeSniffer
|
- pear -q install --onlyreqdeps pear/PHP_CodeSniffer
|
||||||
- phpenv rehash
|
- phpenv rehash
|
||||||
- ./tests/travis/before_script ~/builds/ss
|
- ./tests/travis/travis_setup.php --target ~/builds/ss
|
||||||
- cd ~/builds/ss
|
- cd ~/builds/ss
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
@ -9,8 +9,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Ingo Schommer",
|
"name": "Ingo Schommer",
|
||||||
"homepage": "http://chillu.com",
|
"homepage": "http://chillu.com",
|
||||||
"email" : "ingo@silverstripe.com",
|
"email" : "ingo@silverstripe.com"
|
||||||
"role" : "tech-lead"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require":
|
"require":
|
||||||
@ -19,6 +18,11 @@
|
|||||||
"silverstripe/framework": ">=3.0.1,<3.1",
|
"silverstripe/framework": ">=3.0.1,<3.1",
|
||||||
"silverstripe/cms": ">=3.0.1,<3.1"
|
"silverstripe/cms": ">=3.0.1,<3.1"
|
||||||
},
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"silverstripe/postgresql": "*",
|
||||||
|
"silverstripe/sqlite3": "*",
|
||||||
|
"silverstripe/mssql": "*"
|
||||||
|
},
|
||||||
"extra":
|
"extra":
|
||||||
{
|
{
|
||||||
"snapshot" : "http://www.silverstripe.org/assets/Uploads/translatable4-small.png"
|
"snapshot" : "http://www.silverstripe.org/assets/Uploads/translatable4-small.png"
|
||||||
|
@ -3,20 +3,48 @@
|
|||||||
global $project;
|
global $project;
|
||||||
$project = 'mysite';
|
$project = 'mysite';
|
||||||
|
|
||||||
global $database;
|
|
||||||
$database = '';
|
|
||||||
|
|
||||||
require_once('conf/ConfigureFromEnv.php');
|
|
||||||
|
|
||||||
global $databaseConfig;
|
global $databaseConfig;
|
||||||
$databaseConfig['memory'] = true;
|
switch(getenv('DB')) {
|
||||||
$databaseConfig['path'] = dirname(dirname(__FILE__)) .'/assets/';
|
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/'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
MySQLDatabase::set_connection_charset('utf8');
|
echo $databaseConfig['type'];
|
||||||
|
|
||||||
// Set the current theme. More themes can be downloaded from
|
Security::setDefaultAdmin('username', 'password');
|
||||||
// http://www.silverstripe.org/themes/
|
|
||||||
SSViewer::set_theme('simple');
|
|
||||||
|
|
||||||
// Enable nested URLs for this site (e.g. page/sub-page/)
|
// Fake hostname on CLI to stop framework from complaining
|
||||||
if(class_exists('SiteTree')) SiteTree::enable_nested_urls();
|
$_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');
|
||||||
|
}
|
@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
ob_start();
|
|
||||||
|
|
||||||
define('SS_ENVIRONMENT_TYPE', 'dev');
|
|
||||||
|
|
||||||
/* Database connection */
|
|
||||||
$db = getenv('TESTDB');
|
|
||||||
switch($db) {
|
|
||||||
case "PGSQL";
|
|
||||||
define('SS_DATABASE_CLASS', 'PostgreSQLDatabase');
|
|
||||||
define('SS_DATABASE_USERNAME', 'postgres');
|
|
||||||
define('SS_DATABASE_PASSWORD', '');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "MYSQL":
|
|
||||||
define('SS_DATABASE_CLASS', 'MySQLDatabase');
|
|
||||||
define('SS_DATABASE_USERNAME', 'root');
|
|
||||||
define('SS_DATABASE_PASSWORD', '');
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
define('SS_DATABASE_CLASS', 'SQLitePDODatabase');
|
|
||||||
define('SS_DATABASE_USERNAME', 'root');
|
|
||||||
define('SS_DATABASE_PASSWORD', '');
|
|
||||||
}
|
|
||||||
|
|
||||||
echo SS_DATABASE_CLASS;
|
|
||||||
|
|
||||||
define('SS_DATABASE_SERVER', 'localhost');
|
|
||||||
define('SS_DATABASE_CHOOSE_NAME', true);
|
|
||||||
|
|
||||||
|
|
||||||
/* Configure a default username and password to access the CMS on all sites in this environment. */
|
|
||||||
define('SS_DEFAULT_ADMIN_USERNAME', 'username');
|
|
||||||
define('SS_DEFAULT_ADMIN_PASSWORD', 'password');
|
|
||||||
|
|
||||||
$_FILE_TO_URL_MAPPING[dirname(__FILE__)] = 'http://localhost';
|
|
@ -1,25 +0,0 @@
|
|||||||
### USAGE: before_script <base-folder>
|
|
||||||
|
|
||||||
BUILD_DIR=$1
|
|
||||||
|
|
||||||
# Fetch all dependencies
|
|
||||||
# TODO Replace with different composer.json variations
|
|
||||||
echo "Checking out installer@$CORE_RELEASE"
|
|
||||||
git clone --depth=100 --quiet --branch $CORE_RELEASE git://github.com/silverstripe/silverstripe-installer.git $BUILD_DIR
|
|
||||||
echo "Checking out cms@$CORE_RELEASE"
|
|
||||||
git clone --depth=100 --quiet --branch $CORE_RELEASE git://github.com/silverstripe/silverstripe-cms.git $BUILD_DIR/cms
|
|
||||||
echo "Checking out framework@$CORE_RELEASE"
|
|
||||||
git clone --depth=100 --quiet --branch $CORE_RELEASE git://github.com/silverstripe/sapphire.git $BUILD_DIR/framework
|
|
||||||
echo "Checking out sqlite3"
|
|
||||||
git clone --depth=100 --quiet git://github.com/silverstripe-labs/silverstripe-sqlite3.git $BUILD_DIR/sqlite3
|
|
||||||
echo "Checking out postgresql"
|
|
||||||
git clone --depth=100 --quiet git://github.com/silverstripe/silverstripe-postgresql.git $BUILD_DIR/postgresql
|
|
||||||
|
|
||||||
# Copy setup files
|
|
||||||
cp ./tests/travis/_ss_environment.php $BUILD_DIR
|
|
||||||
cp ./tests/travis/_config.php $BUILD_DIR/mysite
|
|
||||||
|
|
||||||
# Copy actual project code into build directory (checked out by travis)
|
|
||||||
cp -r . $BUILD_DIR/translatable
|
|
||||||
|
|
||||||
cd $BUILD_DIR
|
|
91
tests/travis/travis_setup.php
Executable file
91
tests/travis/travis_setup.php
Executable file
@ -0,0 +1,91 @@
|
|||||||
|
#!/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-master';
|
||||||
|
$coreBranch = getenv('CORE_RELEASE');
|
||||||
|
$coreBranchComposer = (preg_match('/^\d\.\d/', $coreBranch)) ? $coreBranch . '.x-dev' : 'dev-master';
|
||||||
|
|
||||||
|
// 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");
|
Loading…
Reference in New Issue
Block a user