Enable py36 unit tests
[functest-xtesting.git] / build.sh
index 51752a8..65e6bca 100644 (file)
--- a/build.sh
+++ b/build.sh
@@ -1,33 +1,34 @@
 #!/bin/bash
 
-set -e
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
 
-repo=${repo:-opnfv}
-amd64_dirs=${amd64_dirs-"\
-docker/core \
-docker/healthcheck \
-docker/smoke \
-docker/features \
-docker/components \
-docker/vnf \
-docker/parser \
-docker/restapi"}
-arm64_dirs=${arm64_dirs-$(echo "${amd64_dirs}" | sed -e "s|docker/vnf||" \
-    -e "s|docker/restapi||")}
+set -xe
 
-find . -name Dockerfile -exec sed -i -e "s|opnfv/functest-core|${repo}/functest-core:amd64-latest|g" {} +
-for dir in ${amd64_dirs}; do
-    (cd "${dir}" && docker build --no-cache -t "${repo}/functest-${dir##**/}:amd64-latest" .)
-    docker push "${repo}/functest-${dir##**/}:amd64-latest"
-done
-find . -name Dockerfile -exec git checkout {} +
+repo=${REPO:-opnfv}
+tag=${BRANCH:-hunter}
+arch=${arch-"\
+amd64 \
+arm64 \
+arm"}
+image="xtesting"
+build_opts=(--pull=true --no-cache --force-rm=true)
 
-find . -name Dockerfile -exec sed -i -e "s|alpine:3.6|multiarch/alpine:arm64-v3.6|g" {} +
-find . -name Dockerfile -exec sed -i -e "s|opnfv/functest-core|${repo}/functest-core:arm64-latest|g" {} +
-for dir in ${arm64_dirs}; do
-    (cd "${dir}" && docker build --no-cache -t "${repo}/functest-${dir##**/}:arm64-latest" .)
-    docker push "${repo}/functest-${dir##**/}:arm64-latest"
+for arch in ${arch};do
+    if [[ ${arch} == arm64 ]]; then
+        find . -name Dockerfile -exec sed -i \
+            -e "s|alpine:3.9|multiarch/alpine:arm64-v3.9|g" {} +
+    elif [[ ${arch} == arm ]]; then
+        find . -name Dockerfile -exec sed -i \
+            -e "s|alpine:3.9|multiarch/alpine:armhf-v3.9|g" {} +
+    fi
+    (cd docker &&   docker build "${build_opts[@]}" \
+        -t "${repo}/${image}:${arch}-${tag}" .)
+    docker push "${repo}/${image}:${arch}-${tag}"
+    [ "$?" == "0" ] &&
+        (sudo docker rmi "${repo}/${image}:${arch}-${tag}"|| true)
+    find . -name Dockerfile -exec git checkout \{\} +;
 done
-find . -name Dockerfile -exec git checkout {} +
-
 exit $?