File: round-robin-push

package info (click to toggle)
libnb-platform18-java 8.1%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 85,228 kB
  • ctags: 104,620
  • sloc: java: 705,506; xml: 124,894; ansic: 6,317; sh: 4,043; cpp: 2,492; objc: 288; perl: 277; makefile: 261
file content (141 lines) | stat: -rw-r--r-- 3,786 bytes parent folder | download | duplicates (6)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/sh

[ -n "$pop_url" ] || exit 101
if [ -z "$pop_build_info" ]; then
    pop_build_info="nbbuild/build/build_info"
fi
[ -n "$pop_job" ] || exit 103

[ -n "$push_url" ] || exit 113
[ -n "$push_username" ] || exit 114


testresult() {
    if [ -z "$4" ]; then
        FAILURES="0"
    else
        FAILURES="$4"
    fi

    FILE="$1/TEST-hg.$2.xml"
    echo '<?xml version="1.0" encoding="UTF-8" ?>' >$FILE
    echo '<testsuite errors="0" failures="'$FAILURES'" name="hg.'$2'" tests="1" time="1">' >>$FILE
    echo '  <properties>' >>$FILE
    echo '  </properties>' >>$FILE
    echo '  <testcase classname="hg.'$2'" name="hg.'$2'" time="1">' >>$FILE
    if [ "$FAILURES" -gt "0" ]; then
        echo '  <failure message="Failed"/>' >>$FILE
    fi
    echo '  </testcase>' >>$FILE
    echo '  <system-out><![CDATA[' >>$FILE
    echo "$3" >>$FILE
    echo ']]></system-out>' >>$FILE
    echo '  <system-err></system-err>' >>$FILE
    echo '</testsuite>' >>$FILE
}

testmodule() {
    if ant $ANT_PARAM -f $1/build.xml test-unit -Dtest-unit-sys-prop.ignore.random.failures=true; then
        echo Test OK: $1
    else
        echo $1 >>$RESULT
        exit 5
    fi
}

rollback() {
  EXIT="$?"
  if [ -n "$BASETIP" ]; then
    echo "Script failed with exitcode $EXIT rolling back to $BASETIP"
    hg update -C
    hg --config extensions.mq= strip -n "$BASETIP"
    hg pull -r "$BASETIP"
  else
    echo "No rollback, exitcode $EXIT"
  fi
}

if [ -z "$TMP" ]; then
  TMP="/tmp"
fi

ANT_OPTS="-Xmx512m -XX:MaxPermSize=128m"
export ANT_OPTS

BASETIP=`hg log -r . --template '{node}'`
trap rollback EXIT

hg up -C tip
hg --config extensions.purge= clean --all

TESTDIR="nbbuild/build/test/results/"
mkdir -p $TESTDIR

mkdir -p "nbbuild/build"
STATUS="nbbuild/build/build-info"
curl -H "Cache-Control: no-cache" $pop_job/buildStatus -D "$STATUS"
cat "$STATUS"

echo Getting Build Info
HGINFO=`curl -vvvv -H "Cache-Control: no-cache" $pop_job/lastStableBuild/artifact/$pop_build_info`
echo Build info: $HGINFO
testresult "$TESTDIR" "build.info" "$HGINFO"
[ -n "$HGINFO" ] || exit 1

HGID=`echo "$HGINFO" | grep "Hg ID"`
echo Last build_info line: "$HGID"
HGTIP=`echo "$HGID" | cut -f 2 -d ":" | while read X; do echo $X; done`
echo Last OK revision: "$HGTIP"

hg pull -r "$HGTIP" "$pop_url" || exit 5
echo 'hg parent:'
hg parent
if [ `hg heads --template '{node|short}\n' | wc -l` = 1 ]
then
   hg up || exit 6
else
   if hg --config ui.merge=internal:merge --config ui.interactive=1 merge "$HGTIP" < /dev/null; then
     echo Merge OK.
   else
     echo Merge failed.
     hg heads
     exit 7
   fi
   hg ci -u "$push_username"@netbeans.org -m "Merge of $pop_url" || exit 8
fi
HGOUT=`hg out $push_url`
testresult "$TESTDIR" "outgoing.changes" "$HGOUT"

OUT_COUNT=`hg out --no-merges --template 'change: {node|short}\n' $push_url | grep '^change: ' | wc -l`
if [ "$OUT_COUNT" -gt 0 ]; then
    echo "Let the build start. There are $OUT_COUNT outgoing changes."
else
    echo "No outgoing changes. No reason to do build."
    echo >"nbbuild/no-outgoing-changes-no-build.zip"
    if egrep "Location:.*/blue(_anime)?[.]" "$STATUS"; then
        echo Build seems to be stable
        testresult "$TESTDIR" "check.build.stable" "`cat $STATUS`"
    else
        echo Build is not stable
        testresult "$TESTDIR" "check.build.stable" "`cat $STATUS`" "1"
        echo >"nbbuild/downstream-builder-not-stable-no-push.zip"
    fi
    exit 0
fi

. `dirname $0`/round-robin-build

if dobuild; then
    for i in 1 2 3 4 5 6 7 8 9 10; do
        if hg push -f "$push_url"; then
            echo "Build and push successful"
            unset BASETIP
            exit 0
        fi
    done
    echo "Push failed"
    exit 1
else
    echo "Failure, rolling back own commits to $BASETIP"
    exit 1
fi