Support branch input to unit test docker script
With the upcoming OpenBMC release, it will be the first time
an official branch is done to all of the repos. The CI
infrastructure needs to support building against this
new branch (as well as master).
Testing:
- Verified with no branch input it behaves as it always did
- Verified with a non-existent branch it behaves as it always did
- Verified with a valid branch in a single repo that it used it
and defaulted to master for the rest
Change-Id: Ic71153483eb407f596afea1b748387b23bbc81fd
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/build-unit-test-docker.sh b/build-unit-test-docker.sh
index 7607c0f..0f2040e 100755
--- a/build-unit-test-docker.sh
+++ b/build-unit-test-docker.sh
@@ -7,11 +7,16 @@
# default is openbmc/ubuntu-unit-test
# DISTRO: <optional, the distro to build a docker image against>
# default is ubuntu:bionic
+# BRANCH: <optional, branch to build from each of the openbmc/
+# respositories>
+# default is master, which will be used if input branch not
+# provided or not found
set -uo pipefail
DOCKER_IMG_NAME=${DOCKER_IMG_NAME:-"openbmc/ubuntu-unit-test"}
DISTRO=${DISTRO:-"ubuntu:bionic"}
+BRANCH=${BRANCH:-"master"}
# Determine the architecture
ARCH=$(uname -m)
@@ -59,8 +64,15 @@
local package="$1"
local tip
+ # Need to continue if branch not found, hence || true at end
tip=$(git ls-remote "https://github.com/openbmc/${package}" |
- grep 'refs/heads/master' | awk '{ print $1 }')
+ grep "refs/heads/$BRANCH" | awk '{ print $1 }' || true)
+
+ # If specific branch is not found then try master
+ if [ ! -n "$tip" ]; then
+ tip=$(git ls-remote "https://github.com/openbmc/${package}" |
+ grep "refs/heads/master" | awk '{ print $1 }')
+ fi
# Lock the file to avoid interlaced writes
exec 3>> "$DEPCACHE_FILE"