Merge pull request #93 from kadel/travis-tests

Run tests on travis-ci
This commit is contained in:
Tomas Kral 2016-08-11 17:08:29 +02:00 committed by GitHub
commit e7dfff5252
8 changed files with 100 additions and 29 deletions

View File

@ -1,18 +1,21 @@
# we need trusty because test-cmd depends on jq version >= 1.5
dist : trusty
sudo: required
language: go
go:
- 1.6
branches:
only:
- master
install:
- go get github.com/mitchellh/gox
- go get github.com/tools/godep
- ./script/godep-restore.sh
- true
script:
- make binary
- make binary
# $GOPATH/bin is in $PATH
- mkdir -p $GOPATH/bin
- cp kompose $GOPATH/bin/
- make test-unit
- make test-cmd

View File

@ -16,3 +16,15 @@ all:
binary:
CGO_ENABLED=0 ./script/make.sh binary
binary-cross:
CGO_ENABLED=0 ./script/make.sh binary-cross
clean:
./script/make.sh clean
test-unit:
./script/make.sh test-unit
test-cmd:
./script/make.sh test-cmd

View File

@ -71,7 +71,7 @@ file "redis-deployment.json" created
The default `kompose` transformation will generate Kubernetes [Deployments](http://kubernetes.io/docs/user-guide/deployments/) and [Services](http://kubernetes.io/docs/user-guide/services/), in json format. You have alternative option to generate yaml with `-y`. Also, you can alternatively generate [Replication Controllers](http://kubernetes.io/docs/user-guide/replication-controller/) objects, [Deamon Sets](http://kubernetes.io/docs/admin/daemons/), or [Helm](https://github.com/helm/helm) charts.
```console
$ kompose convert
$ kompose convert
file "redis-svc.json" created
file "web-svc.json" created
file "redis-deployment.json" created
@ -180,7 +180,7 @@ You need `-tags experimental` because the current `bundlefile` package of docker
- You need `make`
```console
$ make binary
$ make binary-cross
```
## Contributing and Issues

5
script/.build Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
GITCOMMIT=$(git rev-parse --short HEAD)
BUILD_FLAGS=(-tags experimental -ldflags="-w -X github.com/skippbox/kompose/version.GITCOMMIT=${GITCOMMIT}")

View File

@ -1,26 +1,21 @@
#!/bin/bash
set -e
if [ -z "$1" ]; then
OS_PLATFORM_ARG=(-os="darwin linux windows")
else
OS_PLATFORM_ARG=($1)
fi
source "$(dirname "$BASH_SOURCE")/.build"
if [ -z "$2" ]; then
OS_ARCH_ARG=(-arch="386 amd64")
else
OS_ARCH_ARG=($2)
fi
OUT_FILE="./kompose"
GITCOMMIT=$(git rev-parse --short HEAD)
# Get rid of existing binary
rm -f $OUT_FILE
# Get rid of existing binaries
rm -f kompose*
# Build binaries
gox "${OS_PLATFORM_ARG[@]}" "${OS_ARCH_ARG[@]}" \
-output="bundles/kompose_{{.OS}}-{{.Arch}}/kompose" \
-tags experimental \
-ldflags="-w -X github.com/skippbox/kompose/version.GITCOMMIT=${GITCOMMIT}" \
# Build binary
go build \
"${BUILD_FLAGS[@]}" \
-o $OUT_FILE \
./cli/main
if [ $? -eq 0 ]; then
echo "Build successful. Program saved as ${OUT_FILE}"
else
echo "Build failed."
fi

27
script/binary-cross Normal file
View File

@ -0,0 +1,27 @@
#!/bin/bash
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[@]}" \
./cli/main

3
script/test-cmd Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
./script/test/cmd/tests.sh

26
script/test-unit Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
set -e
source "$(dirname "$BASH_SOURCE")/.build"
find_dirs() {
(
find . -not \( \
\( \
-path './vendor/*' \
\) -prune \
\) -name '*_test.go' -print0 | xargs -0n1 dirname | sed 's|^\./||' | sort -u
)
}
TEST_FLAGS=("${BUILD_FLAGS[@]}" -cover -coverprofile=cover.out)
if [ -z "$TEST_DIRS" ]; then
TEST_DIRS=$(find_dirs '*_test.go')
fi
TESTS_FAILED=()
for dir in $TEST_DIRS; do
go test "${TEST_FLAGS[@]}" "./${dir}"
done