Skip to content

Commit 6cc3d6e

Browse files
committed
Diff python pyx files as a test if they have changed
1 parent bf4786a commit 6cc3d6e

File tree

2 files changed

+41
-16
lines changed

2 files changed

+41
-16
lines changed

ci/prep_cython_cache.sh

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,50 @@
11
#!/bin/bash
22

33
ls "$HOME/.cache/"
4+
5+
PYX_CACHE_DIR="$HOME/.cache/pyxfiles"
6+
pyx_file_list=`find ${TRAVIS_BUILD_DIR} -name "*.pyx"`
47
CACHE_File="$HOME/.cache/cython_files.tar"
58

69
clear_cache=0
710
home_dir=$(pwd)
811

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
1031

11-
echo "Cache available"
12-
clear_cache=1
13-
# did the last commit change cython files?
14-
# go back 2 commits
1532
if [ "$TRAVIS_PULL_REQUEST" == "false" ]
1633
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
2038
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
2443
fi
25-
echo "number of cython files changed: $retval"
44+
2645
fi
2746

28-
if [ $clear_cache -eq 1 ] && [ $retval -eq 0 ] && [ "$USE_CACHE" ]
47+
if [ $clear_cache -eq 1 ] && [ "$USE_CACHE" ]
2948
then
3049
# nope, reuse cython files
3150
echo "Will reuse cached cython file"

ci/submit_cython_cache.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
#!/bin/bash
22

33
CACHE_File="$HOME/.cache/cython_files.tar"
4+
PYX_CACHE_DIR="$HOME/.cache/pyxfiles"
5+
pyx_file_list=`find ${TRAVIS_BUILD_DIR} -name "*.pyx"`
6+
47
rm -rf $CACHE_File
8+
rm -rf $PYX_CACHE_DIR
59

610
home_dir=$(pwd)
711

8-
pyx_files=`find ${TRAVIS_BUILD_DIR} -name "*.pyx"`
12+
mkdir $PYX_CACHE_DIR
13+
rsync -Rv $pyx_file_list $PYX_CACHE_DIR
14+
915
echo "pyx files:"
10-
echo $pyx_files
16+
echo $pyx_file_list
1117

1218
tar cf ${CACHE_File} --files-from /dev/null
1319

14-
for i in ${pyx_files}
20+
for i in ${pyx_file_list}
1521
do
1622
f=${i%.pyx}
1723
ls $f.{c,cpp} | tar rf ${CACHE_File} -T -

0 commit comments

Comments
 (0)