Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add codecov #153

Merged
merged 1 commit into from
Jul 25, 2022
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: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ jobs:
with:
go-version: 1.17

- name: Install mage
- name: Install Mage
run: go install github.com/magefile/mage

- name: Build
run: mage build

- name: Test
run: mage test
run: mage citest

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
30 changes: 28 additions & 2 deletions magefile.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build mage
// +build mage

package main

Expand All @@ -20,7 +19,7 @@ import (
"golang.org/x/crypto/ssh/terminal"
)

var (
const (
Go = "go"
)

Expand Down Expand Up @@ -165,3 +164,30 @@ func CBT() error {
}
return nil
}


// CITest runs unit tests with coverage as a part of CI.
// The mage `-v` option will trigger a verbose output of the test
func CITest() error {
return runCITests()
}

func runCITests(extraTestArgs ...string) error {
args := []string{"test"}
if mg.Verbose() {
args = append(args, "-v")
}
args = append(args, "-tags=jwx_es256k")
args = append(args, "-covermode=atomic")
args = append(args, "-coverprofile=coverage.out")
args = append(args, extraTestArgs...)
args = append(args, "./...")
testEnv := map[string]string{
"CGO_ENABLED": "1",
"GO111MODULE": "on",
}
writer := ColorizeTestStdout()
fmt.Printf("%+v", args)
_, err := sh.Exec(testEnv, writer, os.Stderr, Go, args...)
return err
}