Skip to content

Commit

Permalink
Repeat bazel build to be sure that it succeeds
Browse files Browse the repository at this point in the history
  • Loading branch information
Artyom Lukianov committed Mar 11, 2019
1 parent dcdc067 commit 6c9b2bd
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ bazel-build:
--workspace_status_command=./hack/print-workspace-status.sh \
//cmd/..."

bazel-build-images:
hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} DOCKER_TAG_ALT=${DOCKER_TAG_ALT} ./hack/bazel-build-images.sh"

bazel-push-images:
hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} DOCKER_TAG_ALT=${DOCKER_TAG_ALT} ./hack/bazel-push-images.sh"

Expand Down Expand Up @@ -113,6 +116,7 @@ builder-publish:
.PHONY: \
bazel-generate \
bazel-build \
bazel-build-images \
bazel-push-images \
bazel-tests \
build \
Expand Down
37 changes: 29 additions & 8 deletions automation/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,16 @@ safe_download() (
local remote_sha1_url="${download_from}.sha1"
local local_sha1_file="${download_to}.sha1"
local remote_sha1
local retry=3
# Remote file includes only sha1 w/o filename suffix
remote_sha1="$(curl -s "${remote_sha1_url}")"
for i in $(seq 1 $retry);
do
remote_sha1="$(curl -s "${remote_sha1_url}")"
if [[ "$remote_sha1" != "" ]]; then
break
fi
done

if [[ "$(cat "$local_sha1_file")" != "$remote_sha1" ]]; then
echo "${download_to} is not up to date, corrupted or doesn't exist."
echo "Downloading file from: ${remote_sha1_url}"
Expand Down Expand Up @@ -155,6 +163,26 @@ if [ -n "${KUBEVIRT_CACHE_FROM}" ]; then
fi

make cluster-down

# Create .bazelrc to use remote cache
cat >.bazelrc <<EOF
startup --host_jvm_args=-Dbazel.DigestFunction=sha256
build --remote_local_fallback
build --remote_http_cache=http://bazel-cache.kubevirt-prow.svc.cluster.local:8080/kubevirt.io/kubevirt
EOF

# build all images with the basic repeat logic
# probably because load on the node, possible situation when the bazel
# fails to download artifacts, to avoid job fails because of it,
# we repeat the build images action
set +e
for i in $(seq 1 3);
do
make bazel-build-images
done
set -e
make bazel-build-images

make cluster-up

# Wait for nodes to become ready
Expand All @@ -172,13 +200,6 @@ set -e
echo "Nodes are ready:"
kubectl get nodes

# Create .bazelrc to use remote cache
cat >.bazelrc <<EOF
startup --host_jvm_args=-Dbazel.DigestFunction=sha256
build --remote_local_fallback
build --remote_http_cache=http://bazel-cache.kubevirt-prow.svc.cluster.local:8080/kubevirt.io/kubevirt
EOF

make cluster-sync
hack/dockerized bazel shutdown

Expand Down
39 changes: 39 additions & 0 deletions hack/bazel-build-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
#
# This file is part of the KubeVirt project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Copyright 2019 Red Hat, Inc.
#

set -e

source hack/common.sh
source hack/config.sh

bazel build \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--workspace_status_command=./hack/print-workspace-status.sh \
--define container_prefix=${docker_prefix} \
--define container_tag=${docker_tag} \
//:build-images

if [ -n "$docker_tag_alt" ]; then
bazel build \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--workspace_status_command=./hack/print-workspace-status.sh \
--define container_prefix=${docker_prefix} \
--define container_tag=${docker_tag_alt} \
//:build-images
fi
2 changes: 1 addition & 1 deletion hack/bazel-push-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Copyright 2017 Red Hat, Inc.
# Copyright 2019 Red Hat, Inc.
#

set -e
Expand Down

0 comments on commit 6c9b2bd

Please sign in to comment.