Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 125 lines (93 sloc) 3.089 kb
855f7e3 first version
Alexis Sukrieh authored
1 #!/bin/bash
2
3 set -e
4 source ./capsule.conf
5
6 # init
7
8 LOCKFILE="/tmp/autobuilder.lock"
9 LOCK_FILE_IS_FOUND=42
10 ORIGIN=$(pwd)
11 BUILDDIR=$(mktemp -d "/tmp/${CAPSULE_PROJECT}-autobuild.XXXXXX")
12
13 # subs
14
15 function on_exit() {
16 exit_code=$?
48f9c1f remove buildir on exit, no matter what happens
Alexis Sukrieh authored
17 rm -rf $BUILDDIR
18
855f7e3 first version
Alexis Sukrieh authored
19 if [[ $exit_code -gt 0 ]]; then
20
21 if [[ $exit_code == $LOCK_FILE_IS_FOUND ]]; then
22 echo "Lock file detected, skipping."
23 else
24 echo "FAILURE during processing of $project @'$branch'" >&2
25 mv $logfile $logfile.failed
26 rm -f $LOCKFILE
27 fi
28 else
29 echo "All builds done with success"
30 rm -f $LOCKFILE
31 fi
32 }
33
34 trap on_exit EXIT
35
36 # main
37
38 if [[ -f $LOCKFILE ]]; then
39 exit $LOCK_FILE_IS_FOUND
40 fi
41
42 touch $LOCKFILE
43 mkdir -p $CAPSULE_LOGDIR
44
45 source $HOME/perl5/perlbrew/etc/bashrc
46
47 cd $BUILDDIR
48 for branch in "master" "devel"
49 do
50 for perl in $HOME/perl5/perlbrew/perls/perl-*
51 do
52 theperl="$(basename $perl)"
53 echo "Building $CAPSULE_PROJECT @ $branch for $theperl ..."
54
55 perlbrew switch $theperl
56 hash -r
57
58 mkdir -p "$CAPSULE_LOGDIR/$branch"
59 logfile="$CAPSULE_LOGDIR/$branch/$CAPSULE_PROJECT.$theperl.pending.txt"
60
61 buildtime=$(date +"%Y-%m-%d %H:%M:%S")
62 echo "Autobuild of $project with $theperl" >> $logfile
63 echo "build time: $buildtime" >> $logfile
64 echo "=================================================================================" >> $logfile
65 perl -v >> $logfile
66 echo "" >> $logfile
67
68 rm -rf $CAPSULE_PROJECT
69
70 git clone $CAPSULE_GIT_REPO --branch $branch >> $logfile 2>&1
71 cd $CAPSULE_PROJECT
72
73 # we want the last commit _before_ the merge we just did, so
74 lastrev=$(git log | head -n 1 | awk '{print $2}')
75
76 echo "" >> $logfile
77 echo "==> Using $CAPSULE_GIT_REPO @ $branch [ $lastrev ]" >> $logfile
78 echo "" >> $logfile
79
80 pendinglog="$logfile"
81 logfile="$CAPSULE_LOGDIR/$branch/$CAPSULE_PROJECT.$theperl.$lastrev.txt"
82
83 # if logfile already exist, it means the run has already been done
84 if [[ -f "$logfile" ]] ; then
85 echo " -> already done for $lastrev"
86 rm -f $pendinglog
87 cd ..
88 continue
89 fi
90
91 # Test never done with $lastrev, doing it
92 mv "$pendinglog" "$logfile"
93
94 # make sure all deps are OK for $theperl
95 cpanm $CAPSULE_CPAN_DEPS >> $logfile 2>&1
96
97 # build $project
98 perl Makefile.PL >> $logfile 2>&1
99 make >> $logfile 2>&1
100 HARNESS_VERBOSE=1 make test >> $logfile 2>&1
101
102 # link the last run for $theperl
103 rm -f "$CAPSULE_LOGDIR/$branch.last.$theperl.txt"
104 ln -s $logfile "$CAPSULE_LOGDIR/$branch.last.$theperl.txt"
105
106 # cover score
107 cover_file="$CAPSULE_LOGDIR/$branch/$lastrev.cover.txt"
108 if [[ ! -e $cover_file ]]; then
109 cover -test \
110 -coverage statement \
111 -coverage branch \
112 -coverage subroutine > $cover_file 2>&1
113
114 rm -f "$CAPSULE_LOGDIR/$branch/last.cover.txt"
115 ln -s $cover_file "$CAPSULE_LOGDIR/$branch/last.cover.txt"
116 fi
117
118 cd ..
119 done
120 done
121
122 cd $origin
123 rm -rf $BUILDDIR
124
Something went wrong with that request. Please try again.