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