add coverage report for actions tests

This commit is contained in:
Ben McClelland
2023-06-25 10:54:24 -07:00
parent 1d476c6d4d
commit 1da0c1ceba
4 changed files with 49 additions and 12 deletions
+9 -10
View File
@@ -3,7 +3,7 @@ on: pull_request
jobs:
build:
name: Build
name: RunTests
runs-on: ubuntu-latest
steps:
@@ -16,16 +16,15 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Get dependencies
- name: Get Dependencies
run: |
go get -v -t -d ./...
- name: Build
run: make
- name: Test
- name: Build and Run
run: |
mkdir /tmp/gw
./versitygw -a user -s pass posix /tmp/gw &
sleep 1
./versitygw test -a user -s pass -e http://127.0.0.1:7070 full-flow
make testbin
./runtests.sh
- name: Coverage Report
run: |
go tool covdata percent -i=/tmp/covdata
+2 -2
View File
@@ -24,10 +24,10 @@ jobs:
go get -v -t -d ./...
- name: Build
run: go build -o versitygw cmd/versitygw/*.go
run: make
- name: Test
run: go test -v -timeout 30s -tags=github ./...
run: go test -coverprofile profile.txt -race -v -timeout 30s -tags=github ./...
- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest
+1
View File
@@ -33,3 +33,4 @@ VERSION
*.tar
*.tar.gz
/rand.data
/profile.txt
Executable
+37
View File
@@ -0,0 +1,37 @@
#!/bin/bash
# make temp dirs
mkdir /tmp/gw
rm -rf /tmp/covdata
mkdir /tmp/covdata
# run server in background
GOCOVERDIR=/tmp/covdata ./versitygw -a user -s pass posix /tmp/gw &
GW_PID=$!
# wait a second for server to start up
sleep 1
# check if server is still running
if ! kill -0 $GW_PID; then
echo "server no longer running"
exit 1
fi
# run tests
if ! ./versitygw test -a user -s pass -e http://127.0.0.1:7070 full-flow; then
echo "tests failed"
kill $GW_PID
exit 1
fi
# kill off server
kill $GW_PID
exit 0
# if the above binary was built with -cover enabled (make testbin),
# then the following can be used for code coverage reports:
# go tool covdata percent -i=/tmp/covdata
# go tool covdata textfmt -i=/tmp/covdata -o profile.txt
# go tool cover -html=profile.txt