Moodle release 3.0beta
[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:
15 # Moodle supports versions 5.4, 5.5, and 5.6 of PHP.
16 # Order by fastest to slowest.
17 # We currently only run the highest and lowest versions to reduce the load on travis-ci.org.
18 - 5.6
19 # - 5.5
20 - 5.4
21
22 # We hope to offer PHP 7 support in the near future.
23 - nightly
24
25env:
26 # Although we want to run these jobs and see failures as quickly as possible, we also want to get the slowest job to
27 # start first so that the total run time is not too high.
28 #
29 # We only run MySQL on PHP 5.6, so run that first.
30 # CI Tests should be second-highest in priority as these only take <= 60 seconds to run under normal circumstances.
31 # Postgres is significantly is pretty reasonable in its run-time.
32
33 # Run unit tests on MySQL
34 - DB=mysqli PHPUNIT=true INSTALL=false CITEST=false
35
36 # Run CI Tests without running PHPUnit.
37 - DB=none PHPUNIT=false INSTALL=false CITEST=true
38
39 # Run unit tests on Postgres
40 - DB=pgsql PHPUNIT=true INSTALL=false CITEST=false
41
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
48 # Always allow failure on nightly.
49 # It's a nightly build and failures can happen.
50 allow_failures:
51 - php: nightly
52
53 exclude:
54 # PHP 7 is not yet supported for actual runs.
55 # Exclude it by default - we include it for CITEST only later.
56 - php: nightly
57
58 # MySQL - it's just too slow.
59 # Exclude it on all versions except for 5.6.
60 # - env: DB=mysqli PHPUNIT=true INSTALL=false CITEST=false
61 # php: 5.5
62
63 - env: DB=mysqli PHPUNIT=true INSTALL=false CITEST=false
64 php: 5.4
65
66 include:
67 # Attempt to run the CITEST set on PHP 7.
68 - php: nightly
69 env: DB=none PHPUNIT=false INSTALL=false CITEST=true
70
71cache:
72 directories:
73 - $HOME/.composer/cache
74
75install:
76 # Set the encrypted GITHUB_TOKEN if it's available to raise the API limit.
77 - if [ -n "$GITHUB_APITOKEN" ]; then composer config github-oauth.github.com $GITHUB_APITOKEN; fi
78
79 # Install composer dependencies.
80 # We need --no-interaction in case we hit API limits for composer. This causes it to fall back to a standard clone.
81 # Typically it should be able to use the Composer cache if any other job has already completed before we started here.
82 - travis_retry composer install --prefer-dist --no-interaction
83
84before_script:
85 - >
86 if [ "$INSTALL" = 'true' -o "$PHPUNIT" = 'true' ];
87 then
88 # Copy generic configuration in place.
89 cp config-dist.php config.php ;
90
91 # Create the moodledata directory.
92 mkdir -p "$HOME"/roots/base
93
94 # The database name and password.
95 sed -i \
96 -e "s%= 'moodle'%= 'travis_ci_test'%" \
97 -e "s%= 'password'%= ''%" \
98 config.php ;
99
100 # The wwwroot and dataroot.
101 sed -i \
102 -e "s%http://example.com/moodle%http://localhost%" \
103 -e "s%/home/example/moodledata%/home/travis/roots/base%" \
104 config.php ;
105
106 if [ "$DB" = 'pgsql' ];
107 then
108 # Postgres-specific setup.
109 sed -i \
110 -e "s%= 'username'%= 'postgres'%" \
111 config.php ;
112
113 psql -c 'CREATE DATABASE travis_ci_test;' -U postgres;
114 fi
115
116 if [ "$DB" = 'mysqli' ];
117 then
118 # MySQL-specific setup.
119 sed -i \
120 -e "s%= 'pgsql'%= 'mysqli'%" \
121 -e "s%= 'username'%= 'travis'%" \
122 config.php;
123
124 mysql -u root -e 'SET GLOBAL innodb_file_format=barracuda;' ;
125 mysql -u root -e 'SET GLOBAL innodb_file_per_table=ON;' ;
126 mysql -e 'CREATE DATABASE travis_ci_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;' ;
127 fi
128
129 if [ "$PHPUNIT" = 'true' ];
130 then
131 # Create a directory for the phpunit dataroot.
132 mkdir -p "$HOME"/roots/phpunit
133
134 # The phpunit dataroot and prefix..
135 sed -i \
136 -e "/require_once/i \\\$CFG->phpunit_dataroot = '\/home\/travis\/roots\/phpunit';" \
137 -e "/require_once/i \\\$CFG->phpunit_prefix = 'p_';" \
138 config.php ;
139
140 # Initialise PHPUnit for Moodle.
141 php admin/tool/phpunit/cli/init.php
142 fi
143 fi
144
145script:
146 ########################################################################
147 # PHPUnit
148 ########################################################################
149 - >
150 if [ "$PHPUNIT" = 'true' ];
151 then
152 vendor/bin/phpunit;
153 fi
154
155 ########################################################################
156 # CI Tests
157 ########################################################################
158 - >
159 if [ "$CITEST" = 'true' ];
160 then
161 # Note - this is deliberately placed in the script section as we
162 # should not add any code until after phpunit has run.
163
164 # The following repositories are required.
165 # The local_ci repository does the actual checking.
166 git clone https://github.com/moodlehq/moodle-local_ci.git local/ci
167
168 # Determine the branch
169 grep '^$release.*dev' version.php > /dev/null
170 if [ $? -eq 0 ];
171 then
172 # This is master
173 export branchname='master';
174 else
175 # This is a stable branch. Use the version from version.php to determine which one.
176 export branchname="MOODLE_`grep '^$branch' version.php | sed "s/^.*'\([0-9]*\)'.*$/\1/"`_STABLE";
177 fi
178
179 # We need the official upstream for comparison
180 git remote add upstream https://github.com/moodle/moodle.git;
181 git fetch upstream "$branchname";
182 export GIT_PREVIOUS_COMMIT="`git merge-base FETCH_HEAD $TRAVIS_COMMIT`";
183 export GIT_COMMIT="$TRAVIS_COMMIT";
184 export UPSTREAM_FETCH_HEAD=`git rev-parse FETCH_HEAD`
185
186 # Variables required by our linter.
187 export gitcmd=`which git`;
188 export gitdir="$TRAVIS_BUILD_DIR";
189 export phpcmd=`which php`;
190 fi
191
192 - >
193 if [ "$CITEST" = "true" -a "$GIT_PREVIOUS_COMMIT" != "$UPSTREAM_FETCH_HEAD" ];
194 then
195 # This is a CI test, but it is based on an older weekly release.
196 # Warn in a way that will fail the test.
197 echo "Current commit is based on an older weekly release" && false;
198 fi
199
200 # Actually run the CI Tests - do this outside of the main test to make output clearer.
201 - >
202 if [ "$CITEST" = 'true' ];
203 then
204 bash local/ci/php_lint/php_lint.sh;
205 fi