Browse Source

Merge pull request #17 from steveeJ/ci-tests

travis: enable go-{1.5,1.6,tip} and tests
Jonathan Boulle 9 years ago
parent
commit
5ac2be4ed3
4 changed files with 32 additions and 46 deletions
  1. 17 1
      .travis.yml
  2. 2 1
      build
  3. 0 36
      build-check
  4. 13 8
      test

+ 17 - 1
.travis.yml

@@ -1,9 +1,25 @@
 language: go
+sudo: required
+dist: trusty
+
 go:
   - 1.4
+  - 1.5.3
+  - 1.6
+  - tip
+
+env:
+  global:
+    - TOOLS_CMD=golang.org/x/tools/cmd
+    - PATH=$GOROOT/bin:$PATH
+    - SUDO_PERMITTED=1
+
+matrix:
+  allow_failures:
+    - go: tip
 
 install:
  - go get golang.org/x/tools/cmd/cover
 
 script:
- - ./build-check
+ - ./test

+ 2 - 1
build

@@ -1,4 +1,5 @@
-#!/bin/bash -e
+#!/usr/bin/env bash
+set -e
 
 ORG_PATH="github.com/coreos"
 REPO_PATH="${ORG_PATH}/go-iptables"

+ 0 - 36
build-check

@@ -1,36 +0,0 @@
-#!/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"

+ 13 - 8
test

@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!/usr/bin/env bash
 #
 # Run all go-iptables tests
 #   ./test
@@ -8,6 +8,7 @@
 #   PKG=./unit ./test
 #   PKG=ssh ./test
 #
+set -e
 
 # Invoke ./cover for HTML output
 COVER=${COVER:-"-cover"}
@@ -32,19 +33,23 @@ else
 	FMT="$TEST"
 fi
 
+echo "Checking gofmt..."
+fmtRes=$(gofmt -l $FMT)
+if [ -n "${fmtRes}" ]; then
+	echo -e "gofmt checking failed:\n${fmtRes}"
+	exit 255
+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
+if [[ -z "$SUDO_PERMITTED" ]]; then
+    echo "Test aborted for safety reasons. Please set the SUDO_PERMITTED variable."
+    exit 1
 fi
 
+sudo -E bash -c "PATH=\$GOROOT/bin:\$PATH go test ${COVER} $@ ${TEST}"
 echo "Success"