Skip to content

Commit 51eda65

Browse files
committed
PHPCS: enable caching between runs
Since PHPCS 3.0.0, PHPCS has a caching feature available. In this PR, this caching feature is now turned on for this repo. This means in effect that the very first run of PHPCS with this feature will be marginally slower (on any individual machine). Most runs _after_ that though, will be significantly faster as PHPCS will only scan the files which have changed since the previous run. The cache will automatically be invalidated and rebuild whenever relevant, like when the version of one of the PHPCS dependencies has changed or when PHPCS itself has been changed. To (temporarily) turn caching off, run PHPCS like so: ```bash composer check-cs -- --no-cache ``` The cache file is set to be saved to a `.cache` directory to allow Travis to benefit from this feature as well. As this directory _has_ to exist for the cache file to be written to it, it is created and committed to the repo with a `.gitkeep` file Commit details: `/.cache/` directory: * Create the directory and place a `.gitkeep` file in it to allow it to be committed. PHPCS config file: * Enable the caching feature to a fixed file called `/.cache/phpcs.cache`. `.gitignore`: * Prevent committing of the cache file. `.gitattributes`: * Do not include the `.cache` directory in distributable archives. Travis: * Use the Travis caching feature to cache the new `.cache` directory (including the cache file) between runs to allow Travis to benefit from the PHPCS caching as well.
1 parent 2cc9a64 commit 51eda65

5 files changed

Lines changed: 7 additions & 0 deletions

File tree

.cache/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This directory has to exist to allow cache files to be written to it.

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# https://www.reddit.com/r/PHP/comments/2jzp6k/i_dont_need_your_tests_in_my_production
66
# https://blog.madewithlove.be/post/gitattributes/
77
#
8+
.cache export-ignore
89
.github export-ignore
910
grunt export-ignore
1011
tests export-ignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ nightwatch.conf.js
99

1010
phpcs.xml
1111
.phpcs.xml
12+
.cache/phpcs.cache
1213
phpunit.xml

.phpcs.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
<!-- Check up to 8 files simultaneously. -->
3030
<arg name="parallel" value="8"/>
3131

32+
<!-- Cache the results between runs. -->
33+
<arg name="cache" value="./.cache/phpcs.cache"/>
34+
3235

3336
<!--
3437
#############################################################################

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ dist: trusty
44
cache:
55
yarn: true
66
directories:
7+
- .cache
78
- vendor
89
# Cache directory for older Composer versions.
910
- $HOME/.composer/cache/files

0 commit comments

Comments
 (0)