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