From 3782a1c8634b8f1f48eb393abd61d545023c29aa Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 17 May 2025 11:07:22 -0400 Subject: [PATCH] adding bash script for unit tests --- action.yaml | 13 ++++++++++++- test.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 test.sh diff --git a/action.yaml b/action.yaml index d4c18ab..f869b5b 100644 --- a/action.yaml +++ b/action.yaml @@ -1,9 +1,20 @@ name: "donotpassgo" description: "general go code checks" +inputs: + test: + description: "runs unit tests with specified library" + required: false + default: "none" runs: using: "composite" steps: - - name: "install go packages" + - name: "run unit tests" + shell: bash + run: test.sh + env: + LIBRARY: ${{ inputs.test }} + + - name: "install govulncheck" run: | go install golang.org/x/vuln/cmd/govulncheck@latest diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..39dfe8a --- /dev/null +++ b/test.sh @@ -0,0 +1,28 @@ +#!/bin/bash +if [[ "$LIBRARY" == "none" ]]; then + echo "Test flag not set, skipping unit tests." + exit 0 +fi + +if [[ "$LIBRARY" == "standard" ]]; then + echo "Running unit tests with standard library" + if go test ./...; then + echo "Tests passed!" + exit 0 + else + echo "Tests failed!" + exit 1 + fi +fi + +if [[ "$LIBRARY" == "ginkgo" ]]; then + echo "Running unit tests with ginkgo" + go install github.com/onsi/ginkgo/v2/ginkgo@v2.23.4 + if ginkgo ./...; then + echo "Tests passed!" + exit 0 + else + echo "Tests failed!" + exit 1 + fi +fi \ No newline at end of file