Automatically generated installer lang files
[moodle.git] / .travis.yml
bloba5ad5a15ee186b713a8c07a0fd1a73fee32c515d
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 matrix:
42     # Enable fast finish.
43     # This will fail the build if a single job fails (except those in allow_failures).
44     # It will not stop the jobs from running.
45     fast_finish: true
47     include:
48           # Run grunt/npm install on highest version ('node' is an alias for the latest node.js version.)
49         - php: 7
50           env: DB=none     TASK=GRUNT   NVM_VERSION='lts/carbon'
52     exclude:
53         # MySQL - it's just too slow.
54         # Exclude it on all versions except for 7.0
55         # - env: DB=mysqli   TASK=PHPUNIT
56         #   php: 5.6
57         #
58         # - env: DB=mysqli   TASK=PHPUNIT
59         #   php: 5.5
61         - env: DB=mysqli   TASK=PHPUNIT
62           php: 5.4
64         - env: DB=none     TASK=GRUNT
65           php: 5.4
67         # Moodle 2.7 is not compatible with PHP 7 for the upgrade test.
68         - env: DB=pgsql    TASK=UPGRADE
69           php: 7.0
71 cache:
72     directories:
73       - $HOME/.composer/cache
74       - $HOME/.npm
76 install:
77     - >
78         if [ "$TASK" = 'PHPUNIT' ];
79         then
80             if [ -n "$GITHUB_APITOKEN" ]; then
81                 composer config github-oauth.github.com $GITHUB_APITOKEN;
82                 echo 'auth.json' >> .git/info/exclude
83             fi
85             # Install composer dependencies.
86             # We need --no-interaction in case we hit API limits for composer. This causes it to fall back to a standard clone.
87             # Typically it should be able to use the Composer cache if any other job has already completed before we started here.
88             travis_retry composer install --prefer-dist --no-interaction;
89         fi
91     - >
92         if [ "$TASK" = 'GRUNT' ];
93         then
94             nvm install $NVM_VERSION ;
95             nvm use $NVM_VERSION ;
96         fi
98 before_script:
99     - phpenv config-rm xdebug.ini
100     - >
101       if [ "$TASK" = 'PHPUNIT' -o "$TASK" = 'UPGRADE' ];
102       then
103         # Copy generic configuration in place.
104         cp config-dist.php config.php ;
106         # Create the moodledata directory.
107         mkdir -p "$HOME"/roots/base
109         # The database name and password.
110         sed -i \
111           -e "s%= 'moodle'%= 'travis_ci_test'%" \
112           -e "s%= 'password'%= ''%" \
113           config.php ;
115         # The wwwroot and dataroot.
116         sed -i \
117           -e "s%http://example.com/moodle%http://localhost%" \
118           -e "s%/home/example/moodledata%/home/travis/roots/base%" \
119           config.php ;
121         if [ "$DB" = 'pgsql' ];
122         then
123           # Postgres-specific setup.
124           sed -i \
125             -e "s%= 'username'%= 'postgres'%" \
126             config.php ;
128           psql -c 'CREATE DATABASE travis_ci_test;' -U postgres;
129         fi
131         if [ "$DB" = 'mysqli' ];
132         then
133           # MySQL-specific setup.
134           sed -i \
135             -e "s%= 'pgsql'%= 'mysqli'%" \
136             -e "s%= 'username'%= 'travis'%" \
137             -e "s%=> 'utf8mb4_unicode_ci'%=> 'utf8mb4_bin'%" \
138             config.php;
140           mysql -u root -e 'SET GLOBAL innodb_file_format=barracuda;' ;
141           mysql -u root -e 'SET GLOBAL innodb_file_per_table=ON;' ;
142           mysql -u root -e 'SET GLOBAL innodb_large_prefix=ON;' ;
143           mysql -e 'CREATE DATABASE travis_ci_test DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_bin;' ;
144         fi
145       fi
147     - >
148       if [ "$TASK" = 'PHPUNIT' ];
149       then
150         # Create a directory for the phpunit dataroot.
151         mkdir -p "$HOME"/roots/phpunit
153         # The phpunit dataroot and prefix..
154         sed -i \
155           -e "/require_once/i \\\$CFG->phpunit_dataroot = '\/home\/travis\/roots\/phpunit';" \
156           -e "/require_once/i \\\$CFG->phpunit_prefix = 'p_';" \
157           config.php ;
159         # Initialise PHPUnit for Moodle.
160         php admin/tool/phpunit/cli/init.php
161       fi
163     - >
164       if [ "$TASK" = 'GRUNT' ];
165       then
166         npm install --no-spin;
167         npm install --no-spin -g grunt ;
168       fi
170     ########################################################################
171     # CI Tests
172     ########################################################################
173     - >
174       if [ "$TASK" = 'CITEST' ];
175       then
176         # Note - this is deliberately placed in the script section as we
177         # should not add any code until after phpunit has run.
179         # The following repositories are required.
180         # The local_ci repository does the actual checking.
181         git clone https://github.com/moodlehq/moodle-local_ci.git local/ci
183         # We need the official upstream for comparison
184         git remote add upstream https://github.com/moodle/moodle.git;
186         git fetch upstream MOODLE_31_STABLE;
187         export GIT_PREVIOUS_COMMIT="`git merge-base FETCH_HEAD $TRAVIS_COMMIT`";
188         export GIT_COMMIT="$TRAVIS_COMMIT";
189         export UPSTREAM_FETCH_HEAD=`git rev-parse FETCH_HEAD`
191         # Variables required by our linter.
192         export gitcmd=`which git`;
193         export gitdir="$TRAVIS_BUILD_DIR";
194         export phpcmd=`which php`;
195       fi
197     ########################################################################
198     # Upgrade test
199     ########################################################################
200     - >
201       if [ "$TASK" = 'UPGRADE' ];
202       then
203         # We need the official upstream.
204         git remote add upstream https://github.com/moodle/moodle.git;
206         # Checkout 27 STABLE branch.
207         git fetch upstream MOODLE_27_STABLE;
208         git checkout MOODLE_27_STABLE;
210         # Perform the upgrade
211         php admin/cli/install_database.php --agree-license --adminpass=Password --adminemail=admin@example.com --fullname="Upgrade test" --shortname=Upgrade;
213         # Return to the previous commit
214         git checkout -;
216         # Perform the upgrade
217         php admin/cli/upgrade.php --non-interactive --allow-unstable ;
219         # The local_ci repository can be used to check upgrade savepoints.
220         git clone https://github.com/moodlehq/moodle-local_ci.git local/ci ;
221       fi
223 script:
224     - >
225       if [ "$TASK" = 'PHPUNIT' ];
226       then
227         vendor/bin/phpunit;
228       fi
230     - >
231       if [ "$TASK" = 'CITEST' ];
232       then
233         bash local/ci/php_lint/php_lint.sh;
234       fi
236     - >
237       if [ "$TASK" = 'GRUNT' ];
238       then
239         grunt ;
240         # Add all files to the git index and then run diff --cached to see all changes.
241         # This ensures that we get the status of all files, including new files.
242         git add . ;
243         git diff --cached --exit-code ;
244       fi
246     ########################################################################
247     # Upgrade test
248     ########################################################################
249     - >
250       if [ "$TASK" = 'UPGRADE' ];
251       then
252         cp local/ci/check_upgrade_savepoints/check_upgrade_savepoints.php ./check_upgrade_savepoints.php
253         result=`php check_upgrade_savepoints.php`;
254         # Check if there are problems
255         count=`echo "$result" | grep -P "ERROR|WARN" | wc -l` ;
256         if (($count > 0));
257         then
258           echo "$result"
259           exit 1 ;
260         fi
261       fi