Skip to content
This repository has been archived by the owner on Oct 16, 2018. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
prateek committed Mar 15, 2017
0 parents commit 73be090
Show file tree
Hide file tree
Showing 19 changed files with 681 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .ci/.gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "uber-licence"]
path = uber-licence
url = https://github.com/uber/uber-licence.git
19 changes: 19 additions & 0 deletions .ci/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2016 Uber Technologies, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
4 changes: 4 additions & 0 deletions .ci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ci-scripts
==========

This repository contains scripts used by sibling repositories for builds. It's intended to be used as a submodule, conventionally stored as a folder named `.ci` at the root level.
111 changes: 111 additions & 0 deletions .ci/auto-gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/bin/bash
set -x
. "$(dirname $0)/variables.sh"

autogen_clear() {
DIR="$1"

FILES=${DIR}/*
for FILE in $(ls $FILES); do
if [ -d $FILE ]; then
autogen_subdir_clear $FILE
fi
done
}

autogen_subdir_clear() {
DIR="$1"

rm -f ${DIR}/*.go
}

mocks_clear() {
local MOCK_PATTERN=$1
for DIR in $SRC;
do
local MOCKS=${DIR}/$MOCK_PATTERN
if ls $MOCKS &> /dev/null; then
for FILE in $(ls $MOCKS);
do
rm $FILE
done
fi
done
}

autogen_cleanup() {
DIR="$1"

FILES=${DIR}/*
for FILE in $(ls $FILES);
do
if [ -d $FILE ]; then
autogen_cleanup $FILE
else
add_license $FILE $DIR
fi
done
}

mocks_cleanup() {
local MOCK_PATTERN=$1
for DIR in $SRC;
do
local MOCKS=${DIR}/${MOCK_PATTERN}
if ls $MOCKS &> /dev/null; then
for FILE in $(ls $MOCKS);
do
add_license $FILE $DIR

# NB(xichen): there is an open issue (https://github.com/golang/mock/issues/30)
# with mockgen that causes the generated mock files to have vendored packages
# in the import list. For now we are working around it by removing the vendored
# path. Also sed -i'' does not work with BSD sed shipped with OS X, whereas
# sed -i '' doesn't work with GNU sed, so we work around it by redirecting to a
# temp file first and moving it back later.
sed "s|$VENDOR_PATH/||" $FILE > $FILE.tmp && mv $FILE.tmp $FILE

# Strip GOPATH from the source file path
sed "s|Source: $GOPATH/src/\(.*\.go\)|Source: \1|" $FILE > $FILE.tmp && mv $FILE.tmp $FILE
done
fi
done
}

add_license() {
FILE="$1"
DIR="$2"

# Add uber license
PREV_PWD=$(pwd)
cd $DIR
$LICENSE_BIN --silent --file $(basename $FILE)
cd $PREV_PWD
}

if [ $# -ne 2 ] || [ -z "$1" ] || [ -z "$2" ]; then
echo "usage: auto-gen.sh output_directory file_generation_rules_directory"
exit 1
fi

set -e

. "$(dirname $0)/variables.sh"

if [ "$2" = "generated/mocks" ]; then
# NOTE: m3db uses the *_mock.go convention, m3cluster uses mock_*.go
mocks_clear "*_mock.go"
mocks_clear "mock_*.go"
else
autogen_clear $1
fi

go generate $PACKAGE/$2

if [ "$2" = "generated/mocks" ]; then
# NOTE: m3db uses the *_mock.go convention, m3cluster uses mock_*.go
mocks_cleanup "*_mock.go"
mocks_cleanup "mock_*.go"
else
autogen_cleanup $1
fi
11 changes: 11 additions & 0 deletions .ci/common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
install-vendor: install-glide
@echo Installing glide deps
glide --debug install

install-glide:
@which glide > /dev/null || (go get -u github.com/Masterminds/glide && cd $(GOPATH)/src/github.com/Masterminds/glide && git checkout v0.12.3 && go install)
@glide -version > /dev/null || echo "Glide install failed"

install-ci:
make install-vendor

4 changes: 4 additions & 0 deletions .ci/convert-test-data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
. "$(dirname $0)/variables.sh"

sed -i'' -e "s|$PACKAGE/||g" "$1"
7 changes: 7 additions & 0 deletions .ci/gotestcover/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (C) 2015 Pierre Durand

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 changes: 19 additions & 0 deletions .ci/gotestcover/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#/bin/bash

setup:
go get -u -v github.com/golang/lint/golint
go get -v -t ./...

check:
gofmt -d .
go tool vet .
golint

coverage:
gotestcover -coverprofile=coverage.txt github.com/pierrre/gotestcover
go tool cover -html=coverage.txt -o=coverage.html

clean:
-rm coverage.txt
-rm coverage.html
gofmt -w .
19 changes: 19 additions & 0 deletions .ci/gotestcover/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Go test cover with multiple packages support

## Features
- Coverage profile with multiple packages (`go test` doesn't support that)

## Install
`go get github.com/pierrre/gotestcover`

## Usage
```sh
gotestcover -coverprofile=cover.out mypackage
go tool cover -html=cover.out -o=cover.html
```

Run on multiple package with:
- `package1 package2`
- `package/...`

Some `go test / build` flags are available.
Loading

0 comments on commit 73be090

Please sign in to comment.