Skip to content

Commit

Permalink
Merge pull request #9 from aleem1314/aleem/fix-codecov-report
Browse files Browse the repository at this point in the history
fix: fix tests and code coverage
  • Loading branch information
gsk967 authored Feb 11, 2022
2 parents 7f91781 + 2602625 commit 30bc6d6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 27 deletions.
32 changes: 10 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,27 @@ on:
- master
jobs:
tests:
name: Unit tests
name: Tests and code coverage
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Install Go
uses: actions/[email protected]
with:
go-version: 1.17
- name: Checkout code
uses: actions/checkout@v2
- name: run tests
run: make test
if: env.GIT_DIFF
code_cov:
name: Cover report
needs: tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
envs: ["stable-codecov"]
steps:
- name: Install Go
uses: actions/[email protected]
- uses: technote-space/get-diff-action@v4
with:
go-version: 1.17
- name: Checkout code
uses: actions/checkout@v2
- name: run stable test cover
if: matrix.envs == 'stable-codecov'
PATTERNS: |
**/**.go
go.mod
go.sum
- name: run tests and generate coverage
run: make test-cover
if: env.GIT_DIFF
- name: Upload codecov report
uses: codecov/codecov-action@v1
with:
flags: ${{matrix.envs}}
file: coverage.txt
if: env.GIT_DIFF

2 changes: 1 addition & 1 deletion cmd/passage/cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

"github.com/envadiv/Passage3D/app"
"github.com/envadiv/Passage3D/passage/cmd"
"github.com/envadiv/Passage3D/cmd/passage/cmd"
"github.com/stretchr/testify/require"

svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
Expand Down
2 changes: 1 addition & 1 deletion cmd/passage/cmd/genaccounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil"
simcmd "github.com/envadiv/Passage3D/cmd"
simcmd "github.com/envadiv/Passage3D/cmd/passage/cmd"
)

var testMbm = module.NewBasicManager(genutil.AppModuleBasic{})
Expand Down
4 changes: 1 addition & 3 deletions scripts/test_cover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ for m in ${SUBMODULES[@]}; do
cd $CURDIR/$m
PKGS=$(go list ./...)
for pkg in ${PKGS[@]}; do
if [ $pkg != "github.com/envadiv/Passage3D/cmd/passage/cmd" ]; then
go test -v -timeout 30m -race -coverpkg=all -coverprofile=profile.out -covermode=atomic -tags="ledger test_ledger_mock" "$pkg"
if [ -f profile.out ]; then
tail -n +2 profile.out >> $CURDIR/coverage.txt;
rm profile.out
fi
fi
done
done

Expand All @@ -26,7 +24,7 @@ excludelist=" $(find ./ -type f -name '*.pb.go')"
excludelist+=" $(find ./ -type f -name '*.pb.gw.go')"
excludelist+="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')"
for filename in ${excludelist}; do
filename=$(echo $filename | sed 's/^./github.com\/envadiv\/passage/g')
filename=$(echo $filename | sed 's/^./github.com\/envadiv\/passage3D/g')
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done

0 comments on commit 30bc6d6

Please sign in to comment.