From 3782a1c8634b8f1f48eb393abd61d545023c29aa Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 17 May 2025 11:07:22 -0400 Subject: [PATCH 1/3] 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 -- 2.47.2 From 4d69a9a6f4aa9eba86d747f43fa92facb9f025d2 Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 17 May 2025 11:14:47 -0400 Subject: [PATCH 2/3] bugfix with script path --- action.yaml | 2 +- test.sh | 0 2 files changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 test.sh diff --git a/action.yaml b/action.yaml index f869b5b..aed5b2f 100644 --- a/action.yaml +++ b/action.yaml @@ -10,7 +10,7 @@ runs: steps: - name: "run unit tests" shell: bash - run: test.sh + run: ${{ github.action_path }}/test.sh env: LIBRARY: ${{ inputs.test }} diff --git a/test.sh b/test.sh old mode 100644 new mode 100755 -- 2.47.2 From 4b6117b09c11c370c23d31ce6ae589da8478b672 Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 17 May 2025 11:45:28 -0400 Subject: [PATCH 3/3] readme update --- README.md | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 12c490c..c4f70d8 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,34 @@ # donotpassgo -A composite workflow that runs security checks on Go projects. Golang must be installed before this workflow can run. +A composite workflow that runs general code checks on Go projects, an optional test input is available to trigger unit tests. See [steps](#steps) for more information on the jobs run + +## Usage +adding donotpassgo to workflows is simple, just add the following step to your yaml file: +```yaml +- name: "checkpoint" + uses: https://code.jakeyoungdev.com/actions/donotpassgo@main +``` + +donotpassgo has optional support for running unit tests, this can be added by setting the test flag to standard +```yaml +- name: "checkpoint" + uses: https://code.jakeyoungdev.com/actions/donotpassgo@main + with: + test: standard +``` + +running unit tests with ginkgo is also supported by setting the test flag to ginkgo +```yaml +- name: "checkpoint" + uses: https://code.jakeyoungdev.com/actions/donotpassgo@main + with: + test: ginkgo +``` ## Steps -### govulncheck -govulncheck is installed using 'go install' and is used to scan the application dependencies and standard library. - -### gosec -gosec is used for static code analysis. - -## TODO -1. Add support for unit tests -2. Add ginkgo/gomega support \ No newline at end of file +donotpassgo runs several workflow jobs to ensure quality and secure go code, these steps may be updated as new tools develop. +### Dependency Scans +[govulncheck](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck) is installed using golang and is used to scan for vulnerabilities in the project dependencies and standard library. +### Static Code Analysis +[gosec](https://github.com/securego/gosec) inspects source code for security problems +### Unit Tests +donotpassgo supports two unit tests libraries: the standard go library and [ginkgo](https://github.com/onsi/ginkgo) \ No newline at end of file -- 2.47.2