MDL-55957 behat: Set some text before selecting in Atto
[moodle.git] / .travis.yml
blob99ab5e69d87b74eb83ef6c55aeb8eda62078ab0a
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.
5 sudo: false
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
12 language: php
14 php:
15     # We only run the highest and lowest supported versions to reduce the load on travis-ci.org.
16     - 7.0
17     # - 5.6
18     # - 5.5
19     - 5.4
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.
29     # Run unit tests on MySQL
30     - DB=mysqli   TASK=PHPUNIT
32     # Run CI Tests without running PHPUnit.
33     - DB=none     TASK=CITEST
35     # Run unit tests on Postgres
36     - DB=pgsql    TASK=PHPUNIT
38     # Run a check for unbuilt files with Grunt.
39     - DB=none     TASK=GRUNT
41 matrix:
42     # Enable fast finish.
43     # This will fail the build if a single job fails (except those in allow_failures).
44     # It will not stop the jobs from running.
45     fast_finish: true
47     exclude:
48         # MySQL - it's just too slow.
49         # Exclude it on all versions except for 7.0
50         # - env: DB=mysqli   TASK=PHPUNIT
51         #   php: 5.6
52         #
53         # - env: DB=mysqli   TASK=PHPUNIT
54         #   php: 5.5
56         - env: DB=mysqli   TASK=PHPUNIT
57           php: 5.4
59         - env: DB=none     TASK=GRUNT
60           php: 5.4
62 cache:
63     directories:
64       - $HOME/.composer/cache
65       - $HOME/.npm
67 install:
68     # Disable xdebug. We aren't generating code coverage, and it has a huge impact upon test performance.
69     - rm /home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
71     # Set the encrypted GITHUB_TOKEN if it's available to raise the API limit.
72     - if [ -n "$GITHUB_APITOKEN" ]; then composer config github-oauth.github.com $GITHUB_APITOKEN; fi
73     - echo 'auth.json' >> .git/info/exclude
75     # Install composer dependencies.
76     # We need --no-interaction in case we hit API limits for composer. This causes it to fall back to a standard clone.
77     # Typically it should be able to use the Composer cache if any other job has already completed before we started here.
78     - travis_retry composer install --prefer-dist --no-interaction
80 before_script:
81     - >
82       if [ "$TASK" = 'PHPUNIT' ];
83       then
84         # Copy generic configuration in place.
85         cp config-dist.php config.php ;
87         # Create the moodledata directory.
88         mkdir -p "$HOME"/roots/base
90         # The database name and password.
91         sed -i \
92           -e "s%= 'moodle'%= 'travis_ci_test'%" \
93           -e "s%= 'password'%= ''%" \
94           config.php ;
96         # The wwwroot and dataroot.
97         sed -i \
98           -e "s%http://example.com/moodle%http://localhost%" \
99           -e "s%/home/example/moodledata%/home/travis/roots/base%" \
100           config.php ;
102         if [ "$DB" = 'pgsql' ];
103         then
104           # Postgres-specific setup.
105           sed -i \
106             -e "s%= 'username'%= 'postgres'%" \
107             config.php ;
109           psql -c 'CREATE DATABASE travis_ci_test;' -U postgres;
110         fi
112         if [ "$DB" = 'mysqli' ];
113         then
114           # MySQL-specific setup.
115           sed -i \
116             -e "s%= 'pgsql'%= 'mysqli'%" \
117             -e "s%= 'username'%= 'travis'%" \
118             config.php;
120           mysql -u root -e 'SET GLOBAL innodb_file_format=barracuda;' ;
121           mysql -u root -e 'SET GLOBAL innodb_file_per_table=ON;' ;
122           mysql -e 'CREATE DATABASE travis_ci_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;' ;
123         fi
124       fi
126     - >
127       if [ "$TASK" = 'PHPUNIT' ];
128       then
129         # Create a directory for the phpunit dataroot.
130         mkdir -p "$HOME"/roots/phpunit
132         # The phpunit dataroot and prefix..
133         sed -i \
134           -e "/require_once/i \\\$CFG->phpunit_dataroot = '\/home\/travis\/roots\/phpunit';" \
135           -e "/require_once/i \\\$CFG->phpunit_prefix = 'p_';" \
136           config.php ;
138         # Initialise PHPUnit for Moodle.
139         php admin/tool/phpunit/cli/init.php
140       fi
142     - >
143       if [ "$TASK" = 'GRUNT' ];
144       then
145         npm install ;
146         npm install -g grunt ;
147         grunt ;
148       fi
150     ########################################################################
151     # CI Tests
152     ########################################################################
153     - >
154       if [ "$TASK" = 'CITEST' ];
155       then
156         # Note - this is deliberately placed in the script section as we
157         # should not add any code until after phpunit has run.
159         # The following repositories are required.
160         # The local_ci repository does the actual checking.
161         git clone https://github.com/moodlehq/moodle-local_ci.git local/ci
163         # We need the official upstream for comparison
164         git remote add upstream https://github.com/moodle/moodle.git;
166         git fetch upstream MOODLE_30_STABLE;
167         export GIT_PREVIOUS_COMMIT="`git merge-base FETCH_HEAD $TRAVIS_COMMIT`";
168         export GIT_COMMIT="$TRAVIS_COMMIT";
169         export UPSTREAM_FETCH_HEAD=`git rev-parse FETCH_HEAD`
171         # Variables required by our linter.
172         export gitcmd=`which git`;
173         export gitdir="$TRAVIS_BUILD_DIR";
174         export phpcmd=`which php`;
175       fi
177     # Actually run the CI Tests - do this outside of the main test to make output clearer.
178     - >
179       if [ "$TASK" = 'CITEST' ];
180       then
181         bash local/ci/php_lint/php_lint.sh;
182       fi
184 script:
185     - >
186       if [ "$TASK" = 'PHPUNIT' ];
187       then
188         vendor/bin/phpunit;
189       fi
191     - >
192       if [ "$TASK" = 'CITEST' ];
193       then
194         bash local/ci/php_lint/php_lint.sh;
195       fi
197     - >
198       if [ "$TASK" = 'GRUNT' ];
199       then
200         # Add all files to the git index and then run diff --cached to see all changes.
201         # This ensures that we get the status of all files, including new files.
202         git add . ;
203         git diff --cached --exit-code ;
204       fi