Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: remove obsolete build script #115

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}"
Loading