Commit | Line | Data |
---|---|---|
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 |
5 | sudo: false |
6 | ||
ab17b4f7 AN |
7 | # We currently disable Travis notifications entirely until https://github.com/travis-ci/travis-ci/issues/4976 |
8 | # is fixed. | |
9 | notifications: | |
10 | email: false | |
11 | ||
88ec0860 AN |
12 | language: php |
13 | ||
14 | php: | |
87b7314a DP |
15 | # We only run the highest and lowest supported versions to reduce the load on travis-ci.org. |
16 | - 7.0 | |
17 | # - 5.6 | |
88ec0860 AN |
18 | # - 5.5 |
19 | - 5.4 | |
20 | ||
88ec0860 AN |
21 | env: |
22 | # Although we want to run these jobs and see failures as quickly as possible, we also want to get the slowest job to | |
23 | # start first so that the total run time is not too high. | |
24 | # | |
25 | # We only run MySQL on PHP 5.6, so run that first. | |
26 | # CI Tests should be second-highest in priority as these only take <= 60 seconds to run under normal circumstances. | |
27 | # Postgres is significantly is pretty reasonable in its run-time. | |
28 | ||
29 | # Run unit tests on MySQL | |
30 | - DB=mysqli PHPUNIT=true INSTALL=false CITEST=false | |
31 | ||
32 | # Run CI Tests without running PHPUnit. | |
33 | - DB=none PHPUNIT=false INSTALL=false CITEST=true | |
34 | ||
35 | # Run unit tests on Postgres | |
36 | - DB=pgsql PHPUNIT=true INSTALL=false CITEST=false | |
37 | ||
38 | matrix: | |
39 | # Enable fast finish. | |
40 | # This will fail the build if a single job fails (except those in allow_failures). | |
41 | # It will not stop the jobs from running. | |
42 | fast_finish: true | |
43 | ||
88ec0860 | 44 | exclude: |
88ec0860 | 45 | # MySQL - it's just too slow. |
87b7314a DP |
46 | # Exclude it on all versions except for 7.0 |
47 | # - env: DB=mysqli PHPUNIT=true INSTALL=false CITEST=false | |
48 | # php: 5.6 | |
49 | # | |
88ec0860 AN |
50 | # - env: DB=mysqli PHPUNIT=true INSTALL=false CITEST=false |
51 | # php: 5.5 | |
52 | ||
53 | - env: DB=mysqli PHPUNIT=true INSTALL=false CITEST=false | |
54 | php: 5.4 | |
55 | ||
88ec0860 AN |
56 | cache: |
57 | directories: | |
58 | - $HOME/.composer/cache | |
59 | ||
60 | install: | |
eb474609 AN |
61 | # Disable xdebug. We aren't generating code coverage, and it has a huge impact upon test performance. |
62 | - rm /home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini | |
63 | ||
88ec0860 AN |
64 | # Set the encrypted GITHUB_TOKEN if it's available to raise the API limit. |
65 | - if [ -n "$GITHUB_APITOKEN" ]; then composer config github-oauth.github.com $GITHUB_APITOKEN; fi | |
66 | ||
67 | # Install composer dependencies. | |
68 | # We need --no-interaction in case we hit API limits for composer. This causes it to fall back to a standard clone. | |
69 | # Typically it should be able to use the Composer cache if any other job has already completed before we started here. | |
70 | - travis_retry composer install --prefer-dist --no-interaction | |
71 | ||
72 | before_script: | |
73 | - > | |
74 | if [ "$INSTALL" = 'true' -o "$PHPUNIT" = 'true' ]; | |
75 | then | |
76 | # Copy generic configuration in place. | |
77 | cp config-dist.php config.php ; | |
78 | ||
79 | # Create the moodledata directory. | |
80 | mkdir -p "$HOME"/roots/base | |
81 | ||
82 | # The database name and password. | |
83 | sed -i \ | |
84 | -e "s%= 'moodle'%= 'travis_ci_test'%" \ | |
85 | -e "s%= 'password'%= ''%" \ | |
86 | config.php ; | |
87 | ||
88 | # The wwwroot and dataroot. | |
89 | sed -i \ | |
90 | -e "s%http://example.com/moodle%http://localhost%" \ | |
91 | -e "s%/home/example/moodledata%/home/travis/roots/base%" \ | |
92 | config.php ; | |
93 | ||
94 | if [ "$DB" = 'pgsql' ]; | |
95 | then | |
96 | # Postgres-specific setup. | |
97 | sed -i \ | |
98 | -e "s%= 'username'%= 'postgres'%" \ | |
99 | config.php ; | |
100 | ||
101 | psql -c 'CREATE DATABASE travis_ci_test;' -U postgres; | |
102 | fi | |
103 | ||
104 | if [ "$DB" = 'mysqli' ]; | |
105 | then | |
106 | # MySQL-specific setup. | |
107 | sed -i \ | |
108 | -e "s%= 'pgsql'%= 'mysqli'%" \ | |
109 | -e "s%= 'username'%= 'travis'%" \ | |
110 | config.php; | |
111 | ||
112 | mysql -u root -e 'SET GLOBAL innodb_file_format=barracuda;' ; | |
113 | mysql -u root -e 'SET GLOBAL innodb_file_per_table=ON;' ; | |
114 | mysql -e 'CREATE DATABASE travis_ci_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;' ; | |
115 | fi | |
116 | ||
117 | if [ "$PHPUNIT" = 'true' ]; | |
118 | then | |
119 | # Create a directory for the phpunit dataroot. | |
120 | mkdir -p "$HOME"/roots/phpunit | |
121 | ||
122 | # The phpunit dataroot and prefix.. | |
123 | sed -i \ | |
124 | -e "/require_once/i \\\$CFG->phpunit_dataroot = '\/home\/travis\/roots\/phpunit';" \ | |
125 | -e "/require_once/i \\\$CFG->phpunit_prefix = 'p_';" \ | |
126 | config.php ; | |
127 | ||
128 | # Initialise PHPUnit for Moodle. | |
129 | php admin/tool/phpunit/cli/init.php | |
130 | fi | |
131 | fi | |
132 | ||
133 | script: | |
134 | ######################################################################## | |
135 | # PHPUnit | |
136 | ######################################################################## | |
137 | - > | |
138 | if [ "$PHPUNIT" = 'true' ]; | |
139 | then | |
140 | vendor/bin/phpunit; | |
141 | fi | |
142 | ||
143 | ######################################################################## | |
144 | # CI Tests | |
145 | ######################################################################## | |
146 | - > | |
147 | if [ "$CITEST" = 'true' ]; | |
148 | then | |
149 | # Note - this is deliberately placed in the script section as we | |
150 | # should not add any code until after phpunit has run. | |
151 | ||
152 | # The following repositories are required. | |
153 | # The local_ci repository does the actual checking. | |
154 | git clone https://github.com/moodlehq/moodle-local_ci.git local/ci | |
155 | ||
88ec0860 AN |
156 | # We need the official upstream for comparison |
157 | git remote add upstream https://github.com/moodle/moodle.git; | |
5459e754 | 158 | |
b2e859bc | 159 | git fetch upstream master; |
88ec0860 AN |
160 | export GIT_PREVIOUS_COMMIT="`git merge-base FETCH_HEAD $TRAVIS_COMMIT`"; |
161 | export GIT_COMMIT="$TRAVIS_COMMIT"; | |
162 | export UPSTREAM_FETCH_HEAD=`git rev-parse FETCH_HEAD` | |
163 | ||
164 | # Variables required by our linter. | |
165 | export gitcmd=`which git`; | |
166 | export gitdir="$TRAVIS_BUILD_DIR"; | |
167 | export phpcmd=`which php`; | |
168 | fi | |
169 | ||
88ec0860 AN |
170 | # Actually run the CI Tests - do this outside of the main test to make output clearer. |
171 | - > | |
172 | if [ "$CITEST" = 'true' ]; | |
173 | then | |
174 | bash local/ci/php_lint/php_lint.sh; | |
175 | fi |