diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index c1307fc..3c173d8 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -33,8 +33,6 @@ jobs: run: go get golang.org/x/tools/cmd/cover - name: Check modules run: go mod verify - - name: Build - run: ./build - name: Test run: SUDO_PERMITTED=1 ./test - name: Run linter diff --git a/build b/build deleted file mode 100755 index 6806dd0..0000000 --- a/build +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -set -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 diff --git a/test b/test index 8f86a07..0a46398 100755 --- a/test +++ b/test @@ -13,46 +13,22 @@ set -e # 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 - echo "Checking gofmt..." -fmtRes=$(gofmt -l $FMT) +fmtRes=$(gofmt -l -s .) 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..." bin=$(mktemp) -go test -c -o ${bin} ${COVER} ${TEST} +go test -c -o ${bin} ${COVER} ./iptables/... if [[ -z "$SUDO_PERMITTED" ]]; then echo "Test aborted for safety reasons. Please set the SUDO_PERMITTED variable." exit 1 fi -sudo -E bash -c "${bin} $@ ${TEST}" +sudo -E bash -c "${bin} $@ ./iptables/..." echo "Success" rm "${bin}"