Skip to content

Commit

Permalink
packaging: merge packaging repository
Browse files Browse the repository at this point in the history
git-subtree-dir: tools/packaging
git-subtree-mainline: f818b46
git-subtree-split: 1f22d72

Signed-off-by: Peng Tao <[email protected]>
  • Loading branch information
bergwolf committed Jun 24, 2020
2 parents f818b46 + 1f22d72 commit 782cd2e
Show file tree
Hide file tree
Showing 645 changed files with 292,694 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tools/packaging/.ci/azure/pipelines/obs-packaging-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# Copyright (c) 2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#

trigger:
- master

jobs:
- job: packages
#timeout set to max
timeoutInMinutes: 0
pool:
vmImage: 'ubuntu-latest'
steps:
# azure docker installation task
# https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/docker-installer?view=azure-devops
- task: DockerInstaller@0
displayName: 'Install Docker'

- bash: |
sudo apt-get update -y -qq
sudo apt-get --no-install-recommends install -y git
git config --global user.email "[email protected]"
git config --global user.name "azure-pipeline"
.ci/packaging/setup.sh
displayName: 'Setup'
env:
CI: true
branch: $(system.pullRequest.targetBranch)
GITHUB_PR: $(system.pullRequest.pullRequestNumber)
- 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)
27 changes: 27 additions & 0 deletions tools/packaging/.ci/azure/pipelines/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Copyright (c) 2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#

trigger:
- master

jobs:
- job: packages
#timeout set to max
timeoutInMinutes: 0
pool:
vmImage: 'ubuntu-latest'
steps:
# azure docker installation task
# https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/docker-installer?view=azure-devops
- task: DockerInstaller@0
displayName: 'Install Docker'

- bash: |
sudo apt-get update -y -qq
sudo apt-get --no-install-recommends install -y apt-utils ca-certificates git
git config --global user.email "[email protected]"
git config --global user.name "azure-pipeline"
displayName: 'Setup'
34 changes: 34 additions & 0 deletions tools/packaging/.ci/lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Copyright (c) 2018,2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0

export tests_repo="${tests_repo:-github.com/kata-containers/tests}"
export tests_repo_dir="$GOPATH/src/$tests_repo"

clone_tests_repo()
{
# KATA_CI_NO_NETWORK is (has to be) ignored if there is
# no existing clone.
if [ -d "$tests_repo_dir" -a -n "$KATA_CI_NO_NETWORK" ]
then
return
fi

go get -d -u "$tests_repo" || true
if [ -n "${TRAVIS_BRANCH:-}" ]; then
( cd "${tests_repo_dir}" && git checkout "${TRAVIS_BRANCH}" )
fi
}

run_static_checks()
{
clone_tests_repo
bash "$tests_repo_dir/.ci/static-checks.sh" "github.com/kata-containers/packaging"
}

run_go_test()
{
clone_tests_repo
bash "$tests_repo_dir/.ci/go-test.sh"
}
78 changes: 78 additions & 0 deletions tools/packaging/.ci/packaging/request_to_obs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/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
BUILD_HEAD=${BUILD_HEAD:-${CI:-}}

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}"
echo "INFO: SUBPROJECT_TYPE=${SUBPROJECT_TYPE}"

# Export in all pipeline tasks
cd "${packaging_dir}/obs-packaging" || exit 1
gen_versions_cmd="./gen_versions_txt.sh"
if [ "${BUILD_HEAD}" = "true" ]; then
echo "Building for head gen versions ..."
gen_versions_cmd+=" --head"
fi

${gen_versions_cmd} "${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)
create_repo_cmd="./create-repo-branch.sh"
if [ "${CI:-}" = "true" ]; then
create_repo_cmd+=" --ci"
fi
create_repo_cmd+=" ${OBS_BRANCH}"
script -qefc bash -c "${create_repo_cmd}"
script -qefc bash -c './build_from_docker.sh ${NEW_VERSION}'
19 changes: 19 additions & 0 deletions tools/packaging/.ci/packaging/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
#
# Copyright (c) 2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#

set -o errexit
set -o nounset
set -o pipefail
set -o errtrace

export GOPATH=~/go
export kata_repo="github.com/kata-containers/packaging"
export pr_number=${GITHUB_PR:-}
export pr_branch="PR_${pr_number}"

go get github.com/kata-containers/tests
${GOPATH}/src/github.com/kata-containers/tests/.ci/resolve-kata-dependencies.sh
20 changes: 20 additions & 0 deletions tools/packaging/.ci/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
#
# Copyright (c) 2017-2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#

set -o errexit
set -o nounset
set -o pipefail

cidir=$(dirname "$0")
source "${cidir}/../scripts/lib.sh"
source /etc/os-release

pushd "${tests_repo_dir}"
.ci/run.sh
popd

# This script will execute packaging tests suite
78 changes: 78 additions & 0 deletions tools/packaging/.ci/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#

set -o errexit
set -o nounset
set -o pipefail

source /etc/os-release

SNAP_CI="${SNAP_CI:-false}"

echo "Setup script for packaging"

export tests_repo="${tests_repo:-github.com/kata-containers/tests}"
export tests_repo_dir="$GOPATH/src/$tests_repo"

clone_tests_repo()
{
# KATA_CI_NO_NETWORK is (has to be) ignored if there is
# no existing clone.
if [ -d "$tests_repo_dir" -a -n "${KATA_CI_NO_NETWORK:-}" ]
then
return
fi

go get -d -u "$tests_repo" || true
}

clone_tests_repo

if [ "$SNAP_CI" == "true" ] && [ "$ID" == "ubuntu" ]; then
# Do not install kata since we want to build, install and test the snap
export INSTALL_KATA="no"

echo "Install snap dependencies"
sudo apt-get --no-install-recommends install -y snapd snapcraft make

echo "Building snap image"
make snap

echo "Install kata container snap"
sudo snap install --dangerous --classic "$(basename kata-containers_*.snap)"

etc_confile="/etc/kata-containers/configuration.toml"
usr_confile="/usr/share/defaults/kata-containers/configuration.toml"
snap_confile="/snap/kata-containers/current/usr/share/defaults/kata-containers/configuration.toml"
snap_bin_dir="/snap/kata-containers/current/usr/bin"

sudo rm -f /usr/local/bin/kata-runtime \
/usr/bin/kata-runtime \
/usr/local/bin/containerd-shim-kata-v2 \
/usr/bin/containerd-shim-kata-v2 \
"${etc_confile}" "${usr_confile}"

sudo ln -sf ${snap_bin_dir}/kata-runtime /usr/bin/kata-runtime
sudo ln -sf ${snap_bin_dir}/kata-runtime /usr/local/bin/kata-runtime

sudo ln -sf ${snap_bin_dir}/containerd-shim-kata-v2 /usr/bin/containerd-shim-kata-v2
sudo ln -sf ${snap_bin_dir}/containerd-shim-kata-v2 /usr/local/bin/containerd-shim-kata-v2

# copy configuration file since some tests modify it.
sudo mkdir -p "$(dirname "${etc_confile}")" "$(dirname "${usr_confile}")"
sudo cp "${snap_confile}" "${etc_confile}"
sudo cp "${snap_confile}" "${usr_confile}"

# Use the same version of tests to test the snap
git -C "${tests_repo_dir}" checkout "$(basename kata-containers_*.snap | cut -d_ -f2)"

"${tests_repo_dir}/cmd/container-manager/manage_ctr_mgr.sh" docker configure -r kata-runtime -f
fi

pushd "${tests_repo_dir}"
.ci/setup.sh
popd
13 changes: 13 additions & 0 deletions tools/packaging/.ci/static-checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
#
# Copyright (c) 2018,2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0

set -e

cidir=$(dirname "$0")
source "${cidir}/lib.sh"

# Run static checks
run_static_checks
13 changes: 13 additions & 0 deletions tools/packaging/.ci/teardown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#

set -o errexit
set -o nounset
set -o pipefail

# TODO: Add teardown steps as need
true
Loading

0 comments on commit 782cd2e

Please sign in to comment.