Repository: oras-project/oras
Pull request #450 (2022-07-19 07:31:48)

Migrate to codecov.io
Fix:  #441 

Codecov Migrate Steps:

- [x] add coverage percent at .codecov
- [x] add codecov-action at build.yml
- [x] add badge at README.md

- [x] update make test with go test at makefile
- [x] update .gitignore / rmv .cover/ .test/ add coverage.txt

- [x] del shell/test.sh
- [x] del origin upload coverage report from build.yml


codecov-commenter: # [Codecov](https://codecov.io/gh/oras-project/oras/pull/450?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
> :exclamation: No coverage uploaded for pull request base (`main@8125941`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#section-missing-base-commit).
> The diff coverage is `n/a`.

```diff
@@           Coverage Diff           @@
##             main     #450   +/-   ##
=======================================
  Coverage        ?   55.69%           
=======================================
  Files           ?        6           
  Lines           ?      237           
  Branches        ?        0           
=======================================
  Hits            ?      132           
  Misses          ?       90           
  Partials        ?       15           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/oras-project/oras/pull/450?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/oras-project/oras/pull/450?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Last update [8125941...05ec389](https://codecov.io/gh/oras-project/oras/pull/450?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).

sajayantony: @junczhuMSFT might have to rebase this. 
/cc @shizhMSFT @qweeah 
shizhMSFT: @junczhuMSFT You may also want to clean up previous coverage related scripts.

Patch:
diff --git a/.github/.codecov.yml b/.github/.codecov.yml
new file mode 100644
index 0000000..819c4bd
--- /dev/null
+++ b/.github/.codecov.yml
@@ -0,0 +1,5 @@
+coverage:
+  status:
+    project:
+      default:
+        target: 60%
\ No newline at end of file
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 07bae84..b7260b7 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -28,9 +28,5 @@ jobs:
         run: make test
       - name: Check Version
         run: bin/linux/amd64/oras version
-      - name: Upload Coverage Report
-        uses: actions/upload-artifact@master
-        with:
-          name: oras-coverage-report-${{ github.sha }}
-          path: .cover/
-        if: always()
+      - name: Upload coverage to codecov.io
+        uses: codecov/codecov-action@v3
diff --git a/.gitignore b/.gitignore
index 7364a63..3e142af 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,9 +19,7 @@ debug
 .idea
 
 # Custom
-.cover/
-.test/
-hello.txt
+coverage.txt
 bin/
 dist/
 *.tar.gz
diff --git a/Makefile b/Makefile
index 014c85e..dc75f89 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ LDFLAGS += -X $(PROJECT_PKG)/internal/version.GitTreeState=${GIT_DIRTY}
 
 .PHONY: test
 test: vendor check-encoding
-	./scripts/test.sh
+	go test -race -v -coverprofile=coverage.txt -covermode=atomic ./...
 
 .PHONY: covhtml
 covhtml:
diff --git a/README.md b/README.md
index 5728821..689225c 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
 # ORAS CLI
 
 [![Build Status](https://github.com/oras-project/oras/actions/workflows/build.yml/badge.svg?event=push)](https://github.com/oras-project/oras/actions/workflows/build.yml?query=workflow%3Abuild+event%3Apush)
+[![codecov](https://codecov.io/gh/oras-project/oras/branch/main/graph/badge.svg)](https://codecov.io/gh/oras-project/oras)
 
 
 ![ORAS](https://github.com/oras-project/oras-www/raw/main/docs/assets/images/oras.png)


Test patch:
diff --git a/scripts/test.sh b/scripts/test.sh
deleted file mode 100755
index 432f51d..0000000
--- a/scripts/test.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash -ex
-
-# Copyright The ORAS Authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR/../
-
-rm -rf .cover/ .test/
-mkdir .cover/ .test/
-trap "rm -rf .test/" EXIT
-
-export CGO_ENABLED=0
-for pkg in `go list ./...`; do
-    go test -v -covermode=atomic \
-        -coverprofile=".cover/$(echo $pkg | sed 's/\//_/g').cover.out" $pkg
-done
-
-echo "mode: set" > .cover/cover.out && cat .cover/*.cover.out | grep -v mode: | sort -r | \
-   awk '{if($1 != last) {print $0;last=$1}}' >> .cover/cover.out
-
-go tool cover -html=.cover/cover.out -o=.cover/coverage.html
\ No newline at end of file