Update with scripts from i44pc15
[ghc-devscripts.git] / ci-validate.sh
1 #!/bin/bash
2
3 cd /data1/breitner/ghc/ghc-validate
4
5 function get_branch () 
6 {
7         git branch --list validate/\*|head -n 1|cut -c3-
8 }
9
10 function run (){
11         printf "%q " "$@"
12         echo
13         "$@"
14 }
15 function run_quiet (){
16         printf "%q " "$@"
17         echo
18         "$@" > /dev/null 2>&1
19 }
20 function run_to (){
21         file="$1"
22         shift
23         printf "%q " "$@"
24         echo "-> $file"
25         "$@" > "$file" 2>&1
26 }
27
28
29 while true
30 do
31 while [ -z "$(get_branch)" ]; do sleep 1; done
32
33 BRANCH="$(get_branch)"
34 BRANCH_BASE="${BRANCH#validate/}"
35 LOGFILE="../validate-$BRANCH_BASE-$(date --iso=minutes).log"
36
37 echo "I am asked to validate $BRANCH_BASE"
38
39 echo "Cleaning up future branch names"
40 run_quiet ./sync-all --ignore-failure branch -D "validating/$BRANCH_BASE" "validated/$BRANCH_BASE" "broken/$BRANCH_BASE"
41
42 echo "Making sure we are on current master"
43 run_quiet ./sync-all checkout master
44 run_quiet ./sync-all pull
45 echo "Switching to that branch"
46 run_quiet ./sync-all checkout "$BRANCH"
47 git branch | fgrep -q "* $BRANCH"
48 echo "moving branch to validating/$BRANCH_BASE"
49 run_quiet ./sync-all --ignore-failure branch -m "$BRANCH" "validating/$BRANCH_BASE"
50 echo "Running validate"
51 export CPUS=8
52 if run_to "$LOGFILE" ./validate --no-dph 
53 then
54         echo "validate successful"
55         echo "moving branch to validated/$BRANCH_BASE"
56         run_quiet ./sync-all --ignore-failure branch -m "validating/$BRANCH_BASE" "validated/$BRANCH_BASE"
57 else
58         echo "validate broken"
59         echo "moving branch to broken/$BRANCH_BASE"
60         run_quiet ./sync-all --ignore-failure branch -m "validating/$BRANCH_BASE" "broken/$BRANCH_BASE"
61 fi
62 run_quiet make -C testsuite CLEANUP=1 CLEAN_ONLY=YES
63 run_quiet make clean
64 echo Resetting to master and updating 
65 run_quiet ./sync-all checkout master
66 run_quiet ./sync-all pull
67 echo "Waiting for new branches to appear."
68
69
70 sleep 10
71 done
72