Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

CI: Use specific version of xurls utility #856

Merged
merged 10 commits into from
Oct 26, 2018
68 changes: 57 additions & 11 deletions .ci/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,49 @@ info() {
echo -e "INFO: $*"
}

function build() {
function build_version() {
github_project="$1"
make_target="$2"
version="$3"

[ -z "${version}" ] && die "need version to build"

project_dir="${GOPATH}/src/${github_project}"

[ -d "${project_dir}" ] || go get "${github_project}" || true
[ -d "${project_dir}" ] || go get -d "${github_project}" || true

pushd "${project_dir}"

if [ "$version" != "HEAD" ]; then
info "Using ${github_project} version ${version}"
git checkout -b "${version}" "${version}"
fi

info "Building ${github_project}"
if [ ! -f Makefile ]; then
info "Run autogen.sh to generate Makefile"
bash -f autogen.sh
if [ -f autogen.sh ]; then
info "Run autogen.sh to generate Makefile"
bash -f autogen.sh
fi
fi

make
if [ -f Makefile ]; then
make ${make_target}
else
# install locally (which is what "go get" does by default)
go install ./...
fi

popd
}

function build() {
github_project="$1"
make_target="$2"

build_version "${github_project}" "${make_target}" "HEAD"
}

function build_and_install() {
github_project="$1"
make_target="$2"
Expand Down Expand Up @@ -103,20 +126,43 @@ function install_yq() {
fi
}

function get_dep_from_yaml_db(){
local versions_file="$1"
local dependency="$2"

[ ! -f "$versions_file" ] && die "cannot find $versions_file"

install_yq >&2

result=$("${GOPATH}/bin/yq" read "$versions_file" "$dependency")
[ "$result" = "null" ] && result=""
echo "$result"
}

function get_version(){
dependency="$1"
GOPATH=${GOPATH:-${HOME}/go}
# This is needed in order to retrieve the version for qemu-lite
install_yq >&2
runtime_repo="github.com/kata-containers/runtime"
runtime_repo_dir="$GOPATH/src/${runtime_repo}"
versions_file="${runtime_repo_dir}/versions.yaml"
mkdir -p "$(dirname ${runtime_repo_dir})"
[ -d "${runtime_repo_dir}" ] || git clone --quiet https://${runtime_repo}.git "${runtime_repo_dir}"
[ ! -f "$versions_file" ] && { echo >&2 "ERROR: cannot find $versions_file"; exit 1; }
result=$("${GOPATH}/bin/yq" read "$versions_file" "$dependency")
[ "$result" = "null" ] && result=""
echo "$result"

get_dep_from_yaml_db "${versions_file}" "${dependency}"
}

function get_test_version(){
local dependency="$1"

local db
local cidir

# directory of this script, not the caller
local cidir=$(dirname "${BASH_SOURCE[0]}")

db="${cidir}/../versions.yaml"

get_dep_from_yaml_db "${db}" "${dependency}"
}

function check_gopath() {
Expand Down
11 changes: 10 additions & 1 deletion .ci/static-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,16 @@ check_docs()
if [ ! "$(command -v $cmd)" ]
then
info "Installing $cmd utility"
go get -u "github.com/mvdan/xurls/cmd/${cmd}"

local version
local url
local dir

version=$(get_test_version "externals.xurls.version")
url=$(get_test_version "externals.xurls.url")
dir=$(echo "$url"|sed 's!https://!!g')

build_version "${dir}" "" "${version}"
fi

info "Checking documentation"
Expand Down
27 changes: 22 additions & 5 deletions versions.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
---

#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#

description: |
This file contains test specific version details.
For other version details, see the master database:

https://github.com/kata-containers/runtime/blob/master/versions.yaml

docker_images:
description: "Docker hub images used for testing"

nginx:
description: "Proxy server for HTTP, HTTPS, SMTP, POP3 and IMAP protocols"
url: "https://hub.docker.com/_/nginx/"
version: "1.14"

alpine:
description: "Linux distribution built around busybox and musl libc"
url: "https://hub.docker.com/_/alpine/"
Expand All @@ -21,3 +24,17 @@ docker_images:
description: "Open source analytics and visualization platform"
url: "https://hub.docker.com/_/kibana/"
version: "6.4.0"

nginx:
description: "Proxy server for HTTP, HTTPS, SMTP, POP3 and IMAP protocols"
url: "https://hub.docker.com/_/nginx/"
version: "1.14"

externals:
description: "Third-party projects used specifically for testing"

xurls:
description: |
Tool used by the CI to check URLs in documents and code comments.
url: "https://mvdan.cc/xurls/cmd/xurls"
version: "70405f5eab516c9f7b626d803b043415809499a6"