diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 794f0a99..a7a174b1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,11 +60,22 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - name: Set up Go 1.19 + uses: actions/setup-go@v4 + with: + go-version: 1.19.9 + cache: false + - name: Unit test run: make test - name: Upload Coverage Report - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage.txt + name: coverage-$(date +%s) + flags: unittests bdd-test: needs: ['unit-test'] @@ -102,6 +113,14 @@ jobs: - name: Running tests run: ./ci/ci-test.sh + - name: Upload Coverage Report + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./tests/bdd_coverage.txt + name: coverage-bdd_coverage-$(date +%s) + flags: bddtests + ansible: runs-on: ubuntu-latest needs: ['lint', 'unit-test', 'bdd-test'] diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 43f7071f..ed2dfac8 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -62,18 +62,28 @@ jobs: path: '.' pattern: '*.sh' - unit-test: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 + - name: Set up Go 1.19 + uses: actions/setup-go@v4 + with: + go-version: 1.19.9 + cache: false + - name: Unit test run: make test - name: Upload Coverage Report - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage.txt + name: coverage-$(date +%s) + flags: unittests bdd-test: needs: ['unit-test'] @@ -111,6 +121,14 @@ jobs: - name: Running tests run: ./ci/ci-test.sh + - name: Upload Coverage Report + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./tests/bdd_coverage.txt + name: coverage-bdd_coverage-$(date +%s) + flags: bddtests + csi-driver: runs-on: ubuntu-latest needs: ['lint', 'unit-test', 'bdd-test'] diff --git a/Makefile b/Makefile index 1d14f2f1..6366d610 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,6 @@ # list only csi source code directories PACKAGES = $(shell go list ./... | grep -v 'pkg/generated') -UNIT_TEST_PACKAGES = $(shell go list ./... | grep -v 'pkg/generated\|tests') - # Lint our code. Reference: https://golang.org/cmd/vet/ VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods \ -nilfunc -printf -rangeloops -shift -structtags -unsafeptr @@ -110,7 +108,7 @@ format: .PHONY: test test: format @echo "--> Running go test" ; - @go test $(UNIT_TEST_PACKAGES) + @./buildscripts/test-cov.sh .PHONY: deps diff --git a/buildscripts/test-cov.sh b/buildscripts/test-cov.sh index be9c8fa1..6fce9e35 100755 --- a/buildscripts/test-cov.sh +++ b/buildscripts/test-cov.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # Copyright © 2020 The OpenEBS Authors # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,12 +14,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -#!/usr/bin/env bash - set -e echo "" > coverage.txt -for d in $(go list ./... | grep -v 'vendor\|pkg/apis\|pkg/generated\|tests'); do +for d in $(go list ./... | grep -v "pkg/generated\|tests"); do #TODO - Include -race while creating the coverage profile. go test -coverprofile=profile.out -covermode=atomic $d if [ -f profile.out ]; then diff --git a/ci/ci-test.sh b/ci/ci-test.sh index c048aef7..497a0bc0 100755 --- a/ci/ci-test.sh +++ b/ci/ci-test.sh @@ -161,7 +161,7 @@ set +e echo "running ginkgo test case" -if ! ginkgo -v ; then +if ! ginkgo -v -coverprofile=bdd_coverage.txt -covermode=atomic; then sudo pvscan --cache