Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/coveritup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ jobs:
type: unit-test-run-time
command: go test -race -v ./... -count=1 -coverprofile=coverage.out
record: runtime
- name: Benchmark Test
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

╰─$ go test  -count 2 -bench=. ./... -benchmem|grep "allocs"
     145	   8069938 ns/op	 7360722 B/op	   19794 allocs/op
     152	   8272545 ns/op	 7370076 B/op	   19794 allocs/op

uses: kevincobain2000/action-coveritup@v2
with:
type: allocs-per-op
command: go test -count 1 -bench=. ./... -benchmem|grep allocs|awk '{ print $(--NF)}'
record: score
metric: alloc

- name: Coverage
run: gocov convert coverage.out | gocov-xml > coverage.xml
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
![build-time](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=build-time&branch=master)
![go-binary-size](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=go-binary-size&branch=master)
![unit-test-run-time](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=unit-test-run-time&branch=master)
![allocs-per-op](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=allocs-per-op&branch=master)

![go-mod-dependencies](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=go-mod-dependencies&branch=master)
![go-sec-issues](https://coveritup.app/badge?org=kevincobain2000&repo=gobrew&type=go-sec-issues&branch=master)
Expand All @@ -37,7 +38,7 @@
![go-mod-dependencies](https://coveritup.app/chart?org=kevincobain2000&repo=gobrew&type=go-mod-dependencies&branch=master&output=svg&width=160&height=160)
![go-sec-issues](https://coveritup.app/chart?org=kevincobain2000&repo=gobrew&type=go-sec-issues&branch=master&output=svg&width=160&height=160&line=fill)
![unit-test-run-time](https://coveritup.app/chart?org=kevincobain2000&repo=gobrew&type=unit-test-run-time&branch=master&output=svg&width=160&height=160)

![allocs-per-op](https://coveritup.app/chart?org=kevincobain2000&repo=gobrew&type=allocs-per-op&output=svg&width=160&height=160&branch=master)



Expand Down
13 changes: 12 additions & 1 deletion gobrew_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/assert"
)

func setupGobrew(t *testing.T, ts *httptest.Server) GoBrew {
func setupGobrew[T testing.TB](t T, ts *httptest.Server) GoBrew {
tags, _ := url.JoinPath(ts.URL, "golang-tags.json")
versionURL, _ := url.JoinPath(ts.URL, "latest")
config := Config{
Expand All @@ -25,6 +25,17 @@ func setupGobrew(t *testing.T, ts *httptest.Server) GoBrew {
return gb
}

func BenchmarkInstallGo(t *testing.B) {
ts := httptest.NewServer(http.FileServer(http.Dir("testdata")))
gb := setupGobrew(t, ts)
defer ts.Close()
for i := 0; i < t.N; i++ {
gb.Install("1.9")
exists := gb.existsVersion("1.9")
assert.Equal(t, true, exists)
}
}

func TestInstallAndExistVersion(t *testing.T) {
t.Parallel()
ts := httptest.NewServer(http.FileServer(http.Dir("testdata")))
Expand Down