From cf48bf64c83d98e047f68f1551c28e447be98872 Mon Sep 17 00:00:00 2001 From: Rick <1450685+LinuxSuRen@users.noreply.github.com> Date: Tue, 29 Jun 2021 22:32:42 +0800 Subject: [PATCH] Add codecov for unit test coverage (#585) * Add codecov for unit test coverage * Add codecov badge into readme file Co-authored-by: rick --- .github/workflows/pull-request.yaml | 22 ++++++++++++++++++++++ Makefile | 3 +-- README-zh.md | 2 +- README.md | 2 +- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 6abaa0a2..83f13967 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -98,3 +98,25 @@ jobs: # run: | # export PATH=$PATH:${PWD}/bin:$GOPATH/bin:/home/runner/go/bin # make test + UnitTest: + name: Test + runs-on: ubuntu-20.04 + steps: + - name: Set up Go 1.15 + uses: actions/setup-go@v2.1.3 + with: + go-version: 1.15 + id: go + - name: Check out code into the Go module directory + uses: actions/checkout@v2.3.4 + - name: Test + run: | + make test + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage.out + flags: unittests + name: codecov-umbrella + fail_ci_if_error: true diff --git a/Makefile b/Makefile index 48cd77d7..1ea2c1e4 100644 --- a/Makefile +++ b/Makefile @@ -131,8 +131,7 @@ test-slow: test: mkdir -p bin - go test ./util ./client ./app/ ./app/health ./app/helper ./app/i18n ./app/cmd/common -v -count=1 -coverprofile coverage.out - go test ./app/cmd -v -count=1 + go test ./util ./app/health ./app/i18n ./app/cmd/common -v -count=1 -coverprofile coverage.out # go test ./util -v -count=1 # go test ./client -v -count=1 -coverprofile coverage.out # go test ./app -v -count=1 diff --git a/README-zh.md b/README-zh.md index 845d8695..cbb3fed3 100644 --- a/README-zh.md +++ b/README-zh.md @@ -9,7 +9,7 @@ --> [![](https://goreportcard.com/badge/jenkins-zh/jenkins-cli)](https://goreportcard.com/report/jenkins-zh/jenkins-cli) [![](http://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square)](https://godoc.org/github.com/jenkins-zh/jenkins-cli) -![Sonar Coverage](https://img.shields.io/sonar/coverage/jenkins-zh_jenkins-cli?server=https%3A%2F%2Fsonarcloud.io) +[![codecov](https://codecov.io/gh/jenkins-zh/jenkins-cli/branch/master/graph/badge.svg?token=XS8g2CjdNL)](https://codecov.io/gh/jenkins-zh/jenkins-cli) [![Contributors](https://img.shields.io/github/contributors/jenkins-zh/jenkins-cli.svg)](https://github.com/jenkins-zh/jenkins-cli/graphs/contributors) [![GitHub release](https://img.shields.io/github/release/jenkins-zh/jenkins-cli.svg?label=release)](https://github.com/jenkins-zh/jenkins-cli/releases/latest) ![GitHub All Releases](https://img.shields.io/github/downloads/jenkins-zh/jenkins-cli/total) diff --git a/README.md b/README.md index edcf2149..627f91a7 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ --> [![](https://goreportcard.com/badge/jenkins-zh/jenkins-cli)](https://goreportcard.com/report/jenkins-zh/jenkins-cli) [![](http://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square)](https://godoc.org/github.com/jenkins-zh/jenkins-cli) -![Sonar Coverage](https://img.shields.io/sonar/coverage/jenkins-zh_jenkins-cli?server=https%3A%2F%2Fsonarcloud.io) +[![codecov](https://codecov.io/gh/jenkins-zh/jenkins-cli/branch/master/graph/badge.svg?token=XS8g2CjdNL)](https://codecov.io/gh/jenkins-zh/jenkins-cli) [![Contributors](https://img.shields.io/github/contributors/jenkins-zh/jenkins-cli.svg)](https://github.com/jenkins-zh/jenkins-cli/graphs/contributors) [![GitHub release](https://img.shields.io/github/release/jenkins-zh/jenkins-cli.svg?label=release)](https://github.com/jenkins-zh/jenkins-cli/releases/latest) ![GitHub All Releases](https://img.shields.io/github/downloads/jenkins-zh/jenkins-cli/total)