MDL-55002 lang: Merge English strings from the en_fix language pack
[moodle.git] / .travis.yml
blobd1438f3db7c6bc7af595cb96a231cbfb4f62aa65
1 # PLEASE NOTE: Travis is not currently utilised by the Moodle core integration
2 # process (which uses our internal CI system) this file is here for the benefit
3 # of community developers git clones - see MDL-51458.
5 sudo: false
7 # We currently disable Travis notifications entirely until https://github.com/travis-ci/travis-ci/issues/4976
8 # is fixed.
9 notifications:
10   email: false
12 language: php
14 php:
15     # We only run the highest and lowest supported versions to reduce the load on travis-ci.org.
16     - 7.0
17     # - 5.6
18     # - 5.5
19     - 5.4
21 env:
22     # Although we want to run these jobs and see failures as quickly as possible, we also want to get the slowest job to
23     # start first so that the total run time is not too high.
24     #
25     # We only run MySQL on PHP 5.6, so run that first.
26     # CI Tests should be second-highest in priority as these only take <= 60 seconds to run under normal circumstances.
27     # Postgres is significantly is pretty reasonable in its run-time.
29     # Run unit tests on MySQL
30     - DB=mysqli   TASK=PHPUNIT
32     # Run CI Tests without running PHPUnit.
33     - DB=none     TASK=CITEST
35     # Run unit tests on Postgres
36     - DB=pgsql    TASK=PHPUNIT
38     # Perform an upgrade test too.
39     - DB=pgsql    TASK=UPGRADE
41     # Run a check for unbuilt files with Grunt.
42     - DB=none     TASK=GRUNT
44 matrix:
45     # Enable fast finish.
46     # This will fail the build if a single job fails (except those in allow_failures).
47     # It will not stop the jobs from running.
48     fast_finish: true
50     exclude:
51         # MySQL - it's just too slow.
52         # Exclude it on all versions except for 7.0
53         # - env: DB=mysqli   TASK=PHPUNIT
54         #   php: 5.6
55         #
56         # - env: DB=mysqli   TASK=PHPUNIT
57         #   php: 5.5
59         - env: DB=mysqli   TASK=PHPUNIT
60           php: 5.4
62         - env: DB=none     TASK=GRUNT
63           php: 5.4
65         # Moodle 2.7 is not compatible with PHP 7 for the upgrade test.
66         - env: DB=pgsql    TASK=UPGRADE
67           php: 7.0
69 cache:
70     directories:
71       - $HOME/.composer/cache
72       - $HOME/.npm
74 install:
75     # Disable xdebug. We aren't generating code coverage, and it has a huge impact upon test performance.
76     - rm /home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
78     # Set the encrypted GITHUB_TOKEN if it's available to raise the API limit.
79     - if [ -n "$GITHUB_APITOKEN" ]; then composer config github-oauth.github.com $GITHUB_APITOKEN; fi
80     - echo 'auth.json' >> .git/info/exclude
82     # Install composer dependencies.
83     # We need --no-interaction in case we hit API limits for composer. This causes it to fall back to a standard clone.
84     # Typically it should be able to use the Composer cache if any other job has already completed before we started here.
85     - travis_retry composer install --prefer-dist --no-interaction
87 before_script:
88     - >
89       if [ "$TASK" = 'PHPUNIT' -o "$TASK" = 'UPGRADE' ];
90       then
91         # Copy generic configuration in place.
92         cp config-dist.php config.php ;
94         # Create the moodledata directory.
95         mkdir -p "$HOME"/roots/base
97         # The database name and password.
98         sed -i \
99           -e "s%= 'moodle'%= 'travis_ci_test'%" \
100           -e "s%= 'password'%= ''%" \
101           config.php ;
103         # The wwwroot and dataroot.
104         sed -i \
105           -e "s%http://example.com/moodle%http://localhost%" \
106           -e "s%/home/example/moodledata%/home/travis/roots/base%" \
107           config.php ;
109         if [ "$DB" = 'pgsql' ];
110         then
111           # Postgres-specific setup.
112           sed -i \
113             -e "s%= 'username'%= 'postgres'%" \
114             config.php ;
116           psql -c 'CREATE DATABASE travis_ci_test;' -U postgres;
117         fi
119         if [ "$DB" = 'mysqli' ];
120         then
121           # MySQL-specific setup.
122           sed -i \
123             -e "s%= 'pgsql'%= 'mysqli'%" \
124             -e "s%= 'username'%= 'travis'%" \
125             config.php;
127           mysql -u root -e 'SET GLOBAL innodb_file_format=barracuda;' ;
128           mysql -u root -e 'SET GLOBAL innodb_file_per_table=ON;' ;
129           mysql -e 'CREATE DATABASE travis_ci_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;' ;
130         fi
131       fi
133     - >
134       if [ "$TASK" = 'PHPUNIT' ];
135       then
136         # Create a directory for the phpunit dataroot.
137         mkdir -p "$HOME"/roots/phpunit
139         # The phpunit dataroot and prefix..
140         sed -i \
141           -e "/require_once/i \\\$CFG->phpunit_dataroot = '\/home\/travis\/roots\/phpunit';" \
142           -e "/require_once/i \\\$CFG->phpunit_prefix = 'p_';" \
143           config.php ;
145         # Initialise PHPUnit for Moodle.
146         php admin/tool/phpunit/cli/init.php
147       fi
149     - >
150       if [ "$TASK" = 'GRUNT' ];
151       then
152         npm install ;
153         npm install -g grunt ;
154         grunt ;
155       fi
157     ########################################################################
158     # CI Tests
159     ########################################################################
160     - >
161       if [ "$TASK" = 'CITEST' ];
162       then
163         # Note - this is deliberately placed in the script section as we
164         # should not add any code until after phpunit has run.
166         # The following repositories are required.
167         # The local_ci repository does the actual checking.
168         git clone https://github.com/moodlehq/moodle-local_ci.git local/ci
170         # We need the official upstream for comparison
171         git remote add upstream https://github.com/moodle/moodle.git;
173         git fetch upstream master;
174         export GIT_PREVIOUS_COMMIT="`git merge-base FETCH_HEAD $TRAVIS_COMMIT`";
175         export GIT_COMMIT="$TRAVIS_COMMIT";
176         export UPSTREAM_FETCH_HEAD=`git rev-parse FETCH_HEAD`
178         # Variables required by our linter.
179         export gitcmd=`which git`;
180         export gitdir="$TRAVIS_BUILD_DIR";
181         export phpcmd=`which php`;
182       fi
184     ########################################################################
185     # Upgrade test
186     ########################################################################
187     - >
188       if [ "$TASK" = 'UPGRADE' ];
189       then
190         # We need the official upstream.
191         git remote add upstream https://github.com/moodle/moodle.git;
193         # Checkout 27 STABLE branch.
194         git fetch upstream MOODLE_27_STABLE;
195         git checkout MOODLE_27_STABLE;
197         # Perform the upgrade
198         php admin/cli/install_database.php --agree-license --adminpass=Password --adminemail=admin@example.com --fullname="Upgrade test" --shortname=Upgrade;
200         # Return to the previous commit
201         git checkout -;
203         # Perform the upgrade
204         php admin/cli/upgrade.php --non-interactive --allow-unstable ;
206         # The local_ci repository can be used to check upgrade savepoints.
207         git clone https://github.com/moodlehq/moodle-local_ci.git local/ci ;
208       fi
210 script:
211     - >
212       if [ "$TASK" = 'PHPUNIT' ];
213       then
214         vendor/bin/phpunit;
215       fi
217     - >
218       if [ "$TASK" = 'CITEST' ];
219       then
220         bash local/ci/php_lint/php_lint.sh;
221       fi
223     - >
224       if [ "$TASK" = 'GRUNT' ];
225       then
226         # Add all files to the git index and then run diff --cached to see all changes.
227         # This ensures that we get the status of all files, including new files.
228         git add . ;
229         git diff --cached --exit-code ;
230       fi
232     ########################################################################
233     # Upgrade test
234     ########################################################################
235     - >
236       if [ "$TASK" = 'UPGRADE' ];
237       then
238         cp local/ci/check_upgrade_savepoints/check_upgrade_savepoints.php ./check_upgrade_savepoints.php
239         result=`php check_upgrade_savepoints.php`;
240         # Check if there are problems
241         count=`echo "$result" | grep -P "ERROR|WARN" | wc -l` ;
242         if (($count > 0));
243         then
244           echo "$result"
245           exit 1 ;
246         fi
247       fi