summaryrefslogtreecommitdiff
path: root/contrib/cirrus/lib.sh.t
diff options
context:
space:
mode:
authorChris Evich <cevich@redhat.com>2019-10-22 12:31:30 -0400
committerChris Evich <cevich@redhat.com>2019-10-29 10:34:58 -0400
commit8303eb30377a41879c982b62b53cc549c60b74c0 (patch)
tree4b7242de8dba16a0406552ebee90135ec95e322e /contrib/cirrus/lib.sh.t
parenta56131fef4a82824b397c94f6b7edcdb24769624 (diff)
downloadpodman-8303eb30377a41879c982b62b53cc549c60b74c0.tar.gz
podman-8303eb30377a41879c982b62b53cc549c60b74c0.tar.bz2
podman-8303eb30377a41879c982b62b53cc549c60b74c0.zip
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 <cevich@redhat.com>
Diffstat (limited to 'contrib/cirrus/lib.sh.t')
-rwxr-xr-xcontrib/cirrus/lib.sh.t37
1 files changed, 37 insertions, 0 deletions
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