diff --git a/.github/workflows/pr-ci-check.yml b/.github/workflows/pr-ci-check.yml index 12bb06622..834c3c589 100644 --- a/.github/workflows/pr-ci-check.yml +++ b/.github/workflows/pr-ci-check.yml @@ -21,3 +21,9 @@ jobs: ${{ runner.os }}-go- - name: Make ci run: make ci + - name: Upload test coverage + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage.out + verbose: true diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4d232ef9d..1c41655e5 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -40,6 +40,13 @@ jobs: - name: Test run: make test + - name: Upload test coverage + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage.out + verbose: true + # Only try to publish the container image from the root repo; forks don't have permission to do so and will always get failures. - name: Publish container image if: github.repository == 'vmware-tanzu/velero' diff --git a/changelogs/unreleased/4704-reasonerjt b/changelogs/unreleased/4704-reasonerjt new file mode 100644 index 000000000..79218ea62 --- /dev/null +++ b/changelogs/unreleased/4704-reasonerjt @@ -0,0 +1 @@ +Enable coverage in test.sh and upload to codecov \ No newline at end of file diff --git a/hack/test.sh b/hack/test.sh index bab638319..40846ff53 100755 --- a/hack/test.sh +++ b/hack/test.sh @@ -43,5 +43,5 @@ fi # but the user and group don't exist inside the container, when the code(https://github.com/kubernetes-sigs/controller-runtime/blob/v0.10.2/pkg/internal/testing/addr/manager.go#L44) # tries to get the cache directory, it gets the directory "/" and then get the permission error when trying to create directory under "/". # Specifying the cache directory by environment variable "XDG_CACHE_HOME" to workaround it -XDG_CACHE_HOME=/tmp/ go test -installsuffix "static" -short -timeout 60s "${TARGETS[@]}" +XDG_CACHE_HOME=/tmp/ go test -installsuffix "static" -short -timeout 60s -coverprofile=coverage.out "${TARGETS[@]}" echo "Success!"