From a24aff4edf8424466c9619538e569c6a288f5a5e Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 5 May 2016 14:29:52 +0800 Subject: [PATCH 1/2] MDL-54059 testing: Simplify travis output --- .travis.yml | 83 ++++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/.travis.yml b/.travis.yml index 47f3462fe02..052e397e1af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,16 +27,16 @@ env: # Postgres is significantly is pretty reasonable in its run-time. # Run unit tests on MySQL - - DB=mysqli PHPUNIT=true INSTALL=false CITEST=false + - DB=mysqli TASK=PHPUNIT # Run CI Tests without running PHPUnit. - - DB=none PHPUNIT=false INSTALL=false CITEST=true + - DB=none TASK=CITEST # Run unit tests on Postgres - - DB=pgsql PHPUNIT=true INSTALL=false CITEST=false + - DB=pgsql TASK=PHPUNIT # Perform an upgrade test too. - - DB=pgsql PHPUNIT=false INSTALL=true CITEST=false UPGRADE=true + - DB=pgsql TASK=UPGRADE matrix: # Enable fast finish. @@ -47,17 +47,17 @@ matrix: exclude: # MySQL - it's just too slow. # Exclude it on all versions except for 7.0 - # - env: DB=mysqli PHPUNIT=true INSTALL=false CITEST=false + # - env: DB=mysqli TASK=PHPUNIT # php: 5.6 # - # - env: DB=mysqli PHPUNIT=true INSTALL=false CITEST=false + # - env: DB=mysqli TASK=PHPUNIT # php: 5.5 - - env: DB=mysqli PHPUNIT=true INSTALL=false CITEST=false + - env: DB=mysqli TASK=PHPUNIT php: 5.4 # Moodle 2.7 is not compatible with PHP 7 for the upgrade test. - - env: DB=pgsql PHPUNIT=false INSTALL=true CITEST=false UPGRADE=true + - env: DB=pgsql TASK=UPGRADE php: 7.0 cache: @@ -70,6 +70,7 @@ 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 + - echo 'auth.json' >> .git/info/exclude # 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. @@ -78,7 +79,7 @@ install: before_script: - > - if [ "$INSTALL" = 'true' -o "$PHPUNIT" = 'true' ]; + if [ "$TASK" = 'PHPUNIT' -o "$TASK" = 'UPGRADE' ]; then # Copy generic configuration in place. cp config-dist.php config.php ; @@ -120,38 +121,29 @@ before_script: 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_';" \ - config.php ; - - # Initialise PHPUnit for Moodle. - php admin/tool/phpunit/cli/init.php - fi fi -script: - ######################################################################## - # PHPUnit - ######################################################################## - > - if [ "$PHPUNIT" = 'true' ]; + if [ "$TASK" = 'PHPUNIT' ]; then - vendor/bin/phpunit; + # 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_';" \ + config.php ; + + # Initialise PHPUnit for Moodle. + php admin/tool/phpunit/cli/init.php fi ######################################################################## # CI Tests ######################################################################## - > - if [ "$CITEST" = 'true' ]; + if [ "$TASK" = 'CITEST' ]; then # Note - this is deliberately placed in the script section as we # should not add any code until after phpunit has run. @@ -174,18 +166,11 @@ script: 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 - ######################################################################## # Upgrade test ######################################################################## - > - if [ "$UPGRADE" = 'true' ]; + if [ "$TASK" = 'UPGRADE' ]; then # We need the official upstream. git remote add upstream https://github.com/moodle/moodle.git; @@ -205,7 +190,27 @@ script: # The local_ci repository can be used to check upgrade savepoints. git clone https://github.com/moodlehq/moodle-local_ci.git local/ci ; + fi +script: + - > + if [ "$TASK" = 'PHPUNIT' ]; + then + vendor/bin/phpunit; + fi + + - > + if [ "$TASK" = 'CITEST' ]; + then + bash local/ci/php_lint/php_lint.sh; + fi + + ######################################################################## + # Upgrade test + ######################################################################## + - > + if [ "$TASK" = 'UPGRADE' ]; + then cp local/ci/check_upgrade_savepoints/check_upgrade_savepoints.php ./check_upgrade_savepoints.php result=`php check_upgrade_savepoints.php`; # Check if there are problems From c366cb08cf39a223750f81359c8c201422415087 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 5 May 2016 14:31:59 +0800 Subject: [PATCH 2/2] MDL-54059 testing: Add grunt test --- .travis.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.travis.yml b/.travis.yml index 052e397e1af..d1438f3db7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,9 @@ env: # Perform an upgrade test too. - DB=pgsql TASK=UPGRADE + # Run a check for unbuilt files with Grunt. + - DB=none TASK=GRUNT + matrix: # Enable fast finish. # This will fail the build if a single job fails (except those in allow_failures). @@ -56,6 +59,9 @@ matrix: - env: DB=mysqli TASK=PHPUNIT php: 5.4 + - env: DB=none TASK=GRUNT + php: 5.4 + # Moodle 2.7 is not compatible with PHP 7 for the upgrade test. - env: DB=pgsql TASK=UPGRADE php: 7.0 @@ -63,6 +69,7 @@ matrix: cache: directories: - $HOME/.composer/cache + - $HOME/.npm install: # Disable xdebug. We aren't generating code coverage, and it has a huge impact upon test performance. @@ -139,6 +146,14 @@ before_script: php admin/tool/phpunit/cli/init.php fi + - > + if [ "$TASK" = 'GRUNT' ]; + then + npm install ; + npm install -g grunt ; + grunt ; + fi + ######################################################################## # CI Tests ######################################################################## @@ -205,6 +220,15 @@ script: bash local/ci/php_lint/php_lint.sh; fi + - > + if [ "$TASK" = 'GRUNT' ]; + then + # Add all files to the git index and then run diff --cached to see all changes. + # This ensures that we get the status of all files, including new files. + git add . ; + git diff --cached --exit-code ; + fi + ######################################################################## # Upgrade test ########################################################################