Skip to content

Commit 7456379

Browse files
committed
Travis: add initial CI check
* Validate the `composer.json` file. * Validate the XML ruleset files against the PHPCS XSD schema. * Verify the XML xode style consistency of the ruleset files. * Run PHP linter over all PHP files.
1 parent 616d6d4 commit 7456379

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

.travis.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
dist: trusty
2+
3+
language: php
4+
5+
## Cache composer and apt downloads.
6+
cache:
7+
apt: true
8+
directories:
9+
# Cache directory for older Composer versions.
10+
- $HOME/.composer/cache/files
11+
# Cache directory for more recent Composer versions.
12+
- $HOME/.cache/composer/files
13+
14+
php:
15+
- 5.4
16+
- 7.4
17+
- "nightly"
18+
19+
# Define the stages used.
20+
stages:
21+
- name: sniff
22+
- name: test
23+
24+
jobs:
25+
fast_finish: true
26+
27+
include:
28+
#### SNIFF STAGE ####
29+
- stage: sniff
30+
php: 7.4
31+
addons:
32+
apt:
33+
packages:
34+
- libxml2-utils
35+
script:
36+
# Validate the composer.json file.
37+
# @link https://getcomposer.org/doc/03-cli.md#validate
38+
- composer validate --no-check-all --strict
39+
40+
# Validate the xml files.
41+
# @link http://xmlsoft.org/xmllint.html
42+
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./Security/ruleset.xml
43+
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./example_base_ruleset.xml
44+
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./example_drupal7_ruleset.xml
45+
46+
# Check the code-style consistency of the xml files.
47+
- diff -B ./Security/ruleset.xml <(xmllint --format "./Security/ruleset.xml")
48+
- diff -B ./example_base_ruleset.xml <(xmllint --format "./example_base_ruleset.xml")
49+
- diff -B ./example_drupal7_ruleset.xml <(xmllint --format "./example_drupal7_ruleset.xml")
50+
51+
allow_failures:
52+
# Allow failures for unstable builds.
53+
- php: "nightly"
54+
55+
before_install:
56+
# Speed up build time by disabling Xdebug when its not needed.
57+
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
58+
59+
- export XMLLINT_INDENT=" "
60+
61+
# --prefer-dist will allow for optimal use of the travis caching ability.
62+
- composer install --prefer-dist --no-suggest
63+
64+
script:
65+
# Lint PHP files against parse errors.
66+
- composer lint

0 commit comments

Comments
 (0)