Skip to content

Commit

Permalink
Clean up Makefile and scripts in scripts dir.
Browse files Browse the repository at this point in the history
If command is simple command call it from Makefile,
there is no need to have them in separate shell scripts.
  • Loading branch information
kadel committed Jan 20, 2017
1 parent 7836c36 commit 70a2225
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 385 deletions.
13 changes: 1 addition & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,7 @@ install:
- true

script:
- make check-vendor
- make validate
- make test-unit-cover
- make test-all
# gover collects all .coverprofile files and saves it to one file gover.coverprofile
- gover
- goveralls -coverprofile=gover.coverprofile -service=travis-ci

# make test-cmd requires kompose binary
- make bin

# $GOPATH/bin is in $PATH
- mkdir -p $GOPATH/bin
- cp kompose $GOPATH/bin/

- make test-cmd
91 changes: 60 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,57 +13,86 @@
# See the License for the specific language governing permissions and
# limitations under the License.

.PHONY: all

KOMPOSE_ENVS := \
-e OS_PLATFORM_ARG \
-e OS_ARCH_ARG \
-e TESTDIRS \
-e TESTFLAGS \
-e TESTVERBOSE

BIND_DIR := bundles

TEST_IMAGE = "tomaskral/kompose-test:latest"
GITCOMMIT := $(shell git rev-parse --short HEAD)
BUILD_FLAGS := -ldflags="-w -X github.com/kubernetes-incubator/kompose/version.GITCOMMIT=$(GITCOMMIT)"
PKGS := $(shell glide novendor)
TEST_IMAGE := kompose/tests:latest

default: bin

all: validate
CGO_ENABLED=1 ./script/make.sh
.PHONY: all
all: bin

.PHONY: bin
bin:
CGO_ENABLED=1 ./script/make.sh binary
go build ${BUILD_FLAGS} -o kompose main.go

.PHONY: install
install:
go install ${BUILD_FLAGS}

# kompile kompose for multiple platforms
.PHONY: cross
cross:
# CGO_ENABLED=1 ./script/make.sh binary-cross
./script/make.sh binary-cross
gox -os="darwin linux windows" -arch="386 amd64" -output="bundles/kompose_{{.OS}}-{{.Arch}}/kompose" $(BUILD_FLAGS)

.PHONY: clean
clean:
./script/make.sh clean
rm -f kompose
rm -r -f bundles

.PHONY: test-unit
test-unit:
./script/make.sh test-unit
test-cmd:
./script/make.sh test-cmd
go test $(BUILD_FLAGS) -race -cover -v $(PKGS)

# Run unit tests and collect coverage
.PHONY: test-unit-cover
test-unit-cover:
./script/make.sh test-unit-cover
# First install packages that are dependencies of the test.
go test -i -race -cover $(PKGS)
# go test doesn't support colleting coverage across multiple packages,
# generate go test commands using go list and run go test for every package separately
go list -f '"go test -race -cover -v -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}"' github.com/kubernetes-incubator/kompose/... | grep -v "vendor" | xargs -L 1 -P4 sh -c

# run commandline tests
.PHONY: test-cmd
test-cmd:
./script/test/cmd/tests.sh

# run all validation tests
.PHONY: validate
validate: gofmt vet lint

.PHONY: vet
vet:
./script/make.sh validate-vet
go vet $(PKGS)

.PHONY: lint
lint:
./script/make.sh validate-lint
./script/check-lint.sh

.PHONY: gofmt
gofmt:
./script/make.sh validate-gofmt
./script/check-gofmt.sh

# Checks if there are nested vendor dirs inside Kompose vendor and if vendor was cleaned by glide-vc
.PHONY: check-vendor
check-vendor:
./script/make.sh check-vendor
./script/check-vendor.sh

# Run all tests
.PHONY: test-all
test-all: check-vendor validate test-unit-cover install test-cmd

# build docker image that is used for running all test localy
.PHONY: test-image
test-image:
docker build -t $(TEST_IMAGE) -f script/test_in_container/Dockerfile script/test_in_container/

# run all test localy in docker image (image can be build by by build-test-image target)
.PHONY: test
test:
docker run -v `pwd`:/opt/tmp/kompose:ro -it $(TEST_IMAGE)

# build docker image that is used for running travis test localy
build-test-image:
docker build -t $(TEST_IMAGE) -f script/tests_in_container/Dockerfile .

# run travis test localy using docker image (build by build-test-image target)
test-docker:
docker run -v `pwd`:/opt/tmp/kompose:ro -it $(TEST_IMAGE)
19 changes: 0 additions & 19 deletions script/.build

This file was deleted.

18 changes: 0 additions & 18 deletions script/.validate

This file was deleted.

28 changes: 0 additions & 28 deletions script/bash_autocomplete

This file was deleted.

36 changes: 0 additions & 36 deletions script/binary

This file was deleted.

42 changes: 0 additions & 42 deletions script/binary-cross

This file was deleted.

5 changes: 2 additions & 3 deletions script/validate-gofmt → script/check-gofmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

source "$(dirname "$BASH_SOURCE")/.validate"

GO_FILES=$(find . -path ./vendor -prune -o -name '*.go' -print )
# This checks if all go source files in current directory are format using gofmt

GO_FILES=$(find . -path ./vendor -prune -o -name '*.go' -print )

for file in $GO_FILES; do
gofmtOutput=$(gofmt -l "$file")
Expand All @@ -27,7 +27,6 @@ for file in $GO_FILES; do
done



if [ ${#errors[@]} -eq 0 ]; then
echo "gofmt OK"
else
Expand Down
3 changes: 1 addition & 2 deletions script/validate-lint → script/check-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ set -e
# See the License for the specific language governing permissions and
# limitations under the License.

source "$(dirname "$BASH_SOURCE")/.validate"

for pkg in $PKGS; do
for pkg in $(glide novendor); do
lintOutput=$(golint "$pkg")
# if lineOutput is not empty, save it to errros array
if [ "$lintOutput" ]; then
Expand Down
7 changes: 3 additions & 4 deletions script/check-vendor → script/check-vendor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.



# Check if there are nested vendor dirs inside Kompose vendor.
# All dependencies should be flattened and there shouldn't be vendor in inside vendor.

function check_nested_vendor() {
echo "Checking if there are nested vendor dirs"
echo "Checking for nested vendor dirs"

# count all vendor directories inside Kompose vendor
NO_NESTED_VENDORS=$(find vendor/ -type d | sed 's/^[^/]*.//g' | grep -E "vendor$" | grep -v _vendor | wc -l)
Expand All @@ -41,7 +40,7 @@ function check_glide-vc() {
echo "Checking if vendor was cleaned using glide-vc."

# dry run glide-vc and count how many could be deleted.
NO_DELETED_FILES=$($GOPATH/bin/glide-vc --only-code --no-tests --dryrun | wc -l)
NO_DELETED_FILES=$(glide-vc --only-code --no-tests --dryrun | wc -l)

if [ $NO_DELETED_FILES -ne 0 ]; then
echo "ERROR"
Expand Down
46 changes: 0 additions & 46 deletions script/make.sh

This file was deleted.

Loading

0 comments on commit 70a2225

Please sign in to comment.