-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moves package iteration from ci.yml to bash script
- Loading branch information
1 parent
16f41be
commit 0689ae8
Showing
2 changed files
with
99 additions
and
56 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,92 @@ | ||
#!/bin/bash | ||
|
||
check_missing_value() { | ||
if [[ $1 -eq 0 || $2 == -* ]]; then | ||
echo "missing $3 argument value" | ||
exit 1 | ||
fi | ||
} | ||
|
||
timeout="" | ||
tags="" | ||
run="" | ||
race=false | ||
cover=false | ||
write_full_log=false | ||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
--timeout) | ||
shift | ||
check_missing_value $# "$1" "--timeout" | ||
timeout=$1 | ||
shift | ||
;; | ||
--tags) | ||
shift | ||
check_missing_value $# "$1" "--tags" | ||
tags=$1 | ||
shift | ||
;; | ||
--run) | ||
shift | ||
check_missing_value $# "$1" "--run" | ||
run=$1 | ||
shift | ||
;; | ||
--race) | ||
race=true | ||
shift | ||
;; | ||
--cover) | ||
cover=true | ||
shift | ||
;; | ||
--write-full-log) | ||
write_full_log=true | ||
shift | ||
;; | ||
*) | ||
echo "Invalid argument: $1" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
packages=$(go list ./...) | ||
for package in $packages; do | ||
cmd="stdbuf -oL gotestsum --format short-verbose --packages=\"$package\" --rerun-fails=2 --no-color=false --" | ||
|
||
if [ "$timeout" != "" ]; then | ||
cmd="$cmd -timeout $timeout" | ||
else | ||
cmd="$cmd -timeout 20m" | ||
fi | ||
|
||
if [ "$tags" != "" ]; then | ||
cmd="$cmd -tags=$tags" | ||
fi | ||
|
||
if [ "$run" != "" ]; then | ||
cmd="$cmd -run=$run" | ||
fi | ||
|
||
if [ "$race" == true ]; then | ||
cmd="$cmd -race" | ||
fi | ||
|
||
if [ "$cover" == true ]; then | ||
cmd="$cmd -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/..." | ||
fi | ||
|
||
if [ "$write_full_log" == true ]; then | ||
cmd="$cmd > >(stdbuf -oL tee -a full.log | grep -vE \"INFO|seal\")" | ||
fi | ||
|
||
echo "" | ||
echo running tests for "$package" | ||
echo "$cmd" | ||
|
||
if ! eval "$cmd"; then | ||
exit 1 | ||
fi | ||
done |