@@ -4,29 +4,203 @@ language: php
44
55# # Cache composer and apt downloads.
66cache :
7+ apt : true
78 directories :
89 # Cache directory for older Composer versions.
910 - $HOME/.composer/cache/files
1011 # Cache directory for more recent Composer versions.
1112 - $HOME/.cache/composer/files
1213
1314php :
14- - 5.4
15- - 7.3
15+ - 5.5
16+ - 5.6
17+ - 7.0
18+ - 7.1
19+ - 7.2
20+
21+ env :
22+ - PHPCS_VERSION="dev-master" LINT=1
23+ - PHPCS_VERSION="3.1.0"
24+ - PHPCS_VERSION="2.9.2"
25+ - PHPCS_VERSION="2.6.0"
26+
27+ # Define the stages used.
28+ # For non-PRs, only the sniff and quicktest stages are run.
29+ # For pull requests and merges, the full script is run (skipping quicktest).
30+ # Note: for pull requests, "develop" is the base branch name.
31+ # See: https://docs.travis-ci.com/user/conditions-v1
32+ stages :
33+ - name : sniff
34+ - name : quicktest
35+ if : type = push AND branch NOT IN (master, develop)
36+ - name : test
37+ if : branch IN (master, develop)
38+ - name : coverage
39+ if : branch IN (master, develop)
1640
1741jobs :
1842 fast_finish : true
43+ include :
44+ # ### SNIFF STAGE ####
45+ - stage : sniff
46+ php : 7.3
47+ env : PHPCS_VERSION="dev-master"
48+ addons :
49+ apt :
50+ packages :
51+ - libxml2-utils
52+ install : skip
53+ script :
54+ # Validate the composer.json file.
55+ # @link https://getcomposer.org/doc/03-cli.md#validate
56+ - composer validate --no-check-all --strict
57+
58+ # Check the code style of the code base.
59+ - composer travis-checkcs
60+
61+ # Validate the xml files.
62+ # @link http://xmlsoft.org/xmllint.html
63+ - xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./PHPCSUtils/ruleset.xml
64+ - xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./PHPCS23Utils/ruleset.xml
65+
66+ # Check the code-style consistency of the xml files.
67+ - diff -B ./PHPCSUtils/ruleset.xml <(xmllint --format "./PHPCSUtils/ruleset.xml")
68+ - diff -B ./PHPCS23Utils/ruleset.xml <(xmllint --format "./PHPCS23Utils/ruleset.xml")
69+
70+ # ### QUICK TEST STAGE ####
71+ # This is a much quicker test which only runs the unit tests and linting against the low/high
72+ # supported PHP/PHPCS combinations.
73+ # These are basically the same builds as in the Coverage stage, but then without doing
74+ # the code-coverage.
75+ - stage : quicktest
76+ php : 7.4
77+ env : PHPCS_VERSION="dev-master" LINT=1
78+ - stage : quicktest
79+ php : 7.3
80+ # PHPCS is only compatible with PHP 7.3 as of version 3.3.1/2.9.2.
81+ env : PHPCS_VERSION="2.9.2"
82+
83+ - stage : quicktest
84+ php : 5.4
85+ env : PHPCS_VERSION="dev-master" LINT=1
86+ - stage : quicktest
87+ php : 5.4
88+ env : PHPCS_VERSION="2.6.0"
89+
90+ # ### TEST STAGE ####
91+ # Additional builds to prevent issues with PHPCS versions incompatible with certain PHP versions.
92+ - stage : test
93+ php : 7.3
94+ env : PHPCS_VERSION="dev-master" LINT=1
95+ - php : 7.3
96+ # PHPCS is only compatible with PHP 7.3 as of version 3.3.1/2.9.2.
97+ env : PHPCS_VERSION="3.3.1"
98+
99+ - php : 5.4
100+ env : PHPCS_VERSION="3.1.0"
101+ - php : 5.4
102+ env : PHPCS_VERSION="2.9.2"
103+
104+ # PHPCS is only compatible with PHP 7.4 as of version 3.5.0.
105+ - php : 7.4
106+ env : PHPCS_VERSION="3.5.0"
107+
108+ # One extra build to verify issues around PHPCS annotations when they weren't fully accounted for yet.
109+ - php : 7.2
110+ env : PHPCS_VERSION="3.2.0"
111+
112+ - php : " nightly"
113+ env : PHPCS_VERSION="n/a" LINT=1
114+
115+ # ### CODE COVERAGE STAGE ####
116+ # N.B.: Coverage is only checked on the lowest and highest stable PHP versions for all PHPCS versions.
117+ # These builds are left out off the "test" stage so as not to duplicate test runs.
118+ # The script used is the default script below, the same as for the `test` stage.
119+ - stage : coverage
120+ php : 7.4
121+ env : PHPCS_VERSION="dev-master" LINT=1 COVERALLS_VERSION="^2.0"
122+ - php : 7.3
123+ # PHPCS is only compatible with PHP 7.3 as of version 3.3.1/2.9.2.
124+ env : PHPCS_VERSION="2.9.2" COVERALLS_VERSION="^2.0"
125+
126+ - php : 5.4
127+ env : PHPCS_VERSION="dev-master" LINT=1 COVERALLS_VERSION="^1.0"
128+ - php : 5.4
129+ env : PHPCS_VERSION="2.6.0" COVERALLS_VERSION="^1.0"
130+
131+
132+ allow_failures :
133+ # Allow failures for unstable builds.
134+ - php : " nightly"
19135
20136
21137before_install :
22138 # Speed up build time by disabling Xdebug when its not needed.
23- - phpenv config-rm xdebug.ini || echo 'No xdebug config.'
139+ - |
140+ if [[ "$TRAVIS_BUILD_STAGE_NAME" != "Coverage" ]]; then
141+ phpenv config-rm xdebug.ini || echo 'No xdebug config.'
142+ fi
143+
144+ # On stable PHPCS versions, allow for PHP deprecation notices.
145+ # Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
146+ - |
147+ if [[ "$TRAVIS_BUILD_STAGE_NAME" != "Sniff" && $PHPCS_VERSION != "dev-master" && "$PHPCS_VERSION" != "n/a" ]]; then
148+ echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
149+ fi
150+
151+ - export XMLLINT_INDENT=" "
152+
153+
154+ install :
155+ # Set up test environment using Composer.
156+ - |
157+ if [[ $PHPCS_VERSION != "n/a" ]]; then
158+ composer require --no-update --no-scripts squizlabs/php_codesniffer:${PHPCS_VERSION}
159+ fi
160+ - |
161+ if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" ]]; then
162+ composer require --dev --no-update --no-suggest --no-scripts php-coveralls/php-coveralls:${COVERALLS_VERSION}
163+ fi
164+ - |
165+ if [[ $PHPCS_VERSION == "n/a" ]]; then
166+ # Don't install PHPUnit when it's not needed.
167+ composer remove --dev phpunit/phpunit --no-update --no-scripts
168+ elif [[ "$PHPCS_VERSION" < "3.1.0" ]]; then
169+ # PHPCS < 3.1.0 is not compatible with PHPUnit 6.x.
170+ composer require --dev phpunit/phpunit:"^4.0||^5.0" --no-update --no-scripts
171+ elif [[ "$PHPCS_VERSION" < "3.2.3" ]]; then
172+ # PHPCS < 3.2.3 is not compatible with PHPUnit 7.x.
173+ composer require --dev phpunit/phpunit:"^4.0||^5.0||^6.0" --no-update --no-scripts
174+ fi
24175
25176 # --prefer-dist will allow for optimal use of the travis caching ability.
177+ # The Composer PHPCS plugin takes care of setting the installed_paths for PHPCS.
26178 - composer install --prefer-dist --no-suggest
27179
28180
181+ before_script :
182+ - if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" ]]; then mkdir -p build/logs; fi
183+ - phpenv rehash
184+
185+
29186script :
30- # Validate the composer.json file on low/high PHP versions.
31- # @link https://getcomposer.org/doc/03-cli.md#validate
32- - composer validate --no-check-all --strict
187+ # Lint PHP files against parse errors.
188+ - if [[ "$LINT" == "1" ]]; then composer lint; fi
189+
190+ # Run the unit tests.
191+ - |
192+ if [[ $PHPCS_VERSION != "n/a" && "$TRAVIS_BUILD_STAGE_NAME" != "Coverage" ]]; then
193+ composer test
194+ elif [[ $PHPCS_VERSION != "n/a" && "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" ]]; then
195+ composer coverage
196+ fi
197+
198+ after_success :
199+ - |
200+ if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" && $COVERALLS_VERSION == "^1.0" ]]; then
201+ php vendor/bin/coveralls -v -x build/logs/clover.xml
202+ fi
203+ - |
204+ if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" && $COVERALLS_VERSION == "^2.0" ]]; then
205+ php vendor/bin/php-coveralls -v -x build/logs/clover.xml
206+ fi
0 commit comments