From 8303eb30377a41879c982b62b53cc549c60b74c0 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Tue, 22 Oct 2019 12:31:30 -0400 Subject: Cirrus: Only upload tagged releases Prior to this commit, every push to master had it's builds packaged and uploaded to google storage. This is a waste, since potential users are only ever concerned about tagged releases. Unfortunately because the release process involves humans with potentially multiple human and automation steps happening in parallel, it's easy for automation to not detect a tagged release, or trigger on development|pre-release tags. Fix this in `upload_release_archive.sh` using a new unit-tested function `is_release()`. This acts as the definitive authority on whether or not a specific commit rage or `$CIRRUS_TAG` value constitutes something worthy of upload. Signed-off-by: Chris Evich --- contrib/cirrus/lib.sh.t | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'contrib/cirrus/lib.sh.t') diff --git a/contrib/cirrus/lib.sh.t b/contrib/cirrus/lib.sh.t index 70246ef41..9915b42a4 100755 --- a/contrib/cirrus/lib.sh.t +++ b/contrib/cirrus/lib.sh.t @@ -119,5 +119,42 @@ line2" "=" "line 1 line2" ############################################################################### +# tests for is_release() + +# N/B: Assuming tests run in their own process, so wiping out the local +# CIRRUS_BASE_SHA CIRRUS_CHANGE_IN_REPO and CIRRUS_TAG will be okay. +function test_is_release() { + CIRRUS_BASE_SHA="$1" + CIRRUS_CHANGE_IN_REPO="$2" + CIRRUS_TAG="$3" + local exp_status=$4 + local exp_msg=$5 + local msg + msg=$(is_release) + local status=$? + + check_result "$msg" "$exp_msg" "is_release(CIRRUS_BASE_SHA='$1' CIRRUS_CHANGE_IN_REPO='$2' CIRRUS_TAG='$3')" + check_result "$status" "$exp_status" "is_release(...) returned $status" +} + +# FROM TO TAG RET MSG +#test_is_release "" "" "" "" "" + +test_is_release "" "" "" "9" "FATAL: is_release() requires \$CIRRUS_BASE_SHA to be non-empty" +test_is_release "x" "" "" "9" "FATAL: is_release() requires \$CIRRUS_CHANGE_IN_REPO to be non-empty" + +test_is_release "unknown" "x" "" "11" "is_release() unusable range unknown..x or tag " +test_is_release "x" "unknown" "" "11" "is_release() unusable range x..unknown or tag " +test_is_release "x" "x" "unknown" "11" "is_release() unusable range x..x or tag unknown" + +# Negative-testing git with this function is very difficult, assume it works +# test_is_release ... "is_release() failed to fetch tags" +# test_is_release ... "is_release() failed to parse tags" + +BF_V1=$(git rev-parse v1.0.0^) +AT_V1=$(git rev-parse v1.0.0) +test_is_release "$BF_V1" "$BF_V1" "v9.8.7-dev" "2" "Found \$RELVER v9.8.7-dev" +test_is_release "$BF_V1" "$AT_V1" "v9.8.7-dev" "2" "Found \$RELVER v9.8.7-dev" +test_is_release "$BF_V1" "$AT_V1" "" "0" "Found \$RELVER v1.0.0" exit $rc -- cgit v1.2.3-54-g00ecf