...
1 #!/bin/bash
2
3 # all files should be here
4 files=(
5 main.go
6 parser/*.go
7 tracker/*.go
8 torrent/*.go
9 queue/*.go
10 piece/*.go
11 args/*.go
12 )
13
14 # script for formatting
15 for i in "${files[@]}"; do
16 gofmt -w "$i"
17 done
18
19 # script for running test files
20 go test ./... -v
21
22 #checking goreportcard-cli for issues
23 set -e
24 report=$(goreportcard-cli)
25 startindex=$(($(echo $report | grep -b -o Issue | cut -d: -f1)+8))
26 endindex=$(($(echo $report|grep -b -o gofmt | cut -d: -f1)-1))
27 issuecount=${report:$startindex:$endindex-$startindex}
28 if [ $issuecount == "0" ]; then
29 echo "goreportcard-cli passed"
30 fi
31 if [ $issuecount != 0 ]; then
32 echo $issuecount" issues. Run \`goreportcard-cli -v\` to check. Ignore the issues from \`vendor\` directory"
33 exit 1
34 fi
35
36 echo "Build Successful!"
View as plain text