Skip to content

Commit

Permalink
Merge pull request #115 from squeed/build-improvements
Browse files Browse the repository at this point in the history
cleanup: drop old go versions, bump go.mod version, remove obsolete build script
  • Loading branch information
squeed authored Nov 2, 2023
2 parents 4170f81 + 89558ab commit 60f4899
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 51 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions build

This file was deleted.

30 changes: 3 additions & 27 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

0 comments on commit 60f4899

Please sign in to comment.