@@ -4,6 +4,7 @@ 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
@@ -12,21 +13,142 @@ cache:
1213
1314php :
1415 - 5.4
15- - 7.3
16+ - 5.5
17+ - 5.6
18+ - 7.0
19+ - 7.1
20+ - 7.2
21+
22+ env :
23+ # `master`
24+ - PHPCS_VERSION="dev-master" LINT=1
25+ # Lowest supported PHPCS version.
26+ - PHPCS_VERSION="3.0.2"
27+
28+ # Define the stages used.
29+ # For non-PRs, only the sniff and quicktest stages are run.
30+ # For pull requests and merges, the full script is run (skipping quicktest).
31+ # Note: for pull requests, "develop" is the base branch name.
32+ # See: https://docs.travis-ci.com/user/conditions-v1
33+ stages :
34+ - name : sniff
35+ - name : quicktest
36+ if : type = push AND branch NOT IN (master, develop)
37+ - name : test
38+ if : branch IN (master, develop)
1639
1740jobs :
1841 fast_finish : true
42+ include :
43+ # ### SNIFF STAGE ####
44+ - stage : sniff
45+ php : 7.3
46+ env : PHPCS_VERSION="dev-master"
47+ addons :
48+ apt :
49+ packages :
50+ - libxml2-utils
51+ script :
52+ # Check the code style of the code base.
53+ - composer check-cs
54+
55+ # Validate the xml file.
56+ # @link http://xmlsoft.org/xmllint.html
57+ - xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./PHPCSDebug/ruleset.xml
58+
59+ # Check the code-style consistency of the xml files.
60+ - diff -B ./PHPCSDebug/ruleset.xml <(xmllint --format "./PHPCSDebug/ruleset.xml")
61+
62+ # Validate the composer.json file.
63+ # @link https://getcomposer.org/doc/03-cli.md#validate
64+ - composer validate --no-check-all --strict
65+
66+ # ### QUICK TEST STAGE ####
67+ # This is a much quicker test which only runs the unit tests and linting against the low/high
68+ # supported PHP/PHPCS combinations.
69+ - stage : quicktest
70+ php : 7.3
71+ env : PHPCS_VERSION="dev-master" LINT=1
72+ - stage : quicktest
73+ php : 7.2
74+ env : PHPCS_VERSION="3.0.2"
75+
76+ - stage : quicktest
77+ php : 5.4
78+ env : PHPCS_VERSION="dev-master" LINT=1
79+ - stage : quicktest
80+ php : 5.4
81+ env : PHPCS_VERSION="3.0.2"
82+
83+ # ### TEST STAGE ####
84+ # Additional builds to prevent issues with PHPCS versions incompatible with certain PHP versions.
85+ - stage : test
86+ php : 7.3
87+ env : PHPCS_VERSION="dev-master" LINT=1
88+ # PHPCS is only compatible with PHP 7.3 as of version 3.3.1.
89+ - php : 7.3
90+ env : PHPCS_VERSION="3.3.1"
91+ - php : 7.4
92+ env : PHPCS_VERSION="dev-master"
93+ # PHPCS is only compatible with PHP 7.4 as of version 3.5.0.
94+ - php : 7.4
95+ env : PHPCS_VERSION="3.5.0"
96+ - php : " nightly"
97+ env : PHPCS_VERSION="n/a" LINT=1
98+
99+ allow_failures :
100+ # Allow failures for unstable builds.
101+ - php : " nightly"
19102
20103
21104before_install :
22105 # Speed up build time by disabling Xdebug when its not needed.
23106 - phpenv config-rm xdebug.ini || echo 'No xdebug config.'
24107
108+ # On stable PHPCS versions, allow for PHP deprecation notices.
109+ # Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
110+ - |
111+ if [[ "$TRAVIS_BUILD_STAGE_NAME" != "Sniff" && "$PHPCS_VERSION" != "dev-master" && "$PHPCS_VERSION" != "n/a" ]]; then
112+ echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
113+ fi
114+
115+ - export XMLLINT_INDENT=" "
116+
117+ # Set up test environment using Composer.
118+ - |
119+ if [[ "$TRAVIS_BUILD_STAGE_NAME" != "Sniff" ]]; then
120+ # Remove the PHPCSDevCS dependency as it has different PHPCS requirements and would block installs.
121+ composer remove --dev phpcsstandards/phpcsdevcs --no-update --no-scripts
122+ fi
123+ - |
124+ if [[ $PHPCS_VERSION != "n/a" ]]; then
125+ composer require --no-update --no-scripts squizlabs/php_codesniffer:${PHPCS_VERSION}
126+ fi
127+ - |
128+ if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Sniff" || $PHPCS_VERSION == "n/a" ]]; then
129+ # The sniff stage doesn't run the unit tests, so no need for PHPUnit.
130+ composer remove --dev phpunit/phpunit --no-update --no-scripts
131+ elif [[ "$PHPCS_VERSION" < "3.1.0" ]]; then
132+ # PHPCS < 3.1.0 is not compatible with PHPUnit 6.x.
133+ composer require --dev phpunit/phpunit:"^4.0||^5.0" --no-update --no-scripts
134+ elif [[ "$PHPCS_VERSION" < "3.2.3" ]]; then
135+ # PHPCS < 3.2.3 is not compatible with PHPUnit 7.x.
136+ composer require --dev phpunit/phpunit:"^4.0||^5.0||^6.0" --no-update --no-scripts
137+ fi
138+
25139 # --prefer-dist will allow for optimal use of the travis caching ability.
140+ # The Composer PHPCS plugin takes care of setting the installed_paths for PHPCS.
26141 - composer install --prefer-dist --no-suggest
27142
28143
29144script :
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
145+ # Lint PHP files against parse errors.
146+ - if [[ "$LINT" == "1" ]]; then composer lint; fi
147+
148+ # Check that any sniffs available are feature complete.
149+ # This also acts as an integration test for the feature completeness script,
150+ # which is why it is run against various PHP versions and not in the "Sniff" stage.
151+ - if [[ "$LINT" == "1" ]]; then composer check-complete; fi
152+
153+ # Run the unit tests.
154+ - if [[ $PHPCS_VERSION != "n/a" ]]; then composer run-tests; fi
0 commit comments