mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 14:03:52 +01:00
09ca2e85c6
To prevent false positives
200 lines
6.9 KiB
YAML
200 lines
6.9 KiB
YAML
# PLEASE NOTE: Travis is not currently utilised by the Moodle core integration
|
|
# process (which uses our internal CI system) this file is here for the benefit
|
|
# of community developers git clones - see MDL-51458.
|
|
|
|
sudo: false
|
|
|
|
# We currently disable Travis notifications entirely until https://github.com/travis-ci/travis-ci/issues/4976
|
|
# is fixed.
|
|
notifications:
|
|
email: false
|
|
|
|
language: php
|
|
|
|
php:
|
|
# Moodle supports versions 5.4, 5.5, and 5.6 of PHP.
|
|
# Order by fastest to slowest.
|
|
# We currently only run the highest and lowest versions to reduce the load on travis-ci.org.
|
|
- 5.6
|
|
# - 5.5
|
|
- 5.4
|
|
|
|
# We hope to offer PHP 7 support in the near future.
|
|
- nightly
|
|
|
|
services:
|
|
# Ensure that memcached and mongodb are running for testing of those MUC stores.
|
|
- memcached
|
|
- mongodb
|
|
|
|
env:
|
|
# Although we want to run these jobs and see failures as quickly as possible, we also want to get the slowest job to
|
|
# start first so that the total run time is not too high.
|
|
#
|
|
# We only run MySQL on PHP 5.6, so run that first.
|
|
# CI Tests should be second-highest in priority as these only take <= 60 seconds to run under normal circumstances.
|
|
# Postgres is significantly is pretty reasonable in its run-time.
|
|
|
|
# Run unit tests on MySQL
|
|
- DB=mysqli PHPUNIT=true INSTALL=false CITEST=false
|
|
|
|
# Run CI Tests without running PHPUnit.
|
|
- DB=none PHPUNIT=false INSTALL=false CITEST=true
|
|
|
|
# Run unit tests on Postgres
|
|
- DB=pgsql PHPUNIT=true INSTALL=false CITEST=false
|
|
|
|
matrix:
|
|
# Enable fast finish.
|
|
# This will fail the build if a single job fails (except those in allow_failures).
|
|
# It will not stop the jobs from running.
|
|
fast_finish: true
|
|
|
|
# Always allow failure on nightly.
|
|
# It's a nightly build and failures can happen.
|
|
allow_failures:
|
|
- php: nightly
|
|
|
|
exclude:
|
|
# PHP 7 is not yet supported for actual runs.
|
|
# Exclude it by default - we include it for CITEST only later.
|
|
- php: nightly
|
|
|
|
# MySQL - it's just too slow.
|
|
# Exclude it on all versions except for 5.6.
|
|
# - env: DB=mysqli PHPUNIT=true INSTALL=false CITEST=false
|
|
# php: 5.5
|
|
|
|
- env: DB=mysqli PHPUNIT=true INSTALL=false CITEST=false
|
|
php: 5.4
|
|
|
|
include:
|
|
# Attempt to run the CITEST set on PHP 7.
|
|
- php: nightly
|
|
env: DB=none PHPUNIT=false INSTALL=false CITEST=true
|
|
|
|
cache:
|
|
directories:
|
|
- $HOME/.composer/cache
|
|
|
|
install:
|
|
# Set the encrypted GITHUB_TOKEN if it's available to raise the API limit.
|
|
- if [ -n "$GITHUB_APITOKEN" ]; then composer config github-oauth.github.com $GITHUB_APITOKEN; fi
|
|
|
|
# Install composer dependencies.
|
|
# We need --no-interaction in case we hit API limits for composer. This causes it to fall back to a standard clone.
|
|
# Typically it should be able to use the Composer cache if any other job has already completed before we started here.
|
|
- travis_retry composer install --prefer-dist --no-interaction
|
|
|
|
- echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
|
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
|
- echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
|
|
|
before_script:
|
|
- >
|
|
if [ "$INSTALL" = 'true' -o "$PHPUNIT" = 'true' ];
|
|
then
|
|
# Copy generic configuration in place.
|
|
cp config-dist.php config.php ;
|
|
|
|
# Create the moodledata directory.
|
|
mkdir -p "$HOME"/roots/base
|
|
|
|
# The database name and password.
|
|
sed -i \
|
|
-e "s%= 'moodle'%= 'travis_ci_test'%" \
|
|
-e "s%= 'password'%= ''%" \
|
|
config.php ;
|
|
|
|
# The wwwroot and dataroot.
|
|
sed -i \
|
|
-e "s%http://example.com/moodle%http://localhost%" \
|
|
-e "s%/home/example/moodledata%/home/travis/roots/base%" \
|
|
config.php ;
|
|
|
|
if [ "$DB" = 'pgsql' ];
|
|
then
|
|
# Postgres-specific setup.
|
|
sed -i \
|
|
-e "s%= 'username'%= 'postgres'%" \
|
|
config.php ;
|
|
|
|
psql -c 'CREATE DATABASE travis_ci_test;' -U postgres;
|
|
fi
|
|
|
|
if [ "$DB" = 'mysqli' ];
|
|
then
|
|
# MySQL-specific setup.
|
|
sed -i \
|
|
-e "s%= 'pgsql'%= 'mysqli'%" \
|
|
-e "s%= 'username'%= 'travis'%" \
|
|
config.php;
|
|
|
|
mysql -u root -e 'SET GLOBAL innodb_file_format=barracuda;' ;
|
|
mysql -u root -e 'SET GLOBAL innodb_file_per_table=ON;' ;
|
|
mysql -e 'CREATE DATABASE travis_ci_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;' ;
|
|
fi
|
|
|
|
if [ "$PHPUNIT" = 'true' ];
|
|
then
|
|
# Create a directory for the phpunit dataroot.
|
|
mkdir -p "$HOME"/roots/phpunit
|
|
|
|
# The phpunit dataroot and prefix..
|
|
sed -i \
|
|
-e "/require_once/i \\\$CFG->phpunit_dataroot = '\/home\/travis\/roots\/phpunit';" \
|
|
-e "/require_once/i \\\$CFG->phpunit_prefix = 'p_';" \
|
|
-e "/require_once/i define('TEST_CACHESTORE_MEMCACHE_TESTSERVERS', '127.0.0.1:11211');" \
|
|
-e "/require_once/i define('TEST_CACHESTORE_MEMCACHED_TESTSERVERS', '127.0.0.1:11211');" \
|
|
-e "/require_once/i define('TEST_CACHESTORE_MONGODB_TESTSERVER', 'mongodb://localhost:27017');" \
|
|
config.php ;
|
|
|
|
# Initialise PHPUnit for Moodle.
|
|
php admin/tool/phpunit/cli/init.php
|
|
fi
|
|
fi
|
|
|
|
script:
|
|
########################################################################
|
|
# PHPUnit
|
|
########################################################################
|
|
- >
|
|
if [ "$PHPUNIT" = 'true' ];
|
|
then
|
|
vendor/bin/phpunit;
|
|
fi
|
|
|
|
########################################################################
|
|
# CI Tests
|
|
########################################################################
|
|
- >
|
|
if [ "$CITEST" = 'true' ];
|
|
then
|
|
# Note - this is deliberately placed in the script section as we
|
|
# should not add any code until after phpunit has run.
|
|
|
|
# The following repositories are required.
|
|
# The local_ci repository does the actual checking.
|
|
git clone https://github.com/moodlehq/moodle-local_ci.git local/ci
|
|
|
|
# We need the official upstream for comparison
|
|
git remote add upstream https://github.com/moodle/moodle.git;
|
|
|
|
git fetch upstream master;
|
|
export GIT_PREVIOUS_COMMIT="`git merge-base FETCH_HEAD $TRAVIS_COMMIT`";
|
|
export GIT_COMMIT="$TRAVIS_COMMIT";
|
|
export UPSTREAM_FETCH_HEAD=`git rev-parse FETCH_HEAD`
|
|
|
|
# Variables required by our linter.
|
|
export gitcmd=`which git`;
|
|
export gitdir="$TRAVIS_BUILD_DIR";
|
|
export phpcmd=`which php`;
|
|
fi
|
|
|
|
# Actually run the CI Tests - do this outside of the main test to make output clearer.
|
|
- >
|
|
if [ "$CITEST" = 'true' ];
|
|
then
|
|
bash local/ci/php_lint/php_lint.sh;
|
|
fi
|