Merge pull request #3909 from fidencio/wip/clh-allow-testing-a-specific-pr

static-build,clh: Add the ability to build from a PR
This commit is contained in:
GabyCT 2022-03-23 15:24:34 -06:00 committed by GitHub
commit d9cd8cde2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,8 @@ source "${script_dir}/../../scripts/lib.sh"
cloud_hypervisor_repo="${cloud_hypervisor_repo:-}"
cloud_hypervisor_version="${cloud_hypervisor_version:-}"
cloud_hypervisor_pr="${cloud_hypervisor_pr:-}"
cloud_hypervisor_pull_ref_branch="${cloud_hypervisor_pull_ref_branch:-main}"
if [ -z "$cloud_hypervisor_repo" ]; then
info "Get cloud_hypervisor information from runtime versions.yaml"
@ -31,8 +33,13 @@ if [ -z "$cloud_hypervisor_repo" ]; then
fi
[ -n "$cloud_hypervisor_repo" ] || die "failed to get cloud_hypervisor repo"
[ -n "$cloud_hypervisor_version" ] || cloud_hypervisor_version=$(get_from_kata_deps "assets.hypervisor.cloud_hypervisor.version" "${kata_version}")
[ -n "$cloud_hypervisor_version" ] || die "failed to get cloud_hypervisor version"
if [ -n "$cloud_hypervisor_pr" ]; then
force_build_from_source=true
cloud_hypervisor_version="PR $cloud_hypervisor_pr"
else
[ -n "$cloud_hypervisor_version" ] || cloud_hypervisor_version=$(get_from_kata_deps "assets.hypervisor.cloud_hypervisor.version" "${kata_version}")
[ -n "$cloud_hypervisor_version" ] || die "failed to get cloud_hypervisor version"
fi
pull_clh_released_binary() {
info "Download cloud-hypervisor version: ${cloud_hypervisor_version}"
@ -50,8 +57,19 @@ build_clh_from_source() {
repo_dir="${repo_dir//.git}"
[ -d "${repo_dir}" ] || git clone "${cloud_hypervisor_repo}"
pushd "${repo_dir}"
git fetch || true
git checkout "${cloud_hypervisor_version}"
if [ -n "${cloud_hypervisor_pr}" ]; then
local pr_branch="PR_${cloud_hypervisor_pr}"
git fetch origin "pull/${cloud_hypervisor_pr}/head:${pr_branch}" || return 1
git checkout "${pr_branch}"
git rebase "origin/${cloud_hypervisor_pull_ref_branch}"
git log --oneline main~1..HEAD
else
git fetch || true
git checkout "${cloud_hypervisor_version}"
fi
if [ -n "${features}" ]; then
info "Build cloud-hypervisor enabling the following features: ${features}"
./scripts/dev_cli.sh build --release --libc musl --features "${features}"