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