forked from PHPCompatibility/PHPCompatibility
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
221 lines (198 loc) · 7.37 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
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
php:
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
env:
global:
- PHPUNIT_VERSION="travis"
matrix:
# `master`, i.e PHPCS 3.x.
- PHPCS_VERSION="dev-master" LINT=1
# Lowest supported PHPCS version.
- PHPCS_VERSION="2.3.0"
# 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, "master" is (currently) 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 (master, develop)
- name: test
if: branch IN (master, develop)
- name: coverage
if: branch IN (master, develop)
jobs:
fast_finish: true
include:
#### SNIFF STAGE ####
- stage: sniff
php: 7.3
env: PHPCS_VERSION="dev-master"
addons:
apt:
packages:
- libxml2-utils
script:
# Check the code style of the code base.
- vendor/bin/phpcs
# Validate the xml file.
# @link http://xmlsoft.org/xmllint.html
- xmllint --noout ./PHPCompatibility/ruleset.xml
# Check the code-style consistency of the xml files.
- diff -B ./PHPCompatibility/ruleset.xml <(xmllint --format "./PHPCompatibility/ruleset.xml")
#### 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.
# These are basically the same builds as in the Coverage stage, but then without doing
# the code-coverage.
- stage: quicktest
php: 7.4
env: PHPCS_VERSION="dev-master" LINT=1
- php: 7.3
env: PHPCS_VERSION="2.3.0"
# PHP 7.3+ is only fully supported icw PHPCS 2.9.2 and 3.3.1+.
- php: 7.2
env: PHPCS_VERSION="3.0.2" LINT=1
# PHPCS 3.x cannot be run on PHP 5.3.
- php: 5.4
env: PHPCS_VERSION="dev-master" LINT=1
- php: 5.3
dist: precise
env: PHPCS_VERSION=">=2.0,<3.0" LINT=1
- php: 5.3
dist: precise
env: PHPCS_VERSION="2.3.0"
#### TEST STAGE ####
# In addition to the matrix defined above, test against a variation of PHPCS 2.x and 3.x versions.
- stage: test
php: 5.4
env: PHPCS_VERSION="2.3.0" LINT=1
- php: 5.5
env: PHPCS_VERSION="2.4.*"
- php: 5.5
env: PHPCS_VERSION="3.2.*"
- php: 5.6
env: PHPCS_VERSION="2.8.*"
- php: 7.0
env: PHPCS_VERSION="2.6.*"
- php: 7.1
env: PHPCS_VERSION="2.7.*"
- php: 7.2
env: PHPCS_VERSION="3.3.*"
# Note: PHP 7.3+ is only fully supported icw PHPCS 2.9.2 and 3.3.1+.
# While on PHPCS 2.x, the tests won't fail, on PHPCS 3.x < 3.3.1, they will.
- php: 7.3
env: PHPCS_VERSION="3.4.*" LINT=1
- php: 7.3
env: PHPCS_VERSION="dev-master"
- php: 7.4
env: PHPCS_VERSION=">=2.0,<3.0" LINT=1
- php: 7.4
env: PHPCS_VERSION="2.3.0"
#### CODE COVERAGE STAGE ####
# N.B.: Coverage is only checked on the lowest and highest stable PHP versions for all PHPCS versions.
# These builds are left out off the "test" stage so as not to duplicate test runs.
#
# The `CUSTOM_INI` configuration is used to allow testing with different PHP ini settings.
# Added against one high/high and one low/medium build, though having separate builds for this
# would be preferred.
# Docs: https://docs.travis-ci.com/user/languages/php/#custom-php-configuration
- stage: coverage
php: 7.4
env: PHPCS_VERSION="dev-master" COVERALLS_VERSION="^2.0" CUSTOM_INI=1
- php: 7.3
env: PHPCS_VERSION="2.3.0" COVERALLS_VERSION="^2.0"
# PHP 7.3+ is only fully supported icw PHPCS 2.9.2 and 3.3.1+.
- php: 7.2
env: PHPCS_VERSION="3.0.2" COVERALLS_VERSION="^2.0"
# PHPCS 3.x cannot be run on PHP 5.3.
- php: 5.4
env: PHPCS_VERSION="dev-master" COVERALLS_VERSION="^1.0"
- php: 5.3
dist: precise
env: PHPCS_VERSION=">=2.0,<3.0" LINT=1 COVERALLS_VERSION="^1.0" CUSTOM_INI=1
- php: 5.3
dist: precise
env: PHPCS_VERSION="2.3.0" COVERALLS_VERSION="^1.0"
before_install:
# Speed up build time by disabling Xdebug when its not needed.
- |
if [[ "$TRAVIS_BUILD_STAGE_NAME" != "Coverage" ]]; then
phpenv config-rm xdebug.ini || echo 'No xdebug config.'
fi
# 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" ]]; then
echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
fi
# Allow for testing with different PHP ini configurations.
- |
if [[ "$CUSTOM_INI" == 1 ]]; then
echo 'short_open_tag = On' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
fi
- php -r "echo ini_get('short_open_tag');"
- export XMLLINT_INDENT=" "
# Toggle the PHPUnit versions if necessary, depending on the known Travis configurations.
- if [[ ${TRAVIS_PHP_VERSION:0:3} > "7.1" ]]; then export PHPUNIT_VERSION="^7.0"; fi
- if [[ ${TRAVIS_PHP_VERSION:0:3} < "5.5" ]]; then export PHPUNIT_VERSION="~4.5"; fi
# Set up test environment using Composer.
- composer require --no-update squizlabs/php_codesniffer:${PHPCS_VERSION}
- |
if [[ "$TRAVIS_BUILD_STAGE_NAME" != "Sniff" && $PHPUNIT_VERSION != "travis" ]]; then
composer require --no-update phpunit/phpunit:${PHPUNIT_VERSION}
fi
- |
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" ]]; then
composer require --no-update php-coveralls/php-coveralls:${COVERALLS_VERSION}
fi
# --no-dev makes sure the Travis provided version of PHPUnit is used whenever possible for better stability.
# --prefer-dist will allow for optimal use of the travis caching ability.
- composer install --no-dev --prefer-dist --no-suggest
before_script:
- if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" ]]; then mkdir -p build/logs; fi
- phpenv rehash
script:
# Lint all PHP files against parse errors.
- |
if [[ "$LINT" == "1" ]]; then
if find -L . -path ./vendor -prune -o -path ./PHPCompatibility/Tests/Keywords/ForbiddenNames -prune -o -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi
fi
# Run the unit tests.
- |
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Quicktest" || "$TRAVIS_BUILD_STAGE_NAME" == "Test" ]]; then
if [[ $PHPUNIT_VERSION == "travis" ]]; then
phpunit --no-coverage
else
vendor/bin/phpunit --no-coverage
fi
elif [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" ]]; then
if [[ $PHPUNIT_VERSION == "travis" ]]; then
phpunit
else
vendor/bin/phpunit
fi
fi
after_success:
- |
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" && $COVERALLS_VERSION == "^1.0" ]]; then
php vendor/bin/coveralls -v -x build/logs/clover.xml
fi
- |
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" && $COVERALLS_VERSION == "^2.0" ]]; then
php vendor/bin/php-coveralls -v -x build/logs/clover.xml
fi