MDL-66723 theme_classic: Remove regionmainsettings variables
[moodle.git] / .travis.yml
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.
4
5 sudo: required
6
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
11
12 language: php
13
14 dist: xenial
15
16 services:
17 - mysql
18
19 php:
20 # We only run the highest and lowest supported versions to reduce the load on travis-ci.org.
21 - 7.3
22 - 7.1.30 # Make this sticky because current default version (7.1.11) has a bug with redis-extension output (MDL-66062)
23
24 addons:
25 postgresql: "9.6"
26
27 env:
28 # Although we want to run these jobs and see failures as quickly as possible, we also want to get the slowest job to
29 # start first so that the total run time is not too high.
30 #
31 # We only run MySQL on PHP 7.2, so run that first.
32 # CI Tests should be second-highest in priority as these only take <= 60 seconds to run under normal circumstances.
33 # Postgres is significantly is pretty reasonable in its run-time.
34
35 # Run CI Tests without running PHPUnit.
36 - DB=none TASK=CITEST
37
38 # Run unit tests on Postgres
39 - DB=pgsql TASK=PHPUNIT
40
41 # Perform an upgrade test too.
42 - DB=pgsql TASK=UPGRADE
43
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
49
50 include:
51 # Run mysql only on 7.3 - it's just too slow
52 - php: 7.3
53 env: DB=mysqli TASK=PHPUNIT
54 # Run grunt/npm install on highest version ('node' is an alias for the latest node.js version.)
55 - php: 7.2
56 env: DB=none TASK=GRUNT NVM_VERSION='lts/carbon'
57
58 cache:
59 directories:
60 - $HOME/.composer/cache
61 - $HOME/.npm
62
63 before_install:
64 # Avoid IPv6 default binding as service (causes redis not to start).
65 sudo service redis-server start --bind 127.0.0.1
66
67 install:
68 - >
69 if [ "$DB" = 'mysqli' ];
70 then
71 sudo mkdir /mnt/ramdisk
72 sudo mount -t tmpfs -o size=1024m tmpfs /mnt/ramdisk
73 sudo service mysql stop
74 sudo mv /var/lib/mysql /mnt/ramdisk
75 sudo ln -s /mnt/ramdisk/mysql /var/lib/mysql
76 sudo service mysql restart
77 fi
78 - >
79 if [ "$DB" = 'pgsql' ];
80 then
81 sudo mkdir /mnt/ramdisk
82 sudo mount -t tmpfs -o size=1024m tmpfs /mnt/ramdisk
83 sudo service postgresql stop
84 sudo mv /var/lib/postgresql /mnt/ramdisk
85 sudo ln -s /mnt/ramdisk/postgresql /var/lib/postgresql
86 sudo service postgresql start 9.6
87 fi
88 - >
89 if [ "$TASK" = 'PHPUNIT' ];
90 then
91 if [ -n "$GITHUB_APITOKEN" ]; then
92 composer config github-oauth.github.com $GITHUB_APITOKEN;
93 echo 'auth.json' >> .git/info/exclude
94 fi
95
96 echo 'extension="redis.so"' > /tmp/redis.ini
97 phpenv config-add /tmp/redis.ini
98
99 # Install composer dependencies.
100 # We need --no-interaction in case we hit API limits for composer. This causes it to fall back to a standard clone.
101 # Typically it should be able to use the Composer cache if any other job has already completed before we started here.
102 travis_retry composer install --prefer-dist --no-interaction;
103 fi
104
105 - >
106 if [ "$TASK" = 'GRUNT' ];
107 then
108 nvm install $NVM_VERSION ;
109 nvm use $NVM_VERSION ;
110 fi
111
112 before_script:
113 - phpenv config-rm xdebug.ini
114 - >
115 if [ "$TASK" = 'PHPUNIT' -o "$TASK" = 'UPGRADE' ];
116 then
117 # Copy generic configuration in place.
118 cp config-dist.php config.php ;
119
120 # Create the moodledata directory.
121 mkdir -p "$HOME"/roots/base
122
123 # The database name and password.
124 sed -i \
125 -e "s%= 'moodle'%= 'travis_ci_test'%" \
126 -e "s%= 'password'%= ''%" \
127 config.php ;
128
129 # The wwwroot and dataroot.
130 sed -i \
131 -e "s%http://example.com/moodle%https://localhost%" \
132 -e "s%/home/example/moodledata%/home/travis/roots/base%" \
133 config.php ;
134
135 if [ "$DB" = 'pgsql' ];
136 then
137 # Postgres-specific setup.
138 sed -i \
139 -e "s%= 'username'%= 'postgres'%" \
140 config.php ;
141
142 psql -c 'CREATE DATABASE travis_ci_test;' -U postgres;
143 fi
144
145 if [ "$DB" = 'mysqli' ];
146 then
147 # MySQL-specific setup.
148 sed -i \
149 -e "s%= 'pgsql'%= 'mysqli'%" \
150 -e "s%= 'username'%= 'travis'%" \
151 -e "s%=> 'utf8mb4_unicode_ci'%=> 'utf8mb4_bin'%" \
152 config.php;
153
154 mysql -u root -e 'SET GLOBAL innodb_file_format=barracuda;' ;
155 mysql -u root -e 'SET GLOBAL innodb_file_per_table=ON;' ;
156 mysql -u root -e 'SET GLOBAL innodb_large_prefix=ON;' ;
157 mysql -e 'CREATE DATABASE travis_ci_test DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_bin;' ;
158 fi
159 fi
160
161 - >
162 if [ "$TASK" = 'PHPUNIT' ];
163 then
164 # Create a directory for the phpunit dataroot.
165 mkdir -p "$HOME"/roots/phpunit
166
167 # The phpunit dataroot and prefix..
168 sed -i \
169 -e "/require_once/i \\\$CFG->phpunit_dataroot = '\/home\/travis\/roots\/phpunit';" \
170 -e "/require_once/i \\\$CFG->phpunit_prefix = 'p_';" \
171 config.php ;
172 # Redis cache store tests
173 sed -i \
174 -e "/require_once/i \\define('TEST_CACHESTORE_REDIS_TESTSERVERS', '127.0.0.1');" \
175 config.php ;
176 # Redis session tests, but not for PHP 7.2 and up. See MDL-60978 for more info.
177 redissession="define('TEST_SESSION_REDIS_HOST', '127.0.0.1');"
178 sed -i \
179 -e "/require_once/i \\${redissession}" \
180 config.php ;
181
182 # Initialise PHPUnit for Moodle.
183 php admin/tool/phpunit/cli/init.php
184 fi
185
186 - >
187 if [ "$TASK" = 'GRUNT' ];
188 then
189 npm install --no-spin;
190 npm install --no-spin -g grunt ;
191 fi
192
193 ########################################################################
194 # CI Tests
195 ########################################################################
196 - >
197 if [ "$TASK" = 'CITEST' ];
198 then
199 # Note - this is deliberately placed in the script section as we
200 # should not add any code until after phpunit has run.
201
202 # The following repositories are required.
203 # The local_ci repository does the actual checking.
204 git clone https://github.com/moodlehq/moodle-local_ci.git local/ci
205
206 # We need the official upstream for comparison
207 git remote add upstream https://github.com/moodle/moodle.git;
208
209 git fetch upstream master;
210 export GIT_PREVIOUS_COMMIT="`git merge-base FETCH_HEAD $TRAVIS_COMMIT`";
211 export GIT_COMMIT="$TRAVIS_COMMIT";
212 export UPSTREAM_FETCH_HEAD=`git rev-parse FETCH_HEAD`
213
214 # Variables required by our linter.
215 export gitcmd=`which git`;
216 export gitdir="$TRAVIS_BUILD_DIR";
217 export phpcmd=`which php`;
218 fi
219
220 ########################################################################
221 # Upgrade test
222 ########################################################################
223 - >
224 if [ "$TASK" = 'UPGRADE' ];
225 then
226 # We need the official upstream.
227 git remote add upstream https://github.com/moodle/moodle.git;
228
229 # Checkout 30 STABLE branch (the first version compatible with PHP 7.x)
230 git fetch upstream MOODLE_30_STABLE;
231 git checkout MOODLE_30_STABLE;
232
233 # Perform the upgrade
234 php admin/cli/install_database.php --agree-license --adminpass=Password --adminemail=admin@example.com --fullname="Upgrade test" --shortname=Upgrade;
235
236 # Return to the previous commit
237 git checkout -;
238
239 # Perform the upgrade
240 php admin/cli/upgrade.php --non-interactive --allow-unstable ;
241
242 # The local_ci repository can be used to check upgrade savepoints.
243 git clone https://github.com/moodlehq/moodle-local_ci.git local/ci ;
244 fi
245
246 script:
247 - >
248 if [ "$TASK" = 'PHPUNIT' ];
249 then
250 vendor/bin/phpunit --fail-on-risky --disallow-test-output --verbose;
251 fi
252
253 - >
254 if [ "$TASK" = 'CITEST' ];
255 then
256 bash local/ci/php_lint/php_lint.sh;
257 fi
258
259 - >
260 if [ "$TASK" = 'GRUNT' ];
261 then
262 grunt ;
263 # Add all files to the git index and then run diff --cached to see all changes.
264 # This ensures that we get the status of all files, including new files.
265 # We ignore npm-shrinkwrap.json to make the tasks immune to npm changes.
266 git add . ;
267 git reset -- npm-shrinkwrap.json ;
268 git diff --cached --exit-code ;
269 fi
270
271 ########################################################################
272 # Upgrade test
273 ########################################################################
274 - >
275 if [ "$TASK" = 'UPGRADE' ];
276 then
277 cp local/ci/check_upgrade_savepoints/check_upgrade_savepoints.php ./check_upgrade_savepoints.php
278 result=`php check_upgrade_savepoints.php`;
279 # Check if there are problems
280 count=`echo "$result" | grep -P "ERROR|WARN" | wc -l` ;
281 if (($count > 0));
282 then
283 echo "$result"
284 exit 1 ;
285 fi
286 fi