Просмотр исходного кода

Merge pull request #5 from eyakubovich/travis-ci

integrate TravisCI
Eugene Yakubovich 9 лет назад
Родитель
Сommit
12b3adce0f
5 измененных файлов с 118 добавлено и 0 удалено
  1. 9 0
      .travis.yml
  2. 2 0
      README.md
  3. 21 0
      build
  4. 36 0
      build-check
  5. 50 0
      test

+ 9 - 0
.travis.yml

@@ -0,0 +1,9 @@
+language: go
+go:
+  - 1.4
+
+install:
+ - go get golang.org/x/tools/cmd/cover
+
+script:
+ - ./build-check

+ 2 - 0
README.md

@@ -1,5 +1,7 @@
 # go-iptables
 
+[![Build Status](https://travis-ci.org/coreos/go-iptables.png?branch=master)](https://travis-ci.org/coreos/go-iptables)
+
 Go bindings for iptables utility.
 
 In-kernel netfilter does not have a good userspace API. The tables are manipulated via setsockopt that sets/replaces the entire table. Changes to existing table need to be resolved by userspace code which is difficult and error-prone. Netfilter developers heavily advocate using iptables utlity for programmatic manipulation.

+ 21 - 0
build

@@ -0,0 +1,21 @@
+#!/bin/bash -e
+
+ORG_PATH="github.com/coreos"
+REPO_PATH="${ORG_PATH}/go-iptables"
+
+if [ ! -h gopath/src/${REPO_PATH} ]; then
+	mkdir -p gopath/src/${ORG_PATH}
+	ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255
+fi
+
+export GOBIN=${PWD}/bin
+export GOPATH=${PWD}/gopath
+
+eval $(go env)
+
+if [ ${GOOS} = "linux" ]; then
+	echo "Building go-iptables..."
+	go build ${REPO_PATH}/iptables
+else
+	echo "Not on Linux"
+fi

+ 36 - 0
build-check

@@ -0,0 +1,36 @@
+#!/bin/bash -e
+#
+# Run all go-iptables tests
+#   ./test
+#   ./test -v
+#
+# Run tests for one package
+#   PKG=./unit ./test
+#   PKG=ssh ./test
+#
+
+# Invoke ./cover for HTML output
+COVER=${COVER:-"-cover"}
+
+source ./build
+
+FORMATTABLE="iptables"
+
+# user has not provided PKG override
+if [ -z "$PKG" ]; then
+	FMT=$FORMATTABLE
+
+# user has provided PKG override
+else
+	# strip out slashes and dots from PKG=./foo/
+	FMT=${PKG//\//}
+fi
+
+echo "Checking gofmt..."
+fmtRes=$(gofmt -l $FMT)
+if [ -n "${fmtRes}" ]; then
+	echo -e "gofmt checking failed:\n${fmtRes}"
+	exit 255
+fi
+
+echo "Success"

+ 50 - 0
test

@@ -0,0 +1,50 @@
+#!/bin/bash -e
+#
+# Run all go-iptables tests
+#   ./test
+#   ./test -v
+#
+# Run tests for one package
+#   PKG=./unit ./test
+#   PKG=ssh ./test
+#
+
+# Invoke ./cover for HTML output
+COVER=${COVER:-"-cover"}
+
+source ./build
+
+TESTABLE="iptables"
+FORMATTABLE="$TESTABLE"
+
+# user has not provided PKG override
+if [ -z "$PKG" ]; then
+	TEST=$TESTABLE
+	FMT=$FORMATTABLE
+
+# user has provided PKG override
+else
+	# strip out slashes and dots from PKG=./foo/
+	TEST=${PKG//\//}
+	TEST=${TEST//./}
+
+	# only run gofmt on packages provided by user
+	FMT="$TEST"
+fi
+
+# split TEST into an array and prepend REPO_PATH to each local package
+split=(${TEST// / })
+TEST=${split[@]/#/${REPO_PATH}/}
+
+echo "Running tests..."
+go test -i ${TEST}
+go test ${COVER} $@ ${TEST}
+
+echo "Checking gofmt..."
+fmtRes=$(gofmt -l $FMT)
+if [ -n "${fmtRes}" ]; then
+	echo -e "gofmt checking failed:\n${fmtRes}"
+	exit 255
+fi
+
+echo "Success"