forked from kata-containers/tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci_crio_entry_point.sh
150 lines (118 loc) · 4.71 KB
/
ci_crio_entry_point.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
#
# Copyright (c) 2021 Red Hat, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# This script is called by our jenkins instances, triggered by PRs on cri-o.
# It relies on the following environment variables being set:
# REPO_OWNER - owner of the source repository (default: cri-o)
# REPO_NAME - repository name (default: cri-o)
# PULL_BASE_REF - name of the branch where the pull request is merged to (default: main)
# PULL_NUMBER - pull request number (REQUIRED)
#
# (see: http://jenkins.katacontainers.io/job/kata-containers-2-crio-PR/)
#
# Usage:
# curl -OL https://raw.githubusercontent.com/kata-containers/tests/main/.ci/ci_crio_entry_point.sh
# bash ci_crio_entry_point.sh
set -o errexit
set -o pipefail
set -o errtrace
if [ -z "$PULL_NUMBER" ]; then
echo "No pull number given: testing with HEAD"
PULL_NUMBER="NONE"
fi
# set defaults for required variables
export REPO_OWNER=${REPO_OWNER:-"cri-o"}
export REPO_NAME=${REPO_NAME:-"cri-o"}
export PULL_BASE_REF=${PULL_BASE_REF:-"main"}
# Export all environment variables needed.
export CI_JOB="EXTERNAL_CRIO"
export INSTALL_KATA="yes"
export GO111MODULE=auto
latest_release="1.24"
sudo bash -c "cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl="https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64"
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF"
pr_number="${PULL_NUMBER}"
pr_branch="PR_${pr_number}"
# get (only) the number of the branch that we are testing
branch_release_number=$(echo ${PULL_BASE_REF} | cut -d'-' -f 2)
[ "$branch_release_number" == "main" ] && branch_release_number=${latest_release}
export ghprbGhRepository="${REPO_OWNER}/${REPO_NAME}"
export GOROOT="/usr/local/go"
export JOBS=1
# Put our go area into the Jenkins job WORKSPACE tree
export GOPATH=${WORKSPACE}/go
export PATH=${GOPATH}/bin:/usr/local/go/bin:/usr/sbin:/sbin:${PATH}
mkdir -p "${GOPATH}"
git config --global user.email "[email protected]"
git config --global user.name "Kata Containers Bot"
github="github.com"
crio_github="${github}/cri-o"
kata_github="${github}/kata-containers"
# CRI-O repository
crio_repo="${crio_github}/cri-o"
crio_repo_dir="${GOPATH}/src/${crio_repo}"
# Kata Containers Tests repository
tests_repo="${kata_github}/tests"
tests_repo_dir="${GOPATH}/src/${tests_repo}"
# Kata Containers repository
katacontainers_repo="${kata_github}/kata-containers"
katacontainers_repo_dir="${GOPATH}/src/${katacontainers_repo}"
# Print system info and env variables in case we need to debug
uname -a
env
echo "This Job will test CRI-O changes using Kata Containers runtime."
echo "Testing PR number ${pr_number}."
# Clone the tests repository
mkdir -p $(dirname "${tests_repo_dir}")
[ -d "${tests_repo_dir}" ] || git clone "https://${tests_repo}.git" "${tests_repo_dir}"
source ${tests_repo_dir}/.ci/ci_job_flags.sh
# Clone the kata-containers repository
mkdir -p $(dirname "${katacontainers_repo_dir}")
[ -d "${katacontainers_repo_dir}" ] || git clone "https://${katacontainers_repo}.git" "${katacontainers_repo_dir}"
# Clone the crio repository
mkdir -p $(dirname "${crio_repo_dir}")
[ -d "${crio_repo_dir}" ] || git clone "https://${crio_repo}.git" "${crio_repo_dir}"
if [ "${pr_number}" != "NONE" ]; then
# Checkout to the PR commit and rebase with main
cd "${crio_repo_dir}"
git fetch origin "pull/${pr_number}/head:${pr_branch}"
git checkout "${pr_branch}"
git rebase "origin/${PULL_BASE_REF}"
# And show what we rebased on top of to aid debugging
git log --oneline main~1..HEAD
fi
# Edit critools & kubernetes versions
cd "${katacontainers_repo_dir}"
# Install yq
${GOPATH}/src/${tests_repo}/.ci/install_yq.sh
# CRI-O switched to using go 1.18+
golang_version="1.18.1"
yq w -i versions.yaml languages.golang.meta.newest-version "${golang_version}"
critools_version="${branch_release_number}.0"
[ ${critools_version} == "1.24.0" ] && critools_version="1.24.2"
echo "Using critools ${critools_version}"
yq w -i versions.yaml externals.critools.version "${critools_version}"
yq r versions.yaml externals.critools.version
latest_kubernetes_from_repo=`LC_ALL=C sudo dnf -y repository-packages kubernetes info --available kubelet-${branch_release_number}* | grep Version | cut -d':' -f 2 | xargs`
kubernetes_version="${latest_kubernetes_from_repo}-00"
echo "Using kubernetes ${kubernetes_version}"
yq w -i versions.yaml externals.kubernetes.version "${kubernetes_version}"
yq r versions.yaml externals.kubernetes.version
# Run kata-containers setup
cd "${tests_repo_dir}"
.ci/setup.sh
#echo "CRI-O Version to test:"
#crio --version
# required for cri-o integration tests (see .ci/test_crio.sh)
sudo dnf install -y parallel
.ci/run.sh