Skip to content

Commit 0bd591e

Browse files
authored
add cleanup of >30 day old test data from DNAnexus CI project (#280)
add cleanup of >30 day old test data from DNAnexus CI project , using code from @yihchii in #178 ; adding here rather than on the fork so the DX API token is set
1 parent 8fd2e95 commit 0bd591e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

travis/tests-dx.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,22 @@ echo -e "${demux_name}_launcher\t$demux_launcher_id\t$dx_job_id" >> $TEST_LAUNCH
9898

9999
# the presence of this file in the project denotes all tests launched
100100
dx upload --brief --no-progress --destination /build/$VERSION/ $TEST_LAUNCH_ALL
101+
102+
#
103+
# Cleanup folders w/ files that are 30 days old (@yihchii)
104+
#
105+
THIRTY_DAYS_FILES="30d_old_files.json"
106+
dx find data --class file --created-before=-30d --path=/tests/ --json > $THIRTY_DAYS_FILES
107+
[ "$(cat $THIRTY_DAYS_FILES)" != "[]" ] && dx rm -r -f $(jq -r '(.[].describe.folder + "/")' $THIRTY_DAYS_FILES | sort -u)
108+
rm -rf $THIRTY_DAYS_FILES
109+
110+
# Cleanup empty folders
111+
# - Loop over all versioned sub-folders and clean them up if they are empty
112+
ALL_VERSION_FOLDERS="all_version_folders.txt"
113+
CURRENT_FOLDER="/tests/$VERSION/"
114+
dx ls --folders --full $(dirname $CURRENT_FOLDER) > $ALL_VERSION_FOLDERS
115+
for folder in $(cat $ALL_VERSION_FOLDERS); do
116+
content=$(dx find data --path $folder --brief)
117+
[ -z "$content" ] && dx rm -rf $folder
118+
done
119+
rm -rf $ALL_VERSION_FOLDERS

0 commit comments

Comments
 (0)