-
Notifications
You must be signed in to change notification settings - Fork 11
/
ci-cov-repos
executable file
·71 lines (55 loc) · 1.22 KB
/
ci-cov-repos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# ENTRY POINT (done)
set -e
project="$1"
branch="$2"
if [ -n "$3" ]; then
extraver="/$3"
fi
if [ -z "$project" ]; then
echo "no project specificed"
exit 1
fi
covdir=/var/www/ci.kronosnet.org/coverity
clean_dirs() {
echo "Purging 0 byte files"
find $covdir/ -type f -size 0 -print -delete
echo "Purging empty dirs"
find $covdir/ -type d -empty -print -delete
}
clean_prs() {
echo "Purging old prs data"
cd $covdir/$project/
find . -maxdepth 2 -type d -mtime +30 -name "pr*" -exec rm -rf {} \;
}
process_builds() {
# remove old builds (keep last 10)
builds="$(ls -1 | sort -n)"
numbuilds="$(echo "$builds" | wc -l)"
if [ "$numbuilds" -gt 10 ]; then
purgenum=$((numbuilds - 10))
candidates="$(echo "$builds" | head -n $purgenum)"
for candidate in $candidates; do
echo "Removing old build: $candidate"
rm -rf $candidate
done
fi
}
process_cov_repos() {
cd $covdir/$project/
# we are in project dir
for node in $(ls); do
echo "Node $node / $branch / $extraver"
cd ${node}/${branch}/${extraver}
process_builds
cd $covdir/$project/
done
}
(
flock -e 200
clean_dirs
process_cov_repos
clean_prs
rsync -av --delete-after $covdir/ jweb:$covdir/.
exit 0
) 200>/tmp/ci-cov-repos.lock