diff --git a/.ci/run.sh b/.ci/run.sh index a9d5eafd24..3035758b55 100755 --- a/.ci/run.sh +++ b/.ci/run.sh @@ -8,4 +8,4 @@ set -e cidir=$(dirname "$0") -bash "${cidir}/static-checks.sh" +bash "${cidir}/test-install-docs.sh" diff --git a/.ci/setup.sh b/.ci/setup.sh new file mode 100755 index 0000000000..a9d5eafd24 --- /dev/null +++ b/.ci/setup.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# +# Copyright (c) 2018 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# + +set -e + +cidir=$(dirname "$0") +bash "${cidir}/static-checks.sh" diff --git a/.ci/test-install-docs.sh b/.ci/test-install-docs.sh new file mode 100755 index 0000000000..ee3ba9f666 --- /dev/null +++ b/.ci/test-install-docs.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# +# Copyright (c) 2018 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 + +set -e + +info() +{ + msg="$*" + echo "INFO: $msg" +} + +# Detect if any installation guides changed. If so, run the +# kata manager to "execute" the install guide to ensure the +# commands it specified result in a working system. +check_install_guides() +{ + local -r install_guide_suffix="-installation-guide.md" + + # List of filters used to restrict the types of file changes. + # See git-diff-tree(1) for further info. + local filters="" + + # Added file + filters+="A" + + # Copied file + filters+="C" + + # Modified file + filters+="M" + + # Renamed file + filters+="R" + + # Unmerged (U) and Unknown (X) files. These particular filters + # shouldn't be necessary but just in case... + filters+="UX" + + # List of changed files + local files=$(git diff-tree \ + --name-only \ + --no-commit-id \ + --diff-filter="${filters}" \ + -r \ + origin/master HEAD || true) + + # No files were changed + [ -z "$files" ] && return + + changed=$(echo "$files" | grep "install/.*${install_guide_suffix}$" || true) + + [ -z "$changed" ] && info "No install guides modified" && return + + info "Found modified install guides: $changed" + + # Regardless of which distro install guide(s) were changed, we test + # them all where possible. + + local -r GOPATH=$(go env GOPATH) + [ -z "$GOPATH" ] && die "cannot determine GOPATH" + + local -r mgr="${GOPATH}/src/github.com/kata-containers/tests/cmd/kata-manager/kata-manager.sh" + + [ ! -e "$GOPATH" ] && die "cannot find $mgr" + + source /etc/os-release + + info "Installing system from the $ID install guide" + + $mgr install-packages + + [ -n "$TRAVIS" ] && info "Not creating container as Travis lacks VT-x" && return + + $mgr configure-image + $mgr enable-debug + + msg="INFO: Successfully tested install guide for distro '$ID' $VERSION" + + # Perform a basic test + sudo -E docker run --rm -i --runtime "kata-runtime" busybox echo "$msg" +} + +check_install_guides diff --git a/.travis.yml b/.travis.yml index 7e3018601c..d437cc4979 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,8 @@ dist: trusty language: bash +before_script: + - ".ci/setup.sh" + script: - ".ci/run.sh"