Clean up Makefile and scripts in scripts dir.

If command is simple command call it from Makefile,
there is no need to have them in separate shell scripts.
This commit is contained in:
Tomas Kral
2017-01-23 11:49:25 +01:00
parent f530f99f02
commit 20b844d6e9
16 changed files with 67 additions and 385 deletions
+60 -31
View File
@@ -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
test-unit-cover:
./script/make.sh test-unit-cover
go test $(BUILD_FLAGS) -race -cover -v $(PKGS)
# Run unit tests and collect coverage
.PHONY: test-unit-cover
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
# 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 all tests
.PHONY: test-all
test-all: check-vendor validate test-unit-cover install test-cmd
# run travis test localy using docker image (build by build-test-image target)
test-docker:
# 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)