restructure and adding functionality
This commit is contained in:
16
src/install.sh
Normal file
16
src/install.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
version=$(go version);
|
||||
if [[ -z "$version" ]]; then
|
||||
echo "[FATAL] golang is not installed";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
go install golang.org/x/vuln/cmd/govulncheck@latest
|
||||
go install github.com/securego/gosec/v2/cmd/gosec@latest
|
||||
|
||||
if [[ "$TEST_LIBRARY" == "ginkgo" ]]; then
|
||||
go install github.com/onsi/ginkgo/v2/ginkgo@$TEST_VERSION
|
||||
fi
|
||||
34
src/security.sh
Normal file
34
src/security.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
if [[ "$STATIC_FLAG" == "no" && "$VULN_SCAN" == "no" ]]; then
|
||||
echo "[INFO] no security flags set, skipping!";
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
if [[ "$STATIC_FLAG" == "yes" ]]; then
|
||||
if gosec ./...; then
|
||||
echo "[INFO] gosec passed!";
|
||||
else
|
||||
if [[ "$STATIC_FAIL" == "yes" ]]; then
|
||||
echo "[FATAL] gosec failed!";
|
||||
exit 1;
|
||||
else
|
||||
echo "[INFO] gosec failed!";
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$VULN_CHECK" == "yes" ]]; then
|
||||
if govulncheck ./...; then
|
||||
echo "[INFO] govulncheck passed!";
|
||||
else
|
||||
if [[ "$VULN_FAIL" == "yes" ]]; then
|
||||
echo "[FATAL] govulncheck failed!"
|
||||
exit 1;
|
||||
else
|
||||
echo "[INFO] govulncheck failed!"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
37
src/test.sh
Normal file
37
src/test.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
if [[ "$TEST_LIBRARY" == "none" ]]; then
|
||||
echo "[INFO] test-library input not set, skipping unit tests.";
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
echo "[INFO] running unit tests";
|
||||
if [[ "$TEST_LIBRARY" == "standard" ]]; then
|
||||
if go test ./...; then
|
||||
echo "[INFO] unit tests passed!";
|
||||
exit 0;
|
||||
else
|
||||
if [[ "$TEST_FAIL" == "yes" ]]; then
|
||||
echo "[FATAL] unit tests failed!";
|
||||
exit 1;
|
||||
else
|
||||
echo "[INFO] unit tests failed!";
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$TEST_LIBRARY" == "ginkgo" ]]; then
|
||||
if ginkgo ./...; then
|
||||
echo "[INFO] unit tests passed!";
|
||||
exit 0;
|
||||
else
|
||||
if [[ "$TEST_FAIL" == "yes" ]]; then
|
||||
echo "[FATAL] unit tests failed!";
|
||||
exit 1;
|
||||
else
|
||||
echo "[INFO] unit tests failed!";
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user