Created
September 18, 2020 20:09
-
-
Save viggin543/f5a472c6c3b6f68e3b7f8f7601eb3ba4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CodeCov | |
| on: | |
| push: | |
| branches: [ master ] | |
| jobs: | |
| cd: | |
| name: CodeCov | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set up Go 1.x | |
| uses: actions/setup-go@v2 | |
| with: | |
| go-version: ^1.15 | |
| id: go | |
| - name: Check out code into the Go module directory | |
| uses: actions/checkout@v2 | |
| - name: Test | |
| run: | | |
| CVPKG=$(go list ./... | grep -v mocks | tr '\n' ',') | |
| go test -coverpkg=${CVPKG} -coverprofile=coverage.out -covermode=count ./... | |
| - name: Setup gcloud cli | |
| uses: GoogleCloudPlatform/github-actions/setup-gcloud@master | |
| with: | |
| version: '290.0.1' | |
| project_id: ${{ secrets.PROJECT_ID }} | |
| service_account_key: ${{ secrets.GCLOUD_SERVICE_KEY }} | |
| export_default_credentials: true | |
| - name: Publish cod cov badge | |
| run: | | |
| set -x | |
| total=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'` | |
| if (( $(echo "$total <= 50" | bc -l) )) ; then | |
| COLOR=red | |
| elif (( $(echo "$total > 80" | bc -l) )); then | |
| COLOR=green | |
| else | |
| COLOR=orange | |
| fi | |
| curl "https://img.shields.io/badge/coavrege-$total%25-$COLOR" > badge.svg | |
| gsutil -h "Cache-Control: no-cache" cp badge.svg gs://${SOME_BUCKET}/${PROJECT_NAME}/codcov.svg | |
| gsutil acl ch -u AllUsers:R gs://${SOME_BUCKET}/${PROJECT_NAME}/codcov.svg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment