-
Notifications
You must be signed in to change notification settings - Fork 22
Initial push #1
Initial push #1
Changes from all commits
8c83a88
89d9804
21084a1
81c8bf2
05d2b5a
dcaf3ef
89cf6d1
a8ba9e3
c18cf70
47d21ef
ac6e1e9
3eee0da
b9ef158
371788c
90dece9
d86c1cf
d896625
6ea86f1
8f30bc1
b79782c
3576587
a4008f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2017 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
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}" ./... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2017 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
version: 2 | ||
|
||
requirements: | ||
signed_off_by: | ||
required: true | ||
|
||
# Disallow approval of PRs still under development | ||
always_pending: | ||
title_regex: 'WIP' | ||
labels: | ||
- do-not-merge | ||
- wip | ||
explanation: 'Work in progress - do not merge' | ||
|
||
group_defaults: | ||
approve_by_comment: | ||
enabled: true | ||
approve_regex: '^(LGTM|lgtm|Approved|\+1|:\+1:)' | ||
reject_regex: '^(Rejected|-1|:-1:)' | ||
reset_on_push: | ||
enabled: false | ||
reset_on_reopened: | ||
enabled: false | ||
author_approval: | ||
ignored: true | ||
|
||
groups: | ||
approvers: | ||
required: 1 | ||
teams: | ||
- proxy |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
language: go | ||
sudo: required | ||
go: | ||
- 1.8 | ||
- 1.9 | ||
- tip | ||
go_import_path: github.com/kata-containers/ksm-throttler | ||
|
||
before_install: | ||
- go get github.com/mattn/goveralls | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
- go test -race -coverprofile=coverage.txt -covermode=atomic | ||
|
||
after_success: | ||
- "$GOPATH/bin/goveralls -service=travis-ci -coverprofile=/tmp/cover.out" | ||
- bash <(curl -s https://codecov.io/bash) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[[constraint]] | ||
name = "github.com/golang/protobuf" | ||
revision = "1e59b77b52bf8e4b449a57e6f79f21226d571845" | ||
|
||
[[constraint]] | ||
name = "github.com/sirupsen/logrus" | ||
version = "1.0.3" | ||
|
||
[[constraint]] | ||
name = "golang.org/x/net" | ||
revision = "a337091b0525af65de94df2eb7e98bd9962dcbe2" | ||
|
||
[[constraint]] | ||
name = "google.golang.org/grpc" | ||
version = "1.7.3" | ||
|
||
[[constraint]] | ||
name = "github.com/stretchr/testify" | ||
revision = "2aa2c176b9dab406a6970f6a55f513e8a8c8b18f" | ||
|
||
[[constraint]] | ||
name = "github.com/fsnotify/fsnotify" | ||
revision = "4da3e2cfbabc9f751898f250b49f2439785783a1" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
VERSION := 0.1+ | ||
|
||
PACKAGE = github.com/kata-containers/ksm-throttler | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The github URL is used in a lot of places. It's not a blocker for this PR of course, but I wonder if we could standardise on something like |
||
BASE = $(GOPATH)/src/$(PACKAGE) | ||
PREFIX = /usr | ||
BIN_DIR = $(PREFIX)/bin | ||
LIBEXECDIR = $(PREFIX)/libexec | ||
LOCALSTATEDIR = /var | ||
SOURCES = $(shell find . 2>&1 | grep -E '.*\.(c|h|go)$$') | ||
KSM_SOCKET = $(LOCALSTATEDIR)/run/ksm-throttler/ksm.sock | ||
TRIGGER_DIR = $(GOPATH)/src/$(PACKAGE)/trigger | ||
GO = go | ||
PKGS = $(or $(PKG),$(shell cd $(BASE) && env GOPATH=$(GOPATH) $(GO) list ./... | grep -v "/vendor/")) | ||
|
||
DESCRIBE := $(shell git describe 2> /dev/null || true) | ||
DESCRIBE_DIRTY := $(if $(shell git status --porcelain --untracked-files=no 2> /dev/null),${DESCRIBE}-dirty,${DESCRIBE}) | ||
ifneq ($(DESCRIBE_DIRTY),) | ||
VERSION := $(DESCRIBE_DIRTY) | ||
endif | ||
|
||
# | ||
# Pretty printing | ||
# | ||
|
||
V = @ | ||
Q = $(V:1=) | ||
QUIET_GOBUILD = $(Q:@=@echo ' GOBUILD '$@;) | ||
|
||
# | ||
# Build | ||
# | ||
|
||
all: build binaries | ||
|
||
build: | ||
$(QUIET_GOBUILD)go build $(PKGS) | ||
|
||
throttler: | ||
$(QUIET_GOBUILD)go build -o ksm-throttler -ldflags \ | ||
"-X main.DefaultURI=$(KSM_SOCKET) -X main.Version=$(VERSION)" throttler.go ksm.go | ||
|
||
kicker: | ||
$(QUIET_GOBUILD)go build -o $(TRIGGER_DIR)/kicker/$@ \ | ||
-ldflags "-X main.DefaultURI=$(KSM_SOCKET)" $(TRIGGER_DIR)/kicker/*.go | ||
|
||
virtcontainers: | ||
$(QUIET_GOBUILD)go build -o $(TRIGGER_DIR)/virtcontainers/vc \ | ||
-ldflags "-X main.DefaultURI=$(KSM_SOCKET)" $(TRIGGER_DIR)/virtcontainers/*.go | ||
|
||
binaries: throttler kicker virtcontainers | ||
|
||
# | ||
# systemd files | ||
# | ||
|
||
HAVE_SYSTEMD := $(shell pkg-config --exists systemd 2>/dev/null && echo 'yes') | ||
|
||
ifeq ($(HAVE_SYSTEMD),yes) | ||
UNIT_DIR := $(shell pkg-config --variable=systemdsystemunitdir systemd) | ||
UNIT_FILES = ksm-throttler.service vc-throttler.service | ||
GENERATED_FILES += $(UNIT_FILES) | ||
endif | ||
|
||
# | ||
# Tests | ||
# | ||
|
||
check: check-go-static check-go-test | ||
|
||
check-go-static: | ||
bash .ci/go-lint.sh | ||
|
||
check-go-test: | ||
bash .ci/go-test.sh | ||
|
||
# | ||
# install | ||
# | ||
|
||
define INSTALL_EXEC | ||
$(QUIET_INST)install -D $1 $(DESTDIR)$2/$1 || exit 1; | ||
|
||
endef | ||
define INSTALL_FILE | ||
$(QUIET_INST)install -D -m 644 $1 $(DESTDIR)$2/$1 || exit 1; | ||
|
||
endef | ||
|
||
all-installable: ksm-throttler virtcontainers $(UNIT_FILES) | ||
|
||
install: all-installable | ||
$(call INSTALL_EXEC,ksm-throttler,$(LIBEXECDIR)/ksm-throttler) | ||
$(call INSTALL_EXEC,trigger/virtcontainers/vc,$(LIBEXECDIR)/ksm-throttler) | ||
$(foreach f,$(UNIT_FILES),$(call INSTALL_FILE,$f,$(UNIT_DIR))) | ||
|
||
# | ||
# Clean | ||
# | ||
|
||
clean: | ||
rm -f ksm-throttler | ||
rm -f $(TRIGGER_DIR)/kicker/kicker | ||
rm -f $(TRIGGER_DIR)/virtcontainers/vc | ||
|
||
$(GENERATED_FILES): %: %.in Makefile | ||
@mkdir -p `dirname $@` | ||
$(QUIET_GEN)sed \ | ||
-e 's|[@]bindir[@]|$(BINDIR)|g' \ | ||
-e 's|[@]libexecdir[@]|$(LIBEXECDIR)|' \ | ||
-e "s|[@]localstatedir[@]|$(LOCALSTATEDIR)|" \ | ||
"$<" > "$@" | ||
|
||
.PHONY: \ | ||
all \ | ||
build \ | ||
binaries \ | ||
check \ | ||
check-go-static \ | ||
check-go-test \ | ||
install \ | ||
uninstall \ | ||
clean |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
reviewers: | ||
- proxy | ||
|
||
approvers: | ||
- proxy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: I've just added these labels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.