-
Notifications
You must be signed in to change notification settings - Fork 84
/
.travis.yml
140 lines (119 loc) · 4.4 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
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.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
env:
jobs:
# `master`
- PHPCS_VERSION="dev-master" LINT=1
# Lowest supported PHPCS version.
- PHPCS_VERSION="3.1.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 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)
- name: test
if: branch IN (master)
jobs:
fast_finish: true
include:
#### SNIFF STAGE ####
- stage: sniff
php: 7.4
addons:
apt:
packages:
- libxml2-utils
script:
# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- composer validate --no-check-all --strict
# Validate the xml files.
# @link http://xmlsoft.org/xmllint.html
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./Security/ruleset.xml
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./example_base_ruleset.xml
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./example_drupal7_ruleset.xml
# Check the code-style consistency of the xml files.
- diff -B ./Security/ruleset.xml <(xmllint --format "./Security/ruleset.xml")
- diff -B ./example_base_ruleset.xml <(xmllint --format "./example_base_ruleset.xml")
- diff -B ./example_drupal7_ruleset.xml <(xmllint --format "./example_drupal7_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.
- stage: quicktest
php: 7.4
env: PHPCS_VERSION="dev-master" LINT=1
- php: 7.2
# PHP 7.3 is only supported since PHPCS 3.3.1, PHP 7.4 since PHPCS 3.5.0, so running low against PHP 7.2.
env: PHPCS_VERSION="3.1.0"
- php: 5.4
env: PHPCS_VERSION="dev-master" LINT=1
- php: 5.4
env: PHPCS_VERSION="3.1.0"
#### TEST STAGE ####
# Additional builds to prevent issues with PHPCS versions incompatible with certain PHP versions.
# PHP 7.3 is only supported since PHPCS 3.3.1, PHP 7.4 since PHPCS 3.5.0.
- stage: test
php: 7.4
env: PHPCS_VERSION="dev-master" LINT=1
- php: 7.4
env: PHPCS_VERSION="3.5.0"
- php: 7.3
env: PHPCS_VERSION="dev-master" LINT=1
- php: 7.3
env: PHPCS_VERSION="3.3.1"
- php: "nightly"
env: PHPCS_VERSION="n/a" LINT=1
allow_failures:
# Allow failures for unstable builds.
- php: "nightly"
before_install:
# Speed up build time by disabling Xdebug when its not needed.
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
- export XMLLINT_INDENT=" "
# 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_BRANCH != "dev-master" && "$PHPCS_VERSION" != "n/a" ]]; then
echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
fi
install:
# Set up test environment using Composer.
- |
if [[ $PHPCS_VERSION != "n/a" ]]; then
composer require --no-update --no-scripts squizlabs/php_codesniffer:${PHPCS_VERSION}
fi
- |
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Sniff" || $PHPCS_VERSION == "n/a" ]]; then
# The sniff stage doesn't run the unit tests, so no need for PHPUnit.
# The build on nightly also doesn't run the tests (yet).
composer remove --dev phpunit/phpunit --no-update --no-scripts
fi
# --prefer-dist will allow for optimal use of the travis caching ability.
- composer install --prefer-dist --no-suggest
script:
# Lint PHP files against parse errors.
- if [[ "$LINT" == "1" ]]; then composer lint; fi
# Run the unit tests.
- |
if [[ $PHPCS_VERSION != "n/a" ]]; then
composer test
fi