@@ -13,19 +13,39 @@ cache:
1313
1414php :
1515 - 5.4
16- - 7.3
16+ - 5.5
17+ - 5.6
18+ - 7.0
19+ - 7.1
20+ - 7.2
21+
22+ env :
23+ matrix :
24+ # `master`
25+ - PHPCS_VERSION="dev-master" LINT=1
26+ # Lowest supported PHPCS version.
27+ # In reality this is 3.0.2, but there is a bug in the unit test runner of that version.
28+ - PHPCS_VERSION="3.0.2"
1729
1830# Define the stages used.
31+ # For non-PRs, only the sniff and quicktest stages are run.
32+ # For pull requests and merges, the full script is run (skipping quicktest).
33+ # Note: for pull requests, "develop" is the base branch name.
34+ # See: https://docs.travis-ci.com/user/conditions-v1
1935stages :
2036 - name : sniff
37+ - name : quicktest
38+ if : type = push AND branch NOT IN (master, develop)
2139 - name : test
40+ if : branch IN (master, develop)
2241
2342jobs :
2443 fast_finish : true
2544 include :
2645 # ### SNIFF STAGE ####
2746 - stage : sniff
2847 php : 7.3
48+ env : PHPCS_VERSION="dev-master"
2949 addons :
3050 apt :
3151 packages :
@@ -36,27 +56,89 @@ jobs:
3656
3757 # Validate the xml file.
3858 # @link http://xmlsoft.org/xmllint.html
59+ - xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./Debug/ruleset.xml
3960 - xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./PHPCSDev/ruleset.xml
4061
4162 # Check the code-style consistency of the xml files.
63+ - diff -B ./Debug/ruleset.xml <(xmllint --format "./Debug/ruleset.xml")
4264 - diff -B ./PHPCSDev/ruleset.xml <(xmllint --format "./PHPCSDev/ruleset.xml")
4365
4466
67+ # ### QUICK TEST STAGE ####
68+ # This is a much quicker test which only runs the unit tests and linting against the low/high
69+ # supported PHP/PHPCS combinations.
70+ - stage : quicktest
71+ php : 7.3
72+ env : PHPCS_VERSION="dev-master" LINT=1
73+ - php : 7.2
74+ env : PHPCS_VERSION="3.0.2"
75+
76+ - php : 5.4
77+ env : PHPCS_VERSION="dev-master" LINT=1
78+ - php : 5.4
79+ env : PHPCS_VERSION="3.0.2"
80+
81+ # ### TEST STAGE ####
82+ # Additional builds to prevent issues with PHPCS versions incompatible with certain PHP versions.
83+ - stage : test
84+ php : 7.3
85+ env : PHPCS_VERSION="dev-master" LINT=1
86+ # PHPCS is only compatible with PHP 7.3 as of version 3.3.1.
87+ - php : 7.3
88+ env : PHPCS_VERSION="3.3.1"
89+ # PHPCS is only compatible with PHP 7.4 as of version 3.5.0.
90+ - php : " 7.4snapshot"
91+ env : PHPCS_VERSION=dev-master"
92+
93+ allow_failures :
94+ # Allow failures for unstable builds.
95+ - php : " 7.4snapshot"
96+
97+
4598before_install :
4699 # Speed up build time by disabling Xdebug when its not needed.
47100 - phpenv config-rm xdebug.ini || echo 'No xdebug config.'
48101
102+ # On stable PHPCS versions, allow for PHP deprecation notices.
103+ # Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
104+ - |
105+ if [[ "$TRAVIS_BUILD_STAGE_NAME" != "Sniff" && $PHPCS_BRANCH != "dev-master" ]]; then
106+ echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
107+ fi
108+
49109 - export XMLLINT_INDENT=" "
50110
111+ # Set up test environment using Composer.
112+ - composer require --no-update --no-scripts squizlabs/php_codesniffer:${PHPCS_VERSION}
113+ - |
114+ if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Sniff" ]]; then
115+ # The sniff stage doesn't run the unit tests, so no need for PHPUnit.
116+ composer remove --dev phpunit/phpunit --no-update --no-scripts
117+ elif [[ "$PHPCS_VERSION" < "3.1.0" ]]; then
118+ # PHPCS < 3.1.0 is not compatible with PHPUnit 6.x.
119+ composer require --dev phpunit/phpunit:"^4.0||^5.0" --no-update --no-scripts
120+ elif [[ "$PHPCS_VERSION" < "3.2.3" ]]; then
121+ # PHPCS < 3.2.3 is not compatible with PHPUnit 7.x.
122+ composer require --dev phpunit/phpunit:"^4.0||^5.0||^6.0" --no-update --no-scripts
123+ fi
124+
51125 # --prefer-dist will allow for optimal use of the travis caching ability.
52126 # The Composer PHPCS plugin takes care of setting the installed_paths for PHPCS.
53127 - composer install --prefer-dist --no-suggest
54128
55129
56130script :
57131 # Lint PHP files against parse errors.
58- - composer lint
132+ - if [[ "$LINT" == "1" ]]; then composer lint; fi
133+
134+ # Check that any sniffs available are feature complete.
135+ # This also acts as an integration test for the feature completeness script,
136+ # which is why it is run against various PHP versions and not in the "Sniff" stage.
137+ - if [[ "$LINT" == "1" ]]; then composer check-complete; fi
59138
60- # Validate the composer.json file on low/high PHP versions .
139+ # Validate the composer.json file.
61140 # @link https://getcomposer.org/doc/03-cli.md#validate
62- - composer validate --no-check-all --strict
141+ - if [[ "$LINT" == "1" ]]; then composer validate --no-check-all --strict; fi
142+
143+ # Run the unit tests.
144+ - composer run-tests
0 commit comments