Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-0.58] Introduce go build of functests #8962

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ bazel-generate:
bazel-build:
hack/dockerized "export BUILD_ARCH=${BUILD_ARCH} && export DOCKER_TAG=${DOCKER_TAG} && hack/bazel-fmt.sh && hack/bazel-build.sh"

bazel-build-functests:
hack/dockerized "hack/bazel-fmt.sh && hack/bazel-build-functests.sh"

build-functests: bazel-build-functests

bazel-build-image-bundle:
hack/dockerized "export BUILD_ARCH=${BUILD_ARCH} && hack/bazel-fmt.sh && DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} IMAGE_PREFIX=${IMAGE_PREFIX} hack/bazel-build-image-bundle.sh"

Expand Down Expand Up @@ -56,6 +61,9 @@ client-python:
go-build:
hack/dockerized "export KUBEVIRT_NO_BAZEL=true && KUBEVIRT_VERSION=${KUBEVIRT_VERSION} KUBEVIRT_GO_BUILD_TAGS=${KUBEVIRT_GO_BUILD_TAGS} ./hack/build-go.sh install ${WHAT}" && ./hack/build-copy-artifacts.sh ${WHAT}

go-build-functests:
hack/dockerized "export KUBEVIRT_NO_BAZEL=true && KUBEVIRT_GO_BUILD_TAGS=${KUBEVIRT_GO_BUILD_TAGS} ./hack/go-build-functests.sh"

gosec:
hack/dockerized "GOSEC=${GOSEC} ARTIFACTS=${ARTIFACTS} ./hack/gosec.sh"

Expand All @@ -70,9 +78,6 @@ go-test: go-build

test: bazel-test

build-functests:
hack/dockerized "hack/bazel-fmt.sh && hack/build-func-tests.sh"

functest: build-functests
hack/functests.sh

Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions hack/build-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ source hack/common.sh
source hack/config.sh
source hack/version.sh

source hack/go-build-functests.sh

if [ -z "$1" ]; then
target="install"
else
Expand Down
2 changes: 1 addition & 1 deletion hack/cluster-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ source hack/config.sh
echo "Building ..."

# Build everyting and publish it
${KUBEVIRT_PATH}hack/dockerized "BUILD_ARCH=${BUILD_ARCH} DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} ./hack/build-func-tests.sh"
${KUBEVIRT_PATH}hack/dockerized "BUILD_ARCH=${BUILD_ARCH} DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} ./hack/bazel-build-functests.sh"
${KUBEVIRT_PATH}hack/dockerized "BUILD_ARCH=${BUILD_ARCH} DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} DOCKER_TAG_ALT=${DOCKER_TAG_ALT} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} IMAGE_PREFIX=${IMAGE_PREFIX} IMAGE_PREFIX_ALT=${IMAGE_PREFIX_ALT} ./hack/bazel-push-images.sh"

echo "Done $0"
6 changes: 0 additions & 6 deletions hack/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ OPERATOR_MANIFEST_PATH=$MANIFESTS_OUT_DIR/release/kubevirt-operator.yaml
TESTING_MANIFEST_PATH=$MANIFESTS_OUT_DIR/testing
KUBEVIRT_CRI="$(determine_cri_bin)"

function build_func_tests() {
mkdir -p "${TESTS_OUT_DIR}/"
GOPROXY=off \
go test -c "${KUBEVIRT_DIR}/tests" -o "${TESTS_OUT_DIR}/tests.test"
}

function build_func_tests_image() {
local bin_name=tests
cp ${KUBEVIRT_DIR}/tests/{Dockerfile,entrypoint.sh} \
Expand Down
50 changes: 50 additions & 0 deletions hack/go-build-functests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env 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 2022 Red Hat, Inc.
#

set -e

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

PLATFORM=$(uname -m)
case ${PLATFORM} in
x86_64* | i?86_64* | amd64*)
ARCH="amd64"
;;
aarch64* | arm64*)
ARCH="arm64"
;;
*)
echo "invalid Arch, only support x86_64 and aarch64"
exit 1
;;
esac

function build_func_tests() {
echo "building functional tests"
rm -rf "${TESTS_OUT_DIR}"
mkdir -p "${TESTS_OUT_DIR}/"
GOOS=linux GOARCH=${ARCH} go_build -tags "${KUBEVIRT_GO_BUILD_TAGS}" -o "${TESTS_OUT_DIR}/ginkgo" vendor/github.com/onsi/ginkgo/v2/ginkgo/main.go
GOOS=linux GOARCH=${ARCH} GOPROXY=off go test -tags "${KUBEVIRT_GO_BUILD_TAGS}" -c -o "${TESTS_OUT_DIR}/tests.test" "${KUBEVIRT_DIR}/tests"
GOOS=linux GOARCH=${ARCH} go_build -tags "${KUBEVIRT_GO_BUILD_TAGS}" -o "${TESTS_OUT_DIR}/junit-merger" tools/junit-merger/junit-merger.go
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
build_func_tests
fi