From 07c31e6d0c9ab5c3f7cc17407550ccf86be14620 Mon Sep 17 00:00:00 2001 From: houwenchen Date: Thu, 19 Oct 2023 23:48:06 +0800 Subject: [PATCH 1/4] slove cicd issue Signed-off-by: houwenchen --- .github/workflows/build.yml | 13 ++++++++++++- Makefile | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 794f0a99..9db7b199 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'] diff --git a/Makefile b/Makefile index 1d14f2f1..6cceceae 100644 --- a/Makefile +++ b/Makefile @@ -110,7 +110,7 @@ format: .PHONY: test test: format @echo "--> Running go test" ; - @go test $(UNIT_TEST_PACKAGES) + @go test $(UNIT_TEST_PACKAGES) -cover -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt .PHONY: deps From 9e65a85502d8319edbac8b548f78f5b4304886b5 Mon Sep 17 00:00:00 2001 From: Abhinandan Purkait Date: Mon, 18 Mar 2024 06:33:44 +0000 Subject: [PATCH 2/4] fix: codecov issue Signed-off-by: Abhinandan Purkait --- .github/workflows/pull_request.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 43f7071f..780df8e6 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'] From 466ec71e0e77befef8193abd88dcf44e6811f68c Mon Sep 17 00:00:00 2001 From: Abhinandan Purkait Date: Mon, 18 Mar 2024 06:47:53 +0000 Subject: [PATCH 3/4] chore: use test-cov script to run test and generate report Signed-off-by: Abhinandan Purkait --- Makefile | 4 ++-- buildscripts/test-cov.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 6cceceae..9562d6a7 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ # 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') +# 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 \ @@ -110,7 +110,7 @@ format: .PHONY: test test: format @echo "--> Running go test" ; - @go test $(UNIT_TEST_PACKAGES) -cover -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt + @./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 From d37c762a422c01a7e233da17ada91de07a837660 Mon Sep 17 00:00:00 2001 From: Abhinandan Purkait Date: Mon, 18 Mar 2024 07:01:27 +0000 Subject: [PATCH 4/4] chore: generate report for bdd tests Signed-off-by: Abhinandan Purkait --- .github/workflows/build.yml | 8 ++++++++ .github/workflows/pull_request.yml | 8 ++++++++ Makefile | 2 -- ci/ci-test.sh | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9db7b199..a7a174b1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -113,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 780df8e6..ed2dfac8 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -121,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 9562d6a7..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 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