4221c73868af59f1498c947c8a674cfb346d1fea
[ghc-devscripts.git] / ci-validate.sh
1 #!/bin/bash
2
3 cd /5playpen/t-jobrei/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 "Making sure we are on current master"
40 run_quiet ./sync-all checkout master
41 run_quiet ./sync-all pull
42 echo "Switching to that branch"
43 run_quiet ./sync-all checkout "$BRANCH"
44 git branch | fgrep -q "* $BRANCH"
45 echo "moving branch to validating/$BRANCH_BASE"
46 run_quiet ./sync-all --ignore-failure branch -M "$BRANCH" "validating/$BRANCH_BASE"
47 echo "Running validate"
48 export CPUS=8
49 if run_to "$LOGFILE" ./validate --no-dph 
50 then
51         echo "validate successful"
52         echo "moving branch to validated/$BRANCH_BASE"
53         run_quiet ./sync-all --ignore-failure branch -M "validating/$BRANCH_BASE" "validated/$BRANCH_BASE"
54 else
55         echo "validate broken"
56         echo "moving branch to broken/$BRANCH_BASE"
57         run_quiet ./sync-all --ignore-failure branch -M "validating/$BRANCH_BASE" "broken/$BRANCH_BASE"
58 fi
59 run_quiet make -C testsuite CLEANUP=1 CLEAN_ONLY=YES
60 run_quiet make clean
61 echo Resetting to master and updating 
62 run_quiet ./sync-all checkout master
63 run_quiet ./sync-all pull
64 echo "Waiting for new branches to appear."
65
66
67 sleep 10
68 done
69