/
.travis.yml
220 lines (186 loc) · 6.75 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
os: linux
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
- /home/travis/.rvm/
php:
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- "nightly"
env:
- PHPCS_VERSION="dev-master" LINT=1
- PHPCS_VERSION="3.1.0"
- PHPCS_VERSION="2.9.2"
- PHPCS_VERSION="2.6.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, "develop" is the base branch name.
# See: https://docs.travis-ci.com/user/conditions-v1
stages:
- name: sniff
- name: docs
if: branch IN (master)
- 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.4
env: PHPCS_VERSION="dev-master"
addons:
apt:
packages:
- libxml2-utils
install: skip
script:
# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- composer validate --no-check-all --strict
# Check the code style of the code base.
- composer travis-checkcs
# Validate the xml files.
# @link http://xmlsoft.org/xmllint.html
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./PHPCSUtils/ruleset.xml
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./PHPCS23Utils/ruleset.xml
# Check the code-style consistency of the xml files.
- diff -B ./PHPCSUtils/ruleset.xml <(xmllint --format "./PHPCSUtils/ruleset.xml")
- diff -B ./PHPCS23Utils/ruleset.xml <(xmllint --format "./PHPCS23Utils/ruleset.xml")
after_success: skip
#### DOCUMENTATION SITE TESTING STAGE ####
- stage: docs
language: ruby
cache: bundler
rvm: 2.5.8
before_install: skip
install:
- cd ./docs
- gem install bundler
- bundle install
before_script: skip
script:
# Test the documentation generation.
- bundle exec jekyll build
after_success: skip
#### 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
- stage: quicktest
php: 7.3
# PHPCS is only compatible with PHP 7.3 as of version 3.3.1/2.9.2.
env: PHPCS_VERSION="2.9.2"
- stage: quicktest
php: 5.4
env: PHPCS_VERSION="dev-master" LINT=1
- stage: quicktest
php: 5.4
env: PHPCS_VERSION="2.6.0"
#### 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
- php: 7.3
# PHPCS is only compatible with PHP 7.3 as of version 3.3.1/2.9.2.
env: PHPCS_VERSION="3.3.1"
- php: 5.4
env: PHPCS_VERSION="3.1.0"
- php: 5.4
env: PHPCS_VERSION="2.9.2"
# PHPCS is only compatible with PHP 7.4 as of version 3.5.0.
- php: 7.4
env: PHPCS_VERSION="3.5.0"
# One extra build to verify issues around PHPCS annotations when they weren't fully accounted for yet.
- php: 7.2
env: PHPCS_VERSION="3.2.0"
- php: 7.4
env: PHPCS_VERSION="4.0.x-dev@dev"
#### 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 script used is the default script below, the same as for the `test` stage.
- stage: coverage
php: 7.4
env: PHPCS_VERSION="dev-master" LINT=1 COVERALLS_VERSION="^2.0"
- php: 7.3
# PHPCS is only compatible with PHP 7.3 as of version 3.3.1/2.9.2.
env: PHPCS_VERSION="2.9.2" COVERALLS_VERSION="^2.0"
- php: 5.4
env: PHPCS_VERSION="dev-master" LINT=1 COVERALLS_VERSION="^1.0"
- php: 5.4
env: PHPCS_VERSION="2.6.0" COVERALLS_VERSION="^1.0"
allow_failures:
# Allow failures for unstable builds.
- php: "nightly"
- env: PHPCS_VERSION="4.0.x-dev@dev"
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
- export XMLLINT_INDENT=" "
install:
# Set up test environment using Composer.
- composer require --no-update --no-scripts squizlabs/php_codesniffer:${PHPCS_VERSION}
- |
if [[ "${TRAVIS_BUILD_STAGE_NAME^}" == "Coverage" ]]; then
composer require --dev --no-update --no-suggest --no-scripts php-coveralls/php-coveralls:${COVERALLS_VERSION}
fi
- |
if [[ "${TRAVIS_BUILD_STAGE_NAME^}" == "Sniff" ]]; then
# Don't install PHPUnit when it's not needed.
composer remove --dev phpunit/phpunit --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.
- composer install --prefer-dist --no-suggest
before_script:
- if [[ "${TRAVIS_BUILD_STAGE_NAME^}" == "Coverage" ]]; then mkdir -p build/logs; fi
- phpenv rehash
script:
# Lint PHP files against parse errors.
- if [[ "$LINT" == "1" ]]; then composer lint; fi
# Run the unit tests.
- |
if [[ "${TRAVIS_BUILD_STAGE_NAME^}" != "Coverage" ]]; then
composer test
elif [[ "${TRAVIS_BUILD_STAGE_NAME^}" == "Coverage" ]]; then
composer coverage
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