Skip to content

Commit

Permalink
fix(CI): fix code coverage (#1903)
Browse files Browse the repository at this point in the history
* fix the code test coverage measure

* fix folder type removal
  • Loading branch information
Pantani authored Nov 16, 2022
1 parent e11d40c commit 037d23a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 29 deletions.
20 changes: 8 additions & 12 deletions .codecov.yml → .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
#
# This codecov.yml is the default configuration for
# all repositories on Codecov. You may adjust the settings
# below in your own codecov.yml in your repository.
#
coverage:
precision: 2
round: down
range: 70...100

status:
# Learn more at https://docs.codecov.io/docs/commit-status
project:
default:
threshold: 1% # allow this much decrease on project
app:
target: 80%
paths: "app/"

changes: false

comment:
Expand All @@ -25,9 +17,13 @@ comment:
require_changes: true

ignore:
- "*.pb.go"
- "*.pb.gw.go"
- "*.md"
- "*.rst"
- "cmd/"
- "contrib/"
- "docs/"
- "networks/"
- "cmd"
- "client"
- "contrib"
- "docs"
- "proto"
- "tests/e2e"
31 changes: 16 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Build & Test
name: Test

on:
workflow_call:
pull_request:
Expand All @@ -18,43 +19,43 @@ jobs:
test-coverage-upload:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
go-version: 1.18
- uses: actions/[email protected]
- uses: technote-space/get-diff-action@v6.0.1
- uses: technote-space/get-diff-action@v6.1.1
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: actions/[email protected].10
- uses: actions/[email protected].11
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }}
restore-keys: |
${{ runner.os }}-go-
- name: build
run: make build
- uses: actions/[email protected]
with:
go-version: 1.18
- name: test & coverage report creation
run: |
make test-unit-cover
- name: filter out DONTCOVER
go test -v -coverprofile=coverage.txt -covermode=atomic -coverpkg=./... $(go list ./...)
- name: filter non-testable files
run: |
excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')"
excludelist+=" $(find ./ -type f -name '*.pb.go')"
excludelist+=" $(find ./ -type f -path './tests/mocks/*.go')"
excludelist+=" $(find ./ -type f -name '*.pb.gw.go')"
excludelist+=" $(find ./cmd -type d)"
excludelist+=" $(find ./tests -type d)"
for filename in ${excludelist}; do
filename=$(echo $filename | sed 's/^./github.com\/cosmos\/cosmos-sdk/g')
filename=${filename#".//"}
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
filename=$(echo "$filename" | sed 's/\//\\\//g')
sed -i.bak "/""$filename""/d" coverage.txt
done
- uses: codecov/[email protected]
with:
file: ./coverage.txt # optional
file: ./coverage.txt
fail_ci_if_error: true

test-e2e:
Expand Down
2 changes: 0 additions & 2 deletions cmd/gaiad/cmd/testnet.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package cmd

// DONTCOVER

import (
"bufio"
"encoding/json"
Expand Down
2 changes: 2 additions & 0 deletions tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// REF: https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
package tools

// DONTCOVER

import (
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
)

0 comments on commit 037d23a

Please sign in to comment.