Compare commits

..

5 Commits
v1.0.0 ... main

Author SHA1 Message Date
d26348d065 new/unit-tests (#1)
Reviewed-on: #1
Co-authored-by: jake <jake.young.dev@gmail.com>
Co-committed-by: jake <jake.young.dev@gmail.com>
2025-05-17 15:47:24 +00:00
bf4bc77079 update readme 2025-05-17 01:34:28 -04:00
170b11b99d update readme 2025-05-17 01:32:56 -04:00
fe9e86bdef readme update 2025-05-11 00:38:58 -04:00
10b0a0439f README update 2025-05-10 14:39:30 -04:00
3 changed files with 72 additions and 2 deletions

View File

@ -1,3 +1,34 @@
# donotpassgo
A composite workflow that runs general code checks on Go projects, an optional <b>test</b> input is available to trigger unit tests. See [steps](#steps) for more information on the jobs run
action to run general go code scans, includes dependency scan with govulncheck and static code analysis from gosec
## 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 <b>test</b> flag to <b>standard</b>
```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 <b>test</b> flag to <b>ginkgo</b>
```yaml
- name: "checkpoint"
uses: https://code.jakeyoungdev.com/actions/donotpassgo@main
with:
test: ginkgo
```
## Steps
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)

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: ${{ github.action_path }}/test.sh
env:
LIBRARY: ${{ inputs.test }}
- name: "install govulncheck"
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest

28
test.sh Executable 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