Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Initial push #1

Merged
merged 22 commits into from
Nov 16, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .ci/go-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright (c) 2017 Intel Corporation
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to keep that ?


# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is redundant as it's isn't the first - same comment applies to go-test.sh.


if [ ! $(command -v gometalinter) ]
then
go get github.com/alecthomas/gometalinter
gometalinter --install --vendor
fi

linter_args="--tests --vendor"

# When running the linters in a CI environment we need to disable them all
# by default and then explicitly enable the ones we are care about. This is
# necessary since *if* gometalinter adds a new linter, that linter may cause
# the CI build to fail when it really shouldn't. However, when this script is
# run locally, all linters should be run to allow the developer to review any
# failures (and potentially decide whether we need to explicitly enable a new
# linter in the CI).
if [ "$CI" = true ]; then
linter_args+=" --disable-all"
fi

linter_args+=" --enable=misspell"
linter_args+=" --enable=vet"
linter_args+=" --enable=ineffassign"
linter_args+=" --enable=gofmt"
linter_args+=" --enable=gocyclo"
linter_args+=" --cyclo-over=15"
linter_args+=" --enable=golint"
linter_args+=" --deadline=600s"

eval gometalinter "${linter_args}" ./...
28 changes: 28 additions & 0 deletions .ci/go-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) 2017 Intel Corporation

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#!/bin/bash

set -e

test_packages=$(go list ./... | grep -v vendor)
echo "Run go test and generate coverage:"
for pkg in $test_packages; do
if [ "$pkg" = "github.com/kata-containers/ksm-throttler" ]; then
sudo env GOPATH=$GOPATH GOROOT=$GOROOT PATH=$PATH go test -cover -coverprofile=profile.cov $pkg
else
sudo env GOPATH=$GOPATH GOROOT=$GOROOT PATH=$PATH go test -cover $pkg
fi
done
41 changes: 41 additions & 0 deletions .ci/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
#
# Copyright (c) 2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set -e

cidir=$(dirname "$0")
tests_repo="github.com/clearcontainers/tests"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably this is just a temporary URL until we populate https://github.com/kata-containers/tests?


# Clone Tests repository.
go get "$tests_repo"

tests_repo_dir="${GOPATH}/src/${tests_repo}"

echo "Update proxy and runtime vendoring"
sudo -E PATH=$PATH bash -c "${cidir}/update-vendoring.sh"

pushd "${tests_repo_dir}"
echo "Setup Clear Containers"
sudo -E PATH=$PATH bash -c ".ci/setup.sh"
popd

echo "Setup virtcontainers environment"
chronic sudo -E PATH=$PATH bash -c "${cidir}/../utils/virtcontainers-setup.sh"

echo "Install virtcontainers"
chronic make
chronic sudo make install
37 changes: 37 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
language: go
sudo: required
go:
- 1.7
- 1.8
- tip
go_import_path: github.com/kata-containers/ksm-throttler

before_install:
- go get github.com/mattn/goveralls
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an idea, but how about trying out codecov.io instead? clearcontainers/jenkins#28 Or we could run both and see how they compare?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

- go get golang.org/x/tools/cmd/cover
- go get github.com/pierrre/gotestcover
- go get github.com/fzipp/gocyclo
- go get github.com/gordonklaus/ineffassign
- go get github.com/golang/lint/golint
- go get github.com/client9/misspell/cmd/misspell
- go get github.com/ciao-project/ciao/test-cases

install:
- go_packages=$(go list ./... | grep -v vendor)
- go_files=`go list -f '{{.Dir}}/*.go' $go_packages`
- go get -t -v $go_packages

script:
- go env
- misspell -error $go_packages
- go vet $go_packages
- if [[ "$TRAVIS_GO_VERSION" != "tip" ]] ; then golint $go_packages; fi
- gocyclo -over 15 $go_files
- go list -f '{{.Dir}}' $go_packages | xargs -L 1 ineffassign
- gofmt -s -l $go_files | wc -l | xargs -I % bash -c "test % -eq 0"
- make
- make check
- export GOROOT=`go env GOROOT` && sudo -E PATH=$PATH:$GOROOT/bin $GOPATH/bin/test-cases -v -timeout 9 -short -coverprofile /tmp/cover.out $go_packages

after_success:
- "$GOPATH/bin/goveralls -service=travis-ci -coverprofile=/tmp/cover.out"
54 changes: 54 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
PREFIX := /usr
BIN_DIR := $(PREFIX)/bin

#
# Pretty printing
#

V = @
Q = $(V:1=)
QUIET_GOBUILD = $(Q:@=@echo ' GOBUILD '$@;)

#
# Build
#

all: build binaries

build:
$(QUIET_GOBUILD)go build $(go list ./... | grep -v /vendor/)

throttler:
$(QUIET_GOBUILD)go build -o ksm-throttler throttler.go ksm.go

binaries: throttler

#
# Tests
#

check: check-go-static check-go-test

check-go-static:
bash .ci/go-lint.sh

check-go-test:
bash .ci/go-test.sh

#
# Clean
#

clean:
rm -f ksm-throttler

.PHONY: \
all \
build \
binaries \
check \
check-go-static \
check-go-test \
install \
uninstall \
clean
Loading