adding bash script for unit tests
This commit is contained in:
parent
bf4bc77079
commit
3782a1c863
13
action.yaml
13
action.yaml
@ -1,9 +1,20 @@
|
|||||||
name: "donotpassgo"
|
name: "donotpassgo"
|
||||||
description: "general go code checks"
|
description: "general go code checks"
|
||||||
|
inputs:
|
||||||
|
test:
|
||||||
|
description: "runs unit tests with specified library"
|
||||||
|
required: false
|
||||||
|
default: "none"
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: "install go packages"
|
- name: "run unit tests"
|
||||||
|
shell: bash
|
||||||
|
run: test.sh
|
||||||
|
env:
|
||||||
|
LIBRARY: ${{ inputs.test }}
|
||||||
|
|
||||||
|
- name: "install govulncheck"
|
||||||
run: |
|
run: |
|
||||||
go install golang.org/x/vuln/cmd/govulncheck@latest
|
go install golang.org/x/vuln/cmd/govulncheck@latest
|
||||||
|
|
||||||
|
28
test.sh
Normal file
28
test.sh
Normal 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
|
Loading…
x
Reference in New Issue
Block a user