adding bash script for unit tests

This commit is contained in:
jake 2025-05-17 11:07:22 -04:00
parent bf4bc77079
commit 3782a1c863
2 changed files with 40 additions and 1 deletions

View File

@ -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

28
test.sh Normal file
View File

@ -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