Skip to content

Commit c59a73d

Browse files
committed
Merge pull request #85 from LionsAd/test-cache
Try to use caching
2 parents 070f62f + 3692def commit c59a73d

File tree

1 file changed

+54
-13
lines changed

1 file changed

+54
-13
lines changed

.travis.yml

+54-13
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,28 @@ php:
1515
- 5.4
1616
- 5.5
1717
- 5.6
18+
- 7
1819
- hhvm
1920

2021
branches:
2122
only:
2223
- "7.x-1.x"
2324
- "8.x-1.x"
25+
26+
cache:
27+
apt: true
28+
directories:
29+
- $HOME/drupal-ti-cache
2430

2531
matrix:
2632
fast_finish: true
2733
allow_failures:
28-
- php: 5.6
2934
- php: hhvm
30-
exclude:
35+
- php: 7
36+
include:
3137
# Don't need to test twice on all versions, PHP 5.4 is enough.
32-
- php: 5.3
33-
env: DRUPAL_TI_RUNNERS="phpunit"
34-
- php: 5.5
35-
env: DRUPAL_TI_RUNNERS="phpunit"
36-
- php: 5.6
37-
env: DRUPAL_TI_RUNNERS="phpunit"
38-
- php: hhvm
39-
env: DRUPAL_TI_RUNNERS="phpunit"
38+
- php: 5.4
39+
env: DRUPAL_TI_RUNNERS="phpunit" DRUPAL_TI_SAVE_CACHE="0"
4040

4141
env:
4242
global:
@@ -66,8 +66,21 @@ env:
6666
# Debug options
6767
#- DRUPAL_TI_DEBUG="-x -v"
6868

69+
# Cache options
70+
# Use this variable to use another cache directory, usually not needed to be changed.
71+
- DRUPAL_TI_CACHE_DIR="$HOME/drupal-ti-cache/"
72+
# Set to 0 or comment out to disable cache loading.
73+
- DRUPAL_TI_LOAD_CACHE="1"
74+
# Set to 0 to disable cache saving, useful with many variants.
75+
# Note: Setting this to "0" will remove the .casher directory to
76+
# avoid race conditions between builds.
77+
- DRUPAL_TI_SAVE_CACHE="1"
78+
# Setup dirs to cache relative to another environment variable.
79+
- DRUPAL_TI_CACHE_DIRS_HOME=".composer|.drush|.dist"
80+
- DRUPAL_TI_CACHE_DIRS_TRAVIS_BUILD_DIR="tests/vendor"
81+
6982
matrix:
70-
- DRUPAL_TI_RUNNERS="phpunit"
83+
#- DRUPAL_TI_RUNNERS="phpunit"
7184
- DRUPAL_TI_RUNNERS="phpunit simpletest"
7285

7386
mysql:
@@ -76,9 +89,22 @@ mysql:
7689
encoding: utf8
7790

7891
before_install:
79-
- cd ./tests
92+
# Restore home directory from cache.
93+
- mkdir -p "$DRUPAL_TI_CACHE_DIR"/HOME
94+
- if [ "$DRUPAL_TI_LOAD_CACHE" = "1" ]; then rsync -a "$DRUPAL_TI_CACHE_DIR"/HOME/ "$HOME/"; fi
95+
96+
# Update composer
8097
- composer self-update
81-
- composer global require "lionsad/drupal_ti:dev-master"
98+
99+
# Download drupal_ti - if not cached
100+
- if [ -f "$HOME/.composer/vendor/bin/drupal-ti" ]; then composer global install; else composer global require "lionsad/drupal_ti:dev-master"; fi
101+
102+
# Restore caches from $DRUPAL_TI_CACHE_DIR/TRAVIS_BUILD_DIR to $TRAVIS_BUILD_DIR
103+
# Note: HOME dir was already synced manually above.
104+
- drupal-ti --load-cache TRAVIS_BUILD_DIR
105+
106+
# Setup tests
107+
- cd ./tests
82108
- drupal-ti before_install
83109

84110
install:
@@ -90,6 +116,21 @@ before_script:
90116
script:
91117
- drupal-ti script
92118

119+
# Syncs $DRUPAL_TI_CACHE_DIRS_{*} to $DRUPAL_TI_CACHE_DIR/{*}
120+
# Has internal optimizations for .composer and .drush.
121+
- drupal-ti --save-cache TRAVIS_BUILD_DIR HOME
122+
123+
# Do some manual caching as well
124+
- if [ "$DRUPAL_TI_SAVE_CACHE" = "1" ]; then rsync -a composer.{json,lock} "$DRUPAL_TI_CACHE_DIR"/TRAVIS_BUILD_DIR/tests/; fi
125+
126+
# Delete composer generated files that screw up cache detection.
127+
- rm -f "$DRUPAL_TI_CACHE_DIR"/TRAVIS_BUILD_DIR/tests/.composer/vendor/composer/*.php
128+
- rm -f "$DRUPAL_TI_CACHE_DIR"/TRAVIS_BUILD_DIR/tests/.composer/vendor/autoload.php
129+
130+
# Tests for differences and touches a file if any are detected (optional).
131+
- du -sh "$DRUPAL_TI_CACHE_DIR"
132+
- drupal-ti --sync-cache
133+
93134
after_script:
94135
- drupal-ti after_script
95136

0 commit comments

Comments
 (0)