forked from LaconicNetwork/kompose
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:
parent
f530f99f02
commit
20b844d6e9
13
.travis.yml
13
.travis.yml
@ -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
Makefile
91
Makefile
@ -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)
|
||||
|
||||
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
GITCOMMIT=$(git rev-parse --short HEAD)
|
||||
|
||||
BUILD_FLAGS=(-ldflags="-w -X github.com/kubernetes-incubator/kompose/version.GITCOMMIT=${GITCOMMIT}")
|
||||
@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# all Kompose packages (skip vendor dir)
|
||||
PKGS=$( go list -e ./... | grep -v '/vendor/' )
|
||||
@ -1,28 +0,0 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
: ${PROG:=$(basename ${BASH_SOURCE})}
|
||||
|
||||
_cli_bash_autocomplete() {
|
||||
local cur opts base
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _cli_bash_autocomplete $PROG
|
||||
@ -1,36 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
source "$(dirname "$BASH_SOURCE")/.build"
|
||||
|
||||
OUT_FILE="./kompose"
|
||||
|
||||
# Get rid of existing binary
|
||||
rm -f $OUT_FILE
|
||||
|
||||
# Build binary
|
||||
go build \
|
||||
"${BUILD_FLAGS[@]}" \
|
||||
-o $OUT_FILE \
|
||||
main.go
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Build successful. Program saved as ${OUT_FILE}"
|
||||
else
|
||||
echo "Build failed."
|
||||
fi
|
||||
@ -1,42 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
source "$(dirname "$BASH_SOURCE")/.build"
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
OS_PLATFORM_ARG=(-os="darwin linux windows")
|
||||
else
|
||||
OS_PLATFORM_ARG=($1)
|
||||
fi
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
OS_ARCH_ARG=(-arch="386 amd64")
|
||||
else
|
||||
OS_ARCH_ARG=($2)
|
||||
fi
|
||||
|
||||
GITCOMMIT=$(git rev-parse --short HEAD)
|
||||
|
||||
# Get rid of existing binaries
|
||||
rm -f kompose*
|
||||
|
||||
# Build binaries
|
||||
gox "${OS_PLATFORM_ARG[@]}" "${OS_ARCH_ARG[@]}" \
|
||||
-output="bundles/kompose_{{.OS}}-{{.Arch}}/kompose" \
|
||||
"${BUILD_FLAGS[@]}" \
|
||||
.
|
||||
@ -14,11 +14,11 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
source "$(dirname "$BASH_SOURCE")/.validate"
|
||||
|
||||
# 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")
|
||||
if [ "$gofmtOutput" ]; then
|
||||
@ -27,7 +27,6 @@ for file in $GO_FILES; do
|
||||
done
|
||||
|
||||
|
||||
|
||||
if [ ${#errors[@]} -eq 0 ]; then
|
||||
echo "gofmt OK"
|
||||
else
|
||||
@ -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
|
||||
@ -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)
|
||||
@ -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"
|
||||
@ -1,46 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
export KOMPOSE_PKG='github.com/kubernetes-incubator/kompose'
|
||||
|
||||
# List of bundles to create when no argument is passed
|
||||
DEFAULT_BUNDLES=(
|
||||
validate-gofmt
|
||||
validate-git-marks
|
||||
validate-lint
|
||||
validate-vet
|
||||
binary
|
||||
)
|
||||
bundle() {
|
||||
local bundle="$1"; shift
|
||||
echo "---> Making bundle: $(basename "$bundle") (in $DEST)"
|
||||
source "script/$bundle" "$@"
|
||||
}
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
bundles=(${DEFAULT_BUNDLES[@]})
|
||||
else
|
||||
bundles=($@)
|
||||
fi
|
||||
for bundle in ${bundles[@]}; do
|
||||
export DEST=.
|
||||
ABS_DEST="$(cd "$DEST" && pwd -P)"
|
||||
bundle "$bundle"
|
||||
echo
|
||||
done
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
./script/test/cmd/tests.sh
|
||||
@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
source "$(dirname "$BASH_SOURCE")/.build"
|
||||
|
||||
go test "${BUILD_FLAGS[@]}" -race -cover -v $( go list github.com/kubernetes-incubator/kompose/... | grep -v '/vendor/' )
|
||||
@ -1,27 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
source "$(dirname "$BASH_SOURCE")/.build"
|
||||
|
||||
|
||||
# Install packages that are dependencies of the test. (this will speed up go test runs)
|
||||
go test -i -race -cover $( go list github.com/kubernetes-incubator/kompose/... | grep -v '/vendor/' )
|
||||
|
||||
# go test doesn't support colleting coverage across multiple packages,
|
||||
# so this is why this runs go test for each package separately
|
||||
# generate go test commands using go list and run tests
|
||||
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
|
||||
@ -1,58 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
source "$(dirname "$BASH_SOURCE")/.validate"
|
||||
|
||||
# folders=$(find * -type d | egrep -v '^Godeps|bundles|.git')
|
||||
|
||||
IFS=$'\n'
|
||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*' | grep -v '^vendor/' || true) )
|
||||
unset IFS
|
||||
|
||||
badFiles=()
|
||||
for f in "${files[@]}"; do
|
||||
if [ $(grep -r "^<<<<<<<" $f) ]; then
|
||||
badFiles+=( "$f" )
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ $(grep -r "^>>>>>>>" $f) ]; then
|
||||
badFiles+=( "$f" )
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ $(grep -r "^=======$" $f) ]; then
|
||||
badFiles+=( "$f" )
|
||||
continue
|
||||
fi
|
||||
set -e
|
||||
done
|
||||
|
||||
|
||||
if [ ${#badFiles[@]} -eq 0 ]; then
|
||||
echo 'Congratulations! There is no conflict.'
|
||||
else
|
||||
{
|
||||
echo "There is trace of conflict(s) in the following files :"
|
||||
for f in "${badFiles[@]}"; do
|
||||
echo " - $f"
|
||||
done
|
||||
echo
|
||||
echo 'Please fix the conflict(s) commit the result.'
|
||||
echo
|
||||
} >&2
|
||||
false
|
||||
fi
|
||||
@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
source "$(dirname "$BASH_SOURCE")/.validate"
|
||||
|
||||
go vet $PKGS;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user