From 997312e574aee0db007feb8f91e9cfbc5c075a2b Mon Sep 17 00:00:00 2001 From: Graham Whaley Date: Thu, 30 Apr 2020 13:26:29 +0100 Subject: [PATCH] CI: enable Travis for static checks Enable the Travis CI configuration to perform static CI checks on PRs to this repo. Fixes: #1031 Signed-off-by: Graham Whaley --- .ci/lib.sh | 34 ++++++++++++++++++++++++++++++++++ .ci/static-checks.sh | 15 +++++++-------- .travis.yml | 24 ++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 .ci/lib.sh create mode 100644 .travis.yml diff --git a/.ci/lib.sh b/.ci/lib.sh new file mode 100644 index 0000000000..475658d9f5 --- /dev/null +++ b/.ci/lib.sh @@ -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" +} diff --git a/.ci/static-checks.sh b/.ci/static-checks.sh index d314c49547..54c1042ee5 100755 --- a/.ci/static-checks.sh +++ b/.ci/static-checks.sh @@ -1,14 +1,13 @@ #!/bin/bash # -# Copyright (c) 2018 Intel Corporation +# Copyright (c) 2018,2020 Intel Corporation # # SPDX-License-Identifier: Apache-2.0 -# -set -o errexit -set -o nounset -set -o pipefail +set -e -# This script should run any static analysis check -# It is called by the CI setup -true +cidir=$(dirname "$0") +source "${cidir}/lib.sh" + +# Run static checks +run_static_checks diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..722f54b796 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +# +# Copyright 2017 HyperHQ Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +sudo: required +dist: bionic + +os: + - linux + - linux-ppc64le + +language: go +go_import_path: github.com/kata-containers/packaging + +env: + - target_branch=$TRAVIS_BRANCH + +before_script: + - ".ci/setup.sh" + +script: + - bash .ci/static-checks.sh github.com/kata-containers/packaging