mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-14 15:44:58 +00:00
ci: Add steps to build obs packages.
- OBS packages are build based on kata head - The OBS kata branch is created on demand - TODO: Delete branch when is not needed anymore Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
parent
639c432a88
commit
7f94b70905
@ -7,13 +7,44 @@
|
|||||||
trigger:
|
trigger:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
- job: packages
|
||||||
|
#timeout set to max
|
||||||
|
timeoutInMinutes: 0
|
||||||
pool:
|
pool:
|
||||||
vmImage: 'ubuntu-latest'
|
vmImage: 'ubuntu-latest'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- script: echo setup
|
# azure docker installation task
|
||||||
displayName: 'setup CI'
|
# https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/docker-installer?view=azure-devops
|
||||||
|
- task: DockerInstaller@0
|
||||||
|
displayName: 'Install Docker'
|
||||||
|
|
||||||
- script: |
|
- bash: |
|
||||||
echo This is an initial CI job
|
sudo apt-get update -y -qq
|
||||||
displayName: 'Run CI'
|
sudo apt-get install -y git
|
||||||
|
git config --global user.email "azure-pipeline@kata.io"
|
||||||
|
git config --global user.name "azure-pipeline"
|
||||||
|
displayName: 'Setup'
|
||||||
|
|
||||||
|
- bash: |
|
||||||
|
# This is set by azure, but we use the same variable
|
||||||
|
export AGENT_VERSION=""
|
||||||
|
script -qefc bash -c '.ci/packaging/request_to_obs.sh'
|
||||||
|
# Kata branch to build
|
||||||
|
displayName: 'Request build to OBS'
|
||||||
|
|
||||||
|
env:
|
||||||
|
CI: true
|
||||||
|
BRANCH: $(system.pullRequest.targetBranch)
|
||||||
|
OBS_USER: $(OBS_USER)
|
||||||
|
OBS_PASS: $(OBS_PASS)
|
||||||
|
GITHUB_PR: $(system.pullRequest.pullRequestNumber)
|
||||||
|
|
||||||
|
- bash: |
|
||||||
|
echo "Wait for packages from ${OBS_SUBPROJECT}"
|
||||||
|
[ "${OBS_SUBPROJECT}" != "" ] || { echo "OBS_SUBPROJECT"; exit 1; }
|
||||||
|
script -qefc bash -c './obs-packaging/wait-obs.sh --no-wait-publish'
|
||||||
|
displayName: 'Wait for packages are ready'
|
||||||
|
env:
|
||||||
|
USE_DOCKER: true
|
||||||
|
CI: $(CI)
|
||||||
|
67
.ci/packaging/request_to_obs.sh
Executable file
67
.ci/packaging/request_to_obs.sh
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Copyright (c) 2019 Intel Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
# This script will request package creation in OBS.
|
||||||
|
# create a repository under:
|
||||||
|
# https://build.opensuse.org/project/show/home:katacontainers
|
||||||
|
# Generate package files: rpm spec, deb source files.
|
||||||
|
# Send a request to OBS to build the packages in its servers
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
set -o errtrace
|
||||||
|
|
||||||
|
[ -z "${DEBUG:-}" ] || set -x
|
||||||
|
readonly script_dir=$(dirname $(readlink -f "$0"))
|
||||||
|
readonly packaging_dir="${script_dir}/../.."
|
||||||
|
|
||||||
|
# Kata branch where packages will be based
|
||||||
|
BRANCH=${BRANCH:-master}
|
||||||
|
|
||||||
|
# Name of OBS branch to to push
|
||||||
|
OBS_BRANCH="${OBS_BRANCH:-testing}"
|
||||||
|
|
||||||
|
if [ "${CI:-}" == "true" ] && [ "${GITHUB_PR:-}" != "" ]; then
|
||||||
|
OBS_BRANCH="packaging-PR-${GITHUB_PR}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Push to anywhere, variable used by release scripts to push
|
||||||
|
PUSH=1
|
||||||
|
# dont use release kata image
|
||||||
|
BUILD_HEAD=true
|
||||||
|
|
||||||
|
if [ "${CI:-}" == "true" ];then
|
||||||
|
SUBPROJECT_TYPE="ci"
|
||||||
|
else
|
||||||
|
SUBPROJECT_TYPE="releases"
|
||||||
|
fi
|
||||||
|
# Name of the OBS subproject under:
|
||||||
|
# https://build.opensuse.org/project/subprojects/home:katacontainers
|
||||||
|
OBS_SUBPROJECT="${SUBPROJECT_TYPE}:$(uname -m):${OBS_BRANCH}"
|
||||||
|
|
||||||
|
export BUILD_HEAD
|
||||||
|
export BRANCH
|
||||||
|
export OBS_BRANCH
|
||||||
|
export OBS_SUBPROJECT
|
||||||
|
export PUSH
|
||||||
|
|
||||||
|
# azure: Export in all pipeline tasks
|
||||||
|
echo "##vso[task.setvariable variable=OBS_SUBPROJECT;]${OBS_SUBPROJECT}"
|
||||||
|
|
||||||
|
echo "INFO: BUILD_HEAD=${BUILD_HEAD}"
|
||||||
|
echo "INFO: BRANCH=${BRANCH}"
|
||||||
|
echo "INFO: OBS_BRANCH=${OBS_SUBPROJECT}"
|
||||||
|
echo "INFO: PUSH=${PUSH}"
|
||||||
|
|
||||||
|
# Export in all pipeline tasks
|
||||||
|
cd "${packaging_dir}/obs-packaging" || exit 1
|
||||||
|
echo "Building for head gen versions ..."
|
||||||
|
./gen_versions_txt.sh --head "${BRANCH}"
|
||||||
|
# print versions just for debug/info
|
||||||
|
cat versions.txt
|
||||||
|
export NEW_VERSION=$(curl -s -L https://raw.githubusercontent.com/kata-containers/runtime/${BRANCH}/VERSION)
|
||||||
|
script -qefc bash -c './create-repo-branch.sh --ci ${OBS_BRANCH}'
|
||||||
|
script -qefc bash -c './build_from_docker.sh ${NEW_VERSION}'
|
@ -19,6 +19,7 @@ http_proxy=${http_proxy:-}
|
|||||||
https_proxy=${https_proxy:-}
|
https_proxy=${https_proxy:-}
|
||||||
no_proxy=${no_proxy:-}
|
no_proxy=${no_proxy:-}
|
||||||
PUSH=${PUSH:-}
|
PUSH=${PUSH:-}
|
||||||
|
BUILD_HEAD="${BUILD_HEAD:-false}"
|
||||||
|
|
||||||
# shellcheck source=scripts/obs-docker.sh
|
# shellcheck source=scripts/obs-docker.sh
|
||||||
source "${script_dir}/scripts/obs-docker.sh"
|
source "${script_dir}/scripts/obs-docker.sh"
|
||||||
@ -44,7 +45,7 @@ get_image() {
|
|||||||
echo "branch not provided"
|
echo "branch not provided"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if "${script_dir}/download_image.sh" "${branch}"; then
|
if [ ${BUILD_HEAD} = "false" ] && "${script_dir}/download_image.sh" "${branch}"; then
|
||||||
echo "OK image downloaded"
|
echo "OK image downloaded"
|
||||||
find . -name 'kata-containers-'"${branch}"'-*.tar.gz' || die "Failed to find downloaded image"
|
find . -name 'kata-containers-'"${branch}"'-*.tar.gz' || die "Failed to find downloaded image"
|
||||||
return 0
|
return 0
|
||||||
|
@ -137,9 +137,26 @@ EOT
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
case "${1:-}" in
|
||||||
|
"-h"|"--help")
|
||||||
|
usage Help
|
||||||
|
;;
|
||||||
|
--ci)
|
||||||
|
create_ci_subproject=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
die "Invalid option: ${1:-}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
local branch="${1:-}"
|
local branch="${1:-}"
|
||||||
[ -n "${branch}" ] || usage "missing branch" "1"
|
[ -n "${branch}" ] || usage "missing branch" "1"
|
||||||
project_branch="${home_project}:releases:${arch_target}:${branch}"
|
if [ "${create_ci_subproject:-false}" == "true" ];then
|
||||||
|
release_type="ci"
|
||||||
|
else
|
||||||
|
release_type="releases"
|
||||||
|
fi
|
||||||
|
project_branch="${home_project}:${release_type}:${arch_target}:${branch}"
|
||||||
create_meta_xml "${project_branch}" "${branch}"
|
create_meta_xml "${project_branch}" "${branch}"
|
||||||
info "Creating/Updating project with name ${project_branch}"
|
info "Creating/Updating project with name ${project_branch}"
|
||||||
# Update /Create project metadata.
|
# Update /Create project metadata.
|
||||||
|
@ -11,6 +11,9 @@ setup_oscrc() {
|
|||||||
# oscrc exists at different places on different distros
|
# oscrc exists at different places on different distros
|
||||||
[ -f "${HOME}/.config/osc/oscrc" ] && OSCRC="${HOME}/.config/osc/oscrc"
|
[ -f "${HOME}/.config/osc/oscrc" ] && OSCRC="${HOME}/.config/osc/oscrc"
|
||||||
OSCRC=${OSCRC:-"${HOME}/.oscrc"}
|
OSCRC=${OSCRC:-"${HOME}/.oscrc"}
|
||||||
|
(
|
||||||
|
# do not log OBS credentials even in debug mode
|
||||||
|
set +x
|
||||||
OBS_API="https://api.opensuse.org"
|
OBS_API="https://api.opensuse.org"
|
||||||
|
|
||||||
if [ -n "${OBS_USER:-}" ] && [ -n "${OBS_PASS:-}" ] && [ ! -e "${OSCRC}" ]; then
|
if [ -n "${OBS_USER:-}" ] && [ -n "${OBS_PASS:-}" ] && [ ! -e "${OSCRC}" ]; then
|
||||||
@ -24,11 +27,12 @@ user = ${OBS_USER}
|
|||||||
pass = ${OBS_PASS}
|
pass = ${OBS_PASS}
|
||||||
eom
|
eom
|
||||||
fi
|
fi
|
||||||
|
) >> /dev/null
|
||||||
if [ ! -e "${OSCRC}" ]; then
|
if [ ! -e "${OSCRC}" ]; then
|
||||||
echo "${OSCRC}, please do 'export OBS_USER=your_user ; export OBS_PASS=your_pass' to configure osc for first time."
|
echo "${OSCRC}, please do 'export OBS_USER=your_user ; export OBS_PASS=your_pass' to configure osc for first time."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo "OK - osc configured"
|
||||||
}
|
}
|
||||||
|
|
||||||
docker_run() {
|
docker_run() {
|
||||||
|
@ -9,6 +9,8 @@ set -o nounset
|
|||||||
set -o pipefail
|
set -o pipefail
|
||||||
set -o errtrace
|
set -o errtrace
|
||||||
|
|
||||||
|
script_name="$(basename "${BASH_SOURCE[0]}")"
|
||||||
|
|
||||||
handle_error() {
|
handle_error() {
|
||||||
local exit_code="${?}"
|
local exit_code="${?}"
|
||||||
local line_number="${1:-}"
|
local line_number="${1:-}"
|
||||||
@ -24,7 +26,7 @@ run_in_docker() {
|
|||||||
# shellcheck source=scripts/obs-docker.sh
|
# shellcheck source=scripts/obs-docker.sh
|
||||||
source "${script_dir}/scripts/obs-docker.sh"
|
source "${script_dir}/scripts/obs-docker.sh"
|
||||||
packaging_repo_dir=$(cd "${script_dir}/.." && pwd)
|
packaging_repo_dir=$(cd "${script_dir}/.." && pwd)
|
||||||
docker_run "${packaging_repo_dir}/obs-packaging/wait-obs.sh"
|
docker_run "${packaging_repo_dir}/obs-packaging/wait-obs.sh" $@
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -33,6 +35,8 @@ run_in_docker() {
|
|||||||
# Check all project has finshed the build
|
# Check all project has finshed the build
|
||||||
wait_finish_building() {
|
wait_finish_building() {
|
||||||
while osc pr -q | grep '(building)'; do sleep 5; done
|
while osc pr -q | grep '(building)'; do sleep 5; done
|
||||||
|
# just in case something goes wrong
|
||||||
|
while osc pr -q | grep '(building)'; do sleep 5; done
|
||||||
}
|
}
|
||||||
|
|
||||||
# obs distro final status is 'published'
|
# obs distro final status is 'published'
|
||||||
@ -45,7 +49,7 @@ is_published() {
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if ! echo "${c}" | grep 'published'; then
|
if ! echo "${c}" | grep 'published'; then
|
||||||
echo "${c}"
|
echo "waiting for : ${c}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -63,14 +67,45 @@ check_failed(){
|
|||||||
failed_query=$(osc pr -c -s F)
|
failed_query=$(osc pr -c -s F)
|
||||||
regex=".*failed.*"
|
regex=".*failed.*"
|
||||||
if [[ ${failed_query} =~ ${regex} ]];then
|
if [[ ${failed_query} =~ ${regex} ]];then
|
||||||
printf "%s" "${failed_query}" | column -t -s\;
|
echo "ERROR: Build failed"
|
||||||
return 1
|
osc pr -V -s 'F'
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo "Nothing failed"
|
||||||
|
osc pr -q -c | tail -n +2 | column -t -s\;
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
msg="${1:-}"
|
||||||
|
exit_code=$"${2:-0}"
|
||||||
|
cat <<EOT
|
||||||
|
${msg}
|
||||||
|
Usage:
|
||||||
|
${script_name} [--options]
|
||||||
|
|
||||||
|
options:
|
||||||
|
-h, --help: Show this help
|
||||||
|
--no-wait-publish : no wait that OBS publish packages
|
||||||
|
EOT
|
||||||
|
exit "${exit_code}"
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
run_in_docker
|
run_in_docker $@
|
||||||
|
local no_wait_publish="false"
|
||||||
|
case "${1:-}" in
|
||||||
|
"-h"|"--help")
|
||||||
|
usage "Help" 0
|
||||||
|
;;
|
||||||
|
--no-wait-publish)
|
||||||
|
no_wait_publish="true"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
usage "Invalid option: ${1:-}" 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
OBS_SUBPROJECT="${OBS_SUBPROJECT:-releases:x86_64:alpha}"
|
OBS_SUBPROJECT="${OBS_SUBPROJECT:-releases:x86_64:alpha}"
|
||||||
project="home:katacontainers:${OBS_SUBPROJECT}"
|
project="home:katacontainers:${OBS_SUBPROJECT}"
|
||||||
echo "Checkout: ${project}"
|
echo "Checkout: ${project}"
|
||||||
@ -85,6 +120,11 @@ main() {
|
|||||||
check_failed
|
check_failed
|
||||||
echo "OK - build did not fail"
|
echo "OK - build did not fail"
|
||||||
|
|
||||||
|
if [ "${no_wait_publish}" == "true" ];then
|
||||||
|
echo " Requested not wait for publish"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Wait for published"
|
echo "Wait for published"
|
||||||
wait_published
|
wait_published
|
||||||
echo "OK - published"
|
echo "OK - published"
|
||||||
|
@ -36,13 +36,14 @@ get_from_kata_deps() {
|
|||||||
local branch="${2:-${BRANCH}}"
|
local branch="${2:-${BRANCH}}"
|
||||||
local runtime_repo="github.com/kata-containers/runtime"
|
local runtime_repo="github.com/kata-containers/runtime"
|
||||||
GOPATH=${GOPATH:-${HOME}/go}
|
GOPATH=${GOPATH:-${HOME}/go}
|
||||||
|
local runtime_repo_dir="${GOPATH}/src/${runtime_repo}"
|
||||||
# For our CI, we will query the local versions.yaml file both for kernel and
|
# For our CI, we will query the local versions.yaml file both for kernel and
|
||||||
# all other subsystems. eg: a new version of NEMU would be good to test
|
# all other subsystems. eg: a new version of NEMU would be good to test
|
||||||
# through CI. For the kernel, .ci/install_kata_kernel.sh file in tests
|
# through CI. For the kernel, .ci/install_kata_kernel.sh file in tests
|
||||||
# repository will pass the kernel version as an override to this function to
|
# repository will pass the kernel version as an override to this function to
|
||||||
# allow testing of kernels before they land in tree.
|
# allow testing of kernels before they land in tree.
|
||||||
if [ "${CI:-}" = "true" ]; then
|
if [ "${CI:-}" = "true" ] && [ -d "${runtime_repo_dir}" ]; then
|
||||||
versions_file="${GOPATH}/src/${runtime_repo}/versions.yaml"
|
versions_file="${runtime_repo_dir}/versions.yaml"
|
||||||
else
|
else
|
||||||
versions_file="versions-${branch}.yaml"
|
versions_file="versions-${branch}.yaml"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user