-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Codecov tool to show the code coverages (#26)
- Loading branch information
Showing
12 changed files
with
809 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
|
||
GOPATH_BIN=$(go env GOPATH)/bin | ||
|
||
LOG_ERROR() { | ||
content=${1} | ||
echo -e "\033[31m${content}\033[0m" | ||
} | ||
|
||
LOG_INFO() { | ||
content=${1} | ||
echo -e "\033[32m${content}\033[0m" | ||
} | ||
|
||
execute_cmd() { | ||
command="${1}" | ||
eval "${command}" | ||
ret=$? | ||
if [ $ret -ne 0 ]; then | ||
LOG_ERROR "FAILED of command: ${command}" | ||
exit 1 | ||
else | ||
LOG_INFO "SUCCESS of command: ${command}" | ||
fi | ||
} | ||
|
||
generate_hello() { | ||
local struct="${1}" | ||
local output="${2}" | ||
go get -u github.com/sqs/goreturns # to format code style | ||
cat << EOF >> "${output}" | ||
func main() { | ||
configs := conf.ParseConfig("config.toml") | ||
client, err := client.Dial(&configs[0]) | ||
if err != nil { | ||
fmt.Printf("Dial Client failed, err:%v", err) | ||
return | ||
} | ||
address, tx, _, err := Deploy${struct}(client.GetTransactOpts(), client) | ||
if err != nil { | ||
fmt.Printf("Deploy failed, err:%v", err) | ||
return | ||
} | ||
fmt.Println(address.Hex()) // the address should be saved | ||
fmt.Println(tx.Hash().Hex()) | ||
} | ||
EOF | ||
"${GOPATH_BIN}"/goreturns -w "${output}" | ||
} | ||
|
||
calculate_coverage() { | ||
# start blockchain demo | ||
curl -LO https://raw.githubusercontent.com/FISCO-BCOS/FISCO-BCOS/master/tools/build_chain.sh && chmod u+x build_chain.sh | ||
bash build_chain.sh -l 127.0.0.1:4 -o nodes | ||
cp nodes/127.0.0.1/sdk/* ./ | ||
bash nodes/127.0.0.1/start_all.sh | ||
|
||
# generate code coverage report | ||
go test ./... -race -coverprofile=coverage.txt -covermode=atomic | ||
} | ||
|
||
calculate_coverage |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Calculate Code Coverage | ||
on: | ||
push: | ||
paths-ignore: | ||
- "Changelog.md" | ||
- "README.md" | ||
pull_request: | ||
|
||
jobs: | ||
coverage: | ||
name: coverage | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.14 | ||
- name: generate code coverage report | ||
run: bash .ci/generate_coverage.sh | ||
- name: upload code coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
file: ./coverage.txt | ||
name: go-sdk code coverage | ||
fail_ci_if_error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.