|
1 | 1 | #!/bin/bash
|
2 | 2 |
|
3 | 3 | ls "$HOME/.cache/"
|
| 4 | + |
| 5 | +PYX_CACHE_DIR="$HOME/.cache/pyxfiles" |
| 6 | +pyx_file_list=`find ${TRAVIS_BUILD_DIR} -name "*.pyx"` |
4 | 7 | CACHE_File="$HOME/.cache/cython_files.tar"
|
5 | 8 |
|
6 | 9 | clear_cache=0
|
7 | 10 | home_dir=$(pwd)
|
8 | 11 |
|
9 |
| -if [ -f "$CACHE_File" ] && [ "$USE_CACHE" ]; then |
| 12 | +if [ -f "$CACHE_File" ] && [ "$USE_CACHE" ] && [ -d "$PYX_CACHE_DIR" ]; then |
| 13 | + |
| 14 | + echo "Cache available - checking pyx diff" |
| 15 | + |
| 16 | + for i in ${pyx_file_list} |
| 17 | + do |
| 18 | + diff=`diff -u $i $PYX_CACHE_DIR${i}` |
| 19 | + if [[ $? -ne 0 ]] |
| 20 | + then |
| 21 | + echo "${i##*/} can't be diffed; probably not in cache" |
| 22 | + clear_cache=1 |
| 23 | + fi |
| 24 | + if [[ ! -z $diff ]] |
| 25 | + then |
| 26 | + echo "${i##*/} has changed:" |
| 27 | + echo $diff |
| 28 | + clear_cache=1 |
| 29 | + fi |
| 30 | + done |
10 | 31 |
|
11 |
| - echo "Cache available" |
12 |
| - clear_cache=1 |
13 |
| - # did the last commit change cython files? |
14 |
| - # go back 2 commits |
15 | 32 | if [ "$TRAVIS_PULL_REQUEST" == "false" ]
|
16 | 33 | then
|
17 |
| - echo "Not a PR: checking for cython files changes from last 2 commits" |
18 |
| - git diff HEAD~2 --numstat | grep -E "pyx|pxd" |
19 |
| - retval=$(git diff HEAD~2 --numstat | grep -E "pyx|pxd"| wc -l) |
| 34 | + echo "Not a PR" |
| 35 | + # Uncomment next 2 lines to turn off cython caching not in a PR |
| 36 | + # echo "Non PR cython caching is disabled" |
| 37 | + # clear_cache=1 |
20 | 38 | else
|
21 |
| - echo "PR: checking for any cython file changes from last 5 commits" |
22 |
| - git diff PR_HEAD~5 --numstat | grep -E "pyx|pxd" |
23 |
| - retval=$(git diff PR_HEAD~5 --numstat | grep -E "pyx|pxd"| wc -l) |
| 39 | + echo "In a PR" |
| 40 | + # Uncomment next 2 lines to turn off cython caching in a PR |
| 41 | + # echo "PR cython caching is disabled" |
| 42 | + # clear_cache=1 |
24 | 43 | fi
|
25 |
| - echo "number of cython files changed: $retval" |
| 44 | + |
26 | 45 | fi
|
27 | 46 |
|
28 |
| -if [ $clear_cache -eq 1 ] && [ $retval -eq 0 ] && [ "$USE_CACHE" ] |
| 47 | +if [ $clear_cache -eq 1 ] && [ "$USE_CACHE" ] |
29 | 48 | then
|
30 | 49 | # nope, reuse cython files
|
31 | 50 | echo "Will reuse cached cython file"
|
|
0 commit comments