Skip to content

Commit

Permalink
create a new script file for the coverage test and put the coverage f…
Browse files Browse the repository at this point in the history
…ile into the .gitignore
  • Loading branch information
Pantani committed Dec 3, 2022
1 parent 6e1fa84 commit e9946a4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version: 1.19
- run: ./scripts/test-unit
- run: ./scripts/test-coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3.1.1
with:
file: ./coverage.txt
fail_ci_if_error: true
verbose: true

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ apps/
.vscode
docs/.vuepress/dist
build/
*coverage.*
18 changes: 18 additions & 0 deletions scripts/test-coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

go test -v -coverprofile=coverage.txt -covermode=atomic -coverpkg=./... $(go list github.com/ignite/cli/ignite/...)

excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')"
excludelist+=" $(find ./ -type f -name '*.pb.go')"
excludelist+=" $(find ./ -type f -name '*.pb.gw.go')"
excludelist+=" $(find ./actions -type d)"
excludelist+=" $(find ./assets -type d)"
excludelist+=" $(find ./docs -type d)"
excludelist+=" $(find ./integration -type d)"
excludelist+=" $(find ./scripts -type d)"
for filename in ${excludelist}; do
filename=${filename#".//"}
echo "Excluding ${filename} from coverage report..."
filename=$(echo "$filename" | sed 's/\//\\\//g')
sed -i.bak "/""$filename""/d" coverage.txt
done
17 changes: 1 addition & 16 deletions scripts/test-unit
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
#!/bin/bash

go test -v -coverprofile=coverage.txt -covermode=atomic -coverpkg=./... $(go list github.com/ignite/cli/ignite/...)

excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')"
excludelist+=" $(find ./ -type f -name '*.pb.go')"
excludelist+=" $(find ./ -type f -name '*.pb.gw.go')"
excludelist+=" $(find ./actions -type d)"
excludelist+=" $(find ./assets -type d)"
excludelist+=" $(find ./docs -type d)"
excludelist+=" $(find ./integration -type d)"
excludelist+=" $(find ./scripts -type d)"
for filename in ${excludelist}; do
filename=${filename#".//"}
echo "Excluding ${filename} from coverage report..."
filename=$(echo "$filename" | sed 's/\//\\\//g')
sed -i.bak "/""$filename""/d" coverage.txt
done
go test -v github.com/ignite/cli/ignite/...

0 comments on commit e9946a4

Please sign in to comment.