Skip to content

Commit

Permalink
fix: codecov issue (#285)
Browse files Browse the repository at this point in the history
* slove cicd issue

Signed-off-by: houwenchen <[email protected]>

* fix: codecov issue

Signed-off-by: Abhinandan Purkait <[email protected]>

* chore: use test-cov script to run test and generate report

Signed-off-by: Abhinandan Purkait <[email protected]>

* chore: generate report for bdd tests

Signed-off-by: Abhinandan Purkait <[email protected]>

---------

Signed-off-by: houwenchen <[email protected]>
Signed-off-by: Abhinandan Purkait <[email protected]>
Co-authored-by: houwenchen <[email protected]>
  • Loading branch information
Abhinandan-Purkait and houwenchen authored Mar 18, 2024
1 parent c97c4a7 commit f3e9cd0
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 10 deletions.
21 changes: 20 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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']
Expand Down
22 changes: 20 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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']
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -110,7 +108,7 @@ format:
.PHONY: test
test: format
@echo "--> Running go test" ;
@go test $(UNIT_TEST_PACKAGES)
@./buildscripts/test-cov.sh


.PHONY: deps
Expand Down
6 changes: 3 additions & 3 deletions buildscripts/test-cov.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

# Copyright © 2020 The OpenEBS Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ci/ci-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f3e9cd0

Please sign in to comment.