-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.travis.yml
170 lines (146 loc) · 5.69 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
dist: trusty
language: php
## Cache composer and apt downloads.
cache:
apt: true
directories:
# Cache directory for older Composer versions.
- $HOME/.composer/cache/files
# Cache directory for more recent Composer versions.
- $HOME/.cache/composer/files
# Note: PHP 7.3, 7.4 and nightly are added via "jobs".
php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
env:
# PHPCS `master`
- PHPCS_VERSION="dev-master" LINT=1
# Lowest supported PHPCS version.
- PHPCS_VERSION="3.0.2"
# Define the stages used.
# For non-PRs, only the sniff and quicktest stages are run.
# For pull requests and merges, the full script is run (skipping quicktest).
# Note: for pull requests, "develop" is the base branch name.
# See: https://docs.travis-ci.com/user/conditions-v1
stages:
- name: sniff
- name: quicktest
if: type = push AND branch NOT IN (stable, develop)
- name: test
if: branch IN (stable, develop)
jobs:
fast_finish: true
include:
#### SNIFF STAGE ####
- stage: sniff
php: 7.4
env: PHPCS_VERSION="dev-master"
addons:
apt:
packages:
- libxml2-utils
script:
# Check the code style of the code base.
- composer check-cs
# Validate the xml file.
# @link http://xmlsoft.org/xmllint.html
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./PHPCSDebug/ruleset.xml
# Check the code-style consistency of the xml files.
- diff -B ./PHPCSDebug/ruleset.xml <(xmllint --format "./PHPCSDebug/ruleset.xml")
# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- composer validate --no-check-all --strict
#### QUICK TEST STAGE ####
# This is a much quicker test which only runs the unit tests and linting against the low/high
# supported PHP/PHPCS combinations.
- stage: quicktest
php: 7.4
env: PHPCS_VERSION="dev-master" LINT=1
- stage: quicktest
php: 7.2
env: PHPCS_VERSION="3.0.2"
- stage: quicktest
php: 5.4
env: PHPCS_VERSION="dev-master" LINT=1
- stage: quicktest
php: 5.4
env: PHPCS_VERSION="3.0.2"
#### TEST STAGE ####
# Additional builds to prevent issues with PHPCS versions incompatible with certain PHP versions.
- stage: test
php: 7.3
env: PHPCS_VERSION="dev-master" LINT=1
# PHPCS is only compatible with PHP 7.3 as of version 3.3.1.
- php: 7.3
env: PHPCS_VERSION="3.3.1"
- php: 7.4
env: PHPCS_VERSION="dev-master"
# PHPCS is only compatible with PHP 7.4 as of version 3.5.0.
- php: 7.4
env: PHPCS_VERSION="3.5.0"
# Builds against unstable versions which are allowed to fail for now.
- stage: test
php: 7.4
env: PHPCS_VERSION="4.0.x-dev"
- php: "nightly"
env: PHPCS_VERSION="dev-master" LINT=1
allow_failures:
# Allow failures for unstable builds.
- php: "nightly"
- env: PHPCS_VERSION="4.0.x-dev"
before_install:
# Speed up build time by disabling Xdebug when its not needed.
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
# On stable PHPCS versions, allow for PHP deprecation notices.
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
- |
if [[ "${TRAVIS_BUILD_STAGE_NAME^}" != "Sniff" && "$PHPCS_VERSION" != "dev-master" && "$PHPCS_VERSION" != "4.0.x-dev" ]]; then
echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
fi
- export XMLLINT_INDENT=" "
# Set up test environment using Composer.
- |
if [[ "${TRAVIS_BUILD_STAGE_NAME^}" != "Sniff" ]]; then
# Remove the PHPCSDevCS dependency as it has different PHPCS requirements and would block installs.
composer remove --dev phpcsstandards/phpcsdevcs --no-update --no-scripts
fi
- |
if [[ $PHPCS_VERSION != "n/a" ]]; then
composer require --no-update --no-scripts squizlabs/php_codesniffer:${PHPCS_VERSION}
fi
- |
if [[ "${TRAVIS_BUILD_STAGE_NAME^}" == "Sniff" ]]; then
# The sniff stage doesn't run the unit tests, so no need for PHPUnit.
composer remove --dev phpunit/phpunit --no-update --no-scripts
elif [[ "$PHPCS_VERSION" < "3.1.0" ]]; then
# PHPCS < 3.1.0 is not compatible with PHPUnit 6.x.
composer require --dev phpunit/phpunit:"^4.0||^5.0" --no-update --no-scripts
elif [[ "$PHPCS_VERSION" < "3.2.3" ]]; then
# PHPCS < 3.2.3 is not compatible with PHPUnit 7.x.
composer require --dev phpunit/phpunit:"^4.0||^5.0||^6.0" --no-update --no-scripts
fi
# --prefer-dist will allow for optimal use of the travis caching ability.
# The Composer PHPCS plugin takes care of setting the installed_paths for PHPCS.
- |
if [[ $TRAVIS_PHP_VERSION == "nightly" ]]; then
# Not all dependencies allow for installing on nightly yet, so ignore platform requirements.
composer install --prefer-dist --no-suggest --ignore-platform-reqs
elif [[ "$PHPCS_VERSION" == "4.0.x-dev" ]]; then
# PHPCS 4.x does not ship by default with the base test case, so source is needed.
composer install --prefer-source --no-suggest
else
composer install --prefer-dist --no-suggest
fi
script:
# Lint PHP files against parse errors.
- if [[ "$LINT" == "1" ]]; then composer lint; fi
# Check that any sniffs available are feature complete.
# This also acts as an integration test for the feature completeness script,
# which is why it is run against various PHP versions and not in the "Sniff" stage.
- if [[ "$LINT" == "1" ]]; then composer check-complete; fi
# Run the unit tests.
- if [[ $PHPCS_VERSION != "n/a" ]]; then composer run-tests; fi