Explorar o código

codec: support _release checking and ensure correct codecgen is executed

_release should be run before checkin, to ensure that we support
2 years of go releases (the last 3 releases and tip).

Also, ensure that the codecgen run is the one from the source tree.
Do not depend on GOPATH/bin for it.
Ugorji Nwoke %!s(int64=6) %!d(string=hai) anos
pai
achega
d2dc9cd990
Modificáronse 1 ficheiros con 45 adicións e 6 borrados
  1. 45 6
      codec/build.sh

+ 45 - 6
codec/build.sh

@@ -127,16 +127,19 @@ EOF
 }
 
 _codegenerators() {
-    if ! [[ $zforce ||
-                $(_ng "values_codecgen${zsfx}") ]]; then return 0; fi
+    if ! [[ $zforce || $(_ng "values_codecgen${zsfx}") ]]; then return 0; fi
 
-    # Note: ensure you run the codecgen for this codebase  (using $zgobase/bin/codecgen)
+    # Note: ensure you run the codecgen for this codebase/directory i.e. ./codecgen/codecgen
     local c9="codecgen-scratch.go"
+    local c7="$zmydir/codecgen"
     true &&
         echo "codecgen ... " &&
-        $zgobase/bin/codecgen -rt codecgen -t 'codecgen generated' -o values_codecgen${zsfx} -d 19780 $zfin $zfin2 &&
+        if [[ $zforce || ! -f "$c7/codecgen" || "$c7/gen.go" -nt "$c7/codecgen" ]]; then
+            echo "rebuilding codecgen ... " && ( cd codecgen && go build -o codecgen ${zargs[*]} . )
+        fi &&
+        $c7/codecgen -rt codecgen -t 'codecgen generated' -o values_codecgen${zsfx} -d 19780 $zfin $zfin2 &&
         cp mammoth2_generated_test.go $c9 &&
-        $zgobase/bin/codecgen -t '!notfastpath' -o mammoth2_codecgen${zsfx} -d 19781 mammoth2_generated_test.go &&
+        $c7/codecgen -t '!notfastpath' -o mammoth2_codecgen${zsfx} -d 19781 mammoth2_generated_test.go &&
         rm -f $c9 &&
         echo "generators done!" 
 }
@@ -165,7 +168,7 @@ _prebuild() {
 _make() {
     zforce=1
     zexternal=1
-    ( cd codecgen && go install ${zargs[*]} . ) && _prebuild && go install ${zargs[*]} .
+    (cd codecgen && go install ${zargs[*]} .) && _prebuild && go install ${zargs[*]} .
     unset zforce zexternal
 }
 
@@ -175,6 +178,42 @@ _clean() {
        test_values.generated.go test_values_flex.generated.go
 }
 
+_release() {
+    local reply
+    read -p "Pre-release validation takes a few minutes and MUST be run from within GOPATH/src. Confirm y/n? " -n 1 -r reply
+    echo
+    if [[ ! $reply =~ ^[Yy]$ ]]; then return 1; fi
+
+    # expects GOROOT, GOROOT_BOOTSTRAP to have been set.
+    if [[ -z "${GOROOT// }" || -z "${GOROOT_BOOTSTRAP// }" ]]; then return 1; fi
+    # (cd $GOROOT && git checkout -f master && git pull && git reset --hard)
+    (cd $GOROOT && git pull)
+    local f=`pwd`/make.release.out
+    cat > $f <<EOF
+========== `date` ===========
+EOF
+    # # go 1.6 and below kept giving memory errors on Mac OS X during SDK build or go run execution,
+    # # that is fine, as we only explicitly test the last 3 releases and tip (2 years).
+    zforce=1
+    for i in 1.10 1.11 1.12 master
+    do
+        echo "*********** $i ***********" >>$f
+        if [[ "$i" != "master" ]]; then i="release-branch.go$i"; fi
+        (false ||
+             (echo "===== BUILDING GO SDK for branch: $i ... =====" &&
+                  cd $GOROOT &&
+                  git checkout -f $i && git reset --hard && git clean -f . &&
+                  cd src && ./make.bash >>$f 2>&1 && sleep 1 ) ) &&
+            echo "===== GO SDK BUILD DONE =====" &&
+            _prebuild &&
+            echo "===== PREBUILD DONE with exit: $? =====" &&
+            _tests "$@"
+        if [[ "$?" != 0 ]]; then return 1; fi
+    done
+    unset zforce
+    echo "++++++++ RELEASE TEST SUITES ALL PASSED ++++++++"
+}
+
 _usage() {
     cat <<EOF
 primary usage: $0