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