Skip to content
Snippets Groups Projects
Commit c81b99b7 authored by Tim Hunt's avatar Tim Hunt
Browse files

Fix travis setup and improve test install process

parent 57cbe33d
Branches
No related tags found
No related merge requests found
sudo: required
dist: trusty # Required so we get a not-totally-ancient build of Maxima.
language: php
sudo: required
addons:
firefox: "47.0.1"
postgresql: "9.3"
apt:
packages:
- oracle-java8-installer
- oracle-java8-set-default
- maxima
- maxima-share
- texinfo
cache:
directories:
- $HOME/.composer/cache
- $HOME/.npm
matrix:
# I would like to run at least some of these with DB=mysqli, but that
......@@ -15,79 +27,60 @@ matrix:
# how to do that.
include:
# Just retain one test on PHP 5.6 for the version 4.2 release.
- php: 5.6
env: TASK=PHPUNIT MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli
- php: 7.0
env: TASK=PHPUNIT MOODLE_BRANCH=MOODLE_31_STABLE DB=mysqli
- php: 7.0
env: TASK=PHPUNIT MOODLE_BRANCH=MOODLE_32_STABLE DB=mysqli
# - php: 7.0
# env: TASK=PHPUNIT MOODLE_BRANCH=MOODLE_32_STABLE DB=pgsql
- php: 7.0
env: TASK=PHPUNIT MOODLE_BRANCH=MOODLE_33_STABLE DB=mysqli
# - php: 5.6
# env: TASK=PHPUNIT MOODLE_BRANCH=MOODLE_33_STABLE DB=mysqli
- php: 7.0
env: TASK=PHPUNIT MOODLE_BRANCH=MOODLE_34_STABLE DB=mysqli
# Would be good to run this next test in PHP 7.2, but STACK does not support that yet.
# - php: 7.1
# env: TASK=PHPUNIT MOODLE_BRANCH=MOODLE_34_STABLE DB=pgsql
- php: 7.0
- php: 7.1
env: TASK=PHPUNIT MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli
- php: 5.6
env: TASK=BEHAT MOODLE_BRANCH=MOODLE_31_STABLE DB=mysqli
- php: 7.0
env: TASK=BEHAT MOODLE_BRANCH=MOODLE_32_STABLE DB=mysqli
# - php: 5.6
# env: TASK=BEHAT MOODLE_BRANCH=MOODLE_32_STABLE DB=mysqli
- php: 7.0
env: TASK=BEHAT MOODLE_BRANCH=MOODLE_33_STABLE DB=mysqli
# - php: 7.0
# env: TASK=BEHAT MOODLE_BRANCH=MOODLE_33_STABLE DB=pgsql
- php: 7.0
env: TASK=BEHAT MOODLE_BRANCH=MOODLE_34_STABLE DB=mysqli
# - php: 7.1
# env: TASK=BEHAT MOODLE_BRANCH=MOODLE_34_STABLE DB=mysqli
- php: 7.0
env: TASK=BEHAT MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli
# Would be good to run this next test in PHP 7.2, but STACK does not support that yet.
# - php: 7.1
# env: TASK=BEHAT MOODLE_BRANCH=MOODLE_35_STABLE DB=pgsql
- php: 7.0
env: TASK=CODESTYLE MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli
# - php: 7.1
# env: TASK=CODESTYLE MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli
- php: 7.0
env: TASK=CODEKNOWNFAILS MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli
# - php: 7.1
# env: TASK=CODEKNOWNFAILS MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli
allow_failures:
- php: 7.0
env: TASK=CODEKNOWNFAILS MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli
# - php: 7.1
# env: TASK=CODEKNOWNFAILS MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli
before_install:
- sudo apt-get update
- sudo apt-get install maxima maxima-share texinfo
- maxima --list-avail
# Travis seems to be using Maxime version 5.32.1, lisp gcl, which is very old!
- sudo locale-gen "en_AU.UTF-8"
- sudo dpkg-reconfigure locales
- phpenv config-rm xdebug.ini
- nvm install 8.9
- nvm use 8.9
- cd ../..
- composer selfupdate
- composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^1
- composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^2
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
- mkdir behat_output
install:
- moodle-plugin-ci add-plugin maths/moodle-qbehaviour_dfexplicitvaildate
- moodle-plugin-ci add-plugin maths/moodle-qbehaviour_dfcbmexplicitvaildate
- moodle-plugin-ci add-plugin maths/moodle-qbehaviour_adaptivemultipart
- moodle-plugin-ci install
- moodle-plugin-ci add-config 'define("QTYPE_STACK_TEST_CONFIG_PLATFORM", "unix");'
- moodle-plugin-ci add-config 'define("QTYPE_STACK_TEST_CONFIG_MAXIMAVERSION", "'`maxima --version | sed 's/Maxima //'`'");'
- moodle-plugin-ci add-config 'define("QTYPE_STACK_TEST_CONFIG_CASTIMEOUT", "20");'
- moodle-plugin-ci add-config 'define("QTYPE_STACK_TEST_CONFIG_CASRESULTSCACHE", "none");'
- moodle-plugin-ci add-config 'define("QTYPE_STACK_TEST_CONFIG_MAXIMACOMMAND", "maxima");'
- moodle-plugin-ci add-config 'define("QTYPE_STACK_TEST_CONFIG_PLOTCOMMAND", "gnuplot");'
- moodle-plugin-ci add-config 'define("QTYPE_STACK_TEST_CONFIG_CASDEBUGGING", "0");'
# Prepare to capture Behat failures.
- moodle-plugin-ci add-config '$CFG->behat_faildump_path = "'`pwd`'/behat_output";'
# Output some diagnostic about how the install went.
# Travis seems to be using Maxima version 5.32.1, lisp gcl, which is very old!
- maxima --list-avail
- echo 'ATAlgEquiv(x^2-1,(x-1)*(x+1));quit();' | /home/travis/build/moodledata/phpu_moodledata/stack/maxima_opt_auto -eval '(cl-user::run)'
script:
# Run all the PHP unit tests.
......@@ -95,18 +88,16 @@ script:
# Run all the Behat tests.
- if [ "$TASK" = 'BEHAT' ]; then moodle-plugin-ci behat; fi
# The next line dumps the HTML of any failures to stdout. Not nice, but sufficient for now.
- if [ "$TASK" = 'BEHAT' ]; then find behat_output -name '*.html' -type f -print -exec cat {} \; ; fi
# Run all the various code style tests - this subset should all pass.
- if [ "$TASK" = 'CODESTYLE' ]; then moodle-plugin-ci phplint; fi
- if [ "$TASK" = 'CODESTYLE' ]; then moodle-plugin-ci phpmd; fi
- if [ "$TASK" = 'CODESTYLE' ]; then moodle-plugin-ci csslint; fi
- if [ "$TASK" = 'CODESTYLE' ]; then moodle-plugin-ci shifter; fi
- if [ "$TASK" = 'CODESTYLE' ]; then moodle-plugin-ci validate; fi
- if [ "$TASK" = 'CODESTYLE' ]; then moodle-plugin-ci savepoints; fi
- if [ "$TASK" = 'CODESTYLE' ]; then moodle-plugin-ci mustache; fi
- if [ "$TASK" = 'CODESTYLE' ]; then moodle-plugin-ci grunt; fi
# Run all the various code style tests - these ones are konwn to fail.
# Once we get them passing, move them to the CODESTYLE section above.
- if [ "$TASK" = 'CODEKNOWNFAILS' ]; then moodle-plugin-ci phpmd; fi
- if [ "$TASK" = 'CODEKNOWNFAILS' ]; then moodle-plugin-ci phpcpd; fi
- if [ "$TASK" = 'CODEKNOWNFAILS' ]; then moodle-plugin-ci codechecker; fi
- if [ "$TASK" = 'CODEKNOWNFAILS' ]; then moodle-plugin-ci jshint; fi
......@@ -39,14 +39,44 @@ function xmldb_qtype_stack_install() {
}
set_config('stackmaximaversion', $matches[1], 'qtype_stack');
// The values we want to set here cannot have a default specified in settings.php, because
// any defaults there overwrite anything set here. Since there cannot be a default in settings.php,
// we have to set all those values here.
// Make an reasonable guess at the OS. (It defaults to 'unix' in settings.php.
$platform = 'unix';
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
// See http://stackoverflow.com/questions/1482260/how-to-get-the-os-on-which-php-is-running
// and http://stackoverflow.com/questions/738823/possible-values-for-php-os.
set_config('platform', 'win', 'qtype_stack');
$platform = 'win';
}
set_config('platform', $platform, 'qtype_stack');
// If this is a PHP unit test site, automatically create maxima_opt_auto.
// Should probably consider doing this for real in the future.
if ($platform != 'win' && (PHPUNIT_TEST || defined('BEHAT_UTIL'))) {
// Set to the same defaults as in settings.php - however, that has not been done
// yet in the Moodle install code flow, so we have to duplicate here.
set_config('maximaversion', 'default', 'qtype_stack');
set_config('castimeout', 10, 'qtype_stack');
set_config('casresultscache', 'db', 'qtype_stack');
set_config('maximacommand', '', 'qtype_stack');
set_config('serveruserpass', '', 'qtype_stack');
set_config('plotcommand', '', 'qtype_stack');
// Trying to load the libraries leads to a fail to load /usr/share/maxima/5.32.1/share/draw/draw.lisp error.
// Need to sort this out.
// set_config('maximalibraries', 'stats, distrib, descriptive, simplex', 'qtype_stack');
set_config('maximalibraries', '', 'qtype_stack');
set_config('casdebugging', 1, 'qtype_stack');
set_config('mathsdisplay', 'mathjax', 'qtype_stack');
// TODO: Attempt to create an optimised image at install time.
list($ok, $message) = stack_cas_configuration::create_auto_maxima_image();
if (!$ok) {
throw new coding_exception('maxima_opt_auto creation failed.', $message);
}
} else {
set_config('maximaversion', 'default', 'qtype_stack');
set_config('maximacommand', 'http://vle-stack-acct:8080/MaximaPool/MaximaPool', 'qtype_stack');
set_config('maximalibraries', 'stats, distrib, descriptive, simplex', 'qtype_stack');
}
}
......@@ -51,13 +51,16 @@ $settings->add(new admin_setting_heading('docs',
// Options for connection to Maxima.
// Note that any settings here where we try to set the default
// intelligently in install.php, the default here must be null.
// Otherwise, the default here will overwrite anything set in install.php.
$settings->add(new admin_setting_heading('maixmasettingsheading',
get_string('settingsmaximasettings', 'qtype_stack'), ''));
$settings->add(new admin_setting_configselect('qtype_stack/platform',
get_string('settingplatformtype', 'qtype_stack'),
// Note, install.php tries to auto-detect Windows installs, and set the default appropriately.
get_string('settingplatformtype_desc', 'qtype_stack'), 'unix', array(
get_string('settingplatformtype_desc', 'qtype_stack'), null, array(
'unix' => get_string('settingplatformtypeunix', 'qtype_stack'),
'unix-optimised' => get_string('settingplatformtypeunixoptimised', 'qtype_stack'),
'win' => get_string('settingplatformtypewin', 'qtype_stack'),
......@@ -65,7 +68,7 @@ $settings->add(new admin_setting_configselect('qtype_stack/platform',
$settings->add(new admin_setting_configselect('qtype_stack/maximaversion',
get_string('settingcasmaximaversion', 'qtype_stack'),
get_string('settingcasmaximaversion_desc', 'qtype_stack'), 'default',
get_string('settingcasmaximaversion_desc', 'qtype_stack'), null,
array('5.23.2' => '5.23.2', '5.25.1' => '5.25.1', '5.26.0' => '5.26.0',
'5.27.0' => '5.27.0', '5.28.0' => '5.28.0', '5.30.0' => '5.30.0',
'5.31.1' => '5.31.1', '5.31.2' => '5.31.2', '5.31.3' => '5.31.3',
......@@ -90,7 +93,7 @@ $settings->add(new admin_setting_configselect('qtype_stack/casresultscache',
$settings->add(new admin_setting_configtext('qtype_stack/maximacommand',
get_string('settingplatformmaximacommand', 'qtype_stack'),
get_string('settingplatformmaximacommand_desc', 'qtype_stack'), ''));
get_string('settingplatformmaximacommand_desc', 'qtype_stack'), null));
$settings->add(new admin_setting_configtext('qtype_stack/serveruserpass',
get_string('settingserveruserpass', 'qtype_stack'),
......@@ -102,7 +105,7 @@ $settings->add(new admin_setting_configtext('qtype_stack/plotcommand',
$settings->add(new admin_setting_configtext('qtype_stack/maximalibraries',
get_string('settingmaximalibraries', 'qtype_stack'),
get_string('settingmaximalibraries_desc', 'qtype_stack'), 'stats, distrib, descriptive, simplex'));
get_string('settingmaximalibraries_desc', 'qtype_stack'), null));
$settings->add(new admin_setting_configcheckbox('qtype_stack/casdebugging',
get_string('settingcasdebugging', 'qtype_stack'),
......
......@@ -391,14 +391,15 @@ END;
$config = get_config('qtype_stack');
// Do not try to generate the optimised image on MS platforms.
if ($config->platform == 'win') {
$errmsg = "Microsoft Windows version cannot be optimised";
$errmsg = "Microsoft Windows version cannot be automatically optimised";
return array(false, $errmsg);
} else if ($config->platform != 'unix' && $config->platform != 'unix-optimised') {
$errmsg = "$config->platform version cannot be automatically optimised";
return array(false, $errmsg);
}
/*
* Revert to the plain unix platform. This will genuinely call the CAS, and
* as a result create a new image.
*/
// Revert to the plain unix platform. This will genuinely call the CAS, and
// as a result create a new image.
$oldplatform = $config->platform;
$oldmaximacommand = $config->maximacommand;
set_config('platform', 'unix', 'qtype_stack');
......@@ -421,13 +422,19 @@ END;
list($message, $genuinedebug, $result) = stack_connection_helper::stackmaxima_genuine_connect();
}
$revert = false;
if ($result && ($oldplatform == 'unix' || $oldplatform == 'unix-optimised')) {
$revert = true;
if (!$result) {
$errmsg = "Uncached connection failed: $message\n\n$genuinedebug";
} else {
// Try to auto make the optimised image.
list($message, $genuinedebug, $result, $commandline)
= stack_connection_helper::stackmaxima_auto_maxima_optimise($genuinedebug, true);
= stack_connection_helper::stackmaxima_auto_maxima_optimise($genuinedebug);
if (!$result) {
$errmsg = "Automake failed: $message\n\n$genuinedebug";
if ($result) {
} else {
set_config('platform', 'unix-optimised', 'qtype_stack');
set_config('maximacommand', $commandline, 'qtype_stack');
stack_utils::get_config()->platform = 'unix-optimised';
......@@ -444,15 +451,12 @@ END;
if ($ts->get_value_key('a') != '2') {
$errors = $ts->get_errors();
$errmsg = "Evaluation test failed, errors: $errors";
$revert = true;
}
} else {
$errmsg = "Automake failed";
$revert = true;
// It worked!
$errmsg = '';
$revert = false;
}
}
} else {
$errmsg = "Uncached connection failed.";
$revert = true;
}
if ($revert) {
......
......@@ -34,7 +34,11 @@ require_once(__DIR__ . '/../../stack/cas/installhelper.class.php');
*/
abstract class qtype_stack_test_config {
public static function is_test_config_available() {
return defined('QTYPE_STACK_TEST_CONFIG_PLATFORM');
// Either the platform is already non-default (e.g.
// because auto-optimse worked during install, or
// settings given in config.php.
return get_config('qtype_stack', 'platform') !== 'unix' ||
defined('QTYPE_STACK_TEST_CONFIG_PLATFORM');
}
/**
......@@ -57,6 +61,11 @@ abstract class qtype_stack_test_config {
define('QTYPE_STACK_EXPECTED_VERSION', $matches[1]);
}
if (!defined('QTYPE_STACK_TEST_CONFIG_PLATFORM')) {
// Things were set up by install.php. Nothing to do here.
return;
}
set_config('platform', QTYPE_STACK_TEST_CONFIG_PLATFORM, 'qtype_stack');
set_config('maximaversion', QTYPE_STACK_TEST_CONFIG_MAXIMAVERSION, 'qtype_stack');
set_config('castimeout', QTYPE_STACK_TEST_CONFIG_CASTIMEOUT, 'qtype_stack');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment