Skip to content

chore: add coveralls #1813

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 8 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci-badger-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ jobs:
run: make dependency
- name: Run Badger Tests
run: make test
- name: Install Goveralls
run: go install github.com/mattn/goveralls@latest
- name: Send Coverage Results
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLSIO_TOKEN }}
run: goveralls -coverprofile=cover.out
50 changes: 32 additions & 18 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ set -eo pipefail

go version

# Check if Github Actions is running
if [ $CI = "true" ]; then
# Enable code coverage
# export because tests run in a subprocess
export covermode="-covermode=atomic"
export coverprofile="-coverprofile=cover_tmp.out"
echo "mode: atomic" >> cover.out
fi

# Run `go list` BEFORE setting GOFLAGS so that the output is in the right
# format for grep.
# export packages because the test will run in a sub process.
export packages=$(go list ./... | grep "github.com/dgraph-io/badger/v3/")

tags="-tags=jemalloc"

# Ensure that we can compile the binary.
# Compile the Badger binary
pushd badger
go build -v $tags .
popd
Expand All @@ -23,18 +32,18 @@ manual() {
set -e
for pkg in $packages; do
echo "===> Testing $pkg"
go test $tags -timeout=25m -race $pkg -parallel 16
go test $tags -timeout=25m $covermode $coverprofile -race -parallel 16 $pkg && write_coverage
done
echo "==> DONE package tests"

echo "==> Running manual tests"
# Run the special Truncate test.
rm -rf p
set -e
go test $tags $timeout -run='TestTruncateVlogNoClose$' --manual=true
go test $tags $timeout $covermode $coverprofile -run='TestTruncateVlogNoClose$' --manual=true && write_coverage
truncate --size=4096 p/000000.vlog
go test $tags $timeout -run='TestTruncateVlogNoClose2$' --manual=true
go test $tags $timeout -run='TestTruncateVlogNoClose3$' --manual=true
go test $tags $timeout $covermode $coverprofile -run='TestTruncateVlogNoClose2$' --manual=true && write_coverage
go test $tags $timeout $covermode $coverprofile -run='TestTruncateVlogNoClose3$' --manual=true && write_coverage
rm -rf p

# TODO(ibrahim): Let's make these tests have Manual prefix.
Expand All @@ -43,14 +52,14 @@ manual() {
# TestValueGCManaged
# TestDropPrefix
# TestDropAllManaged
go test $tags $timeout -run='TestBigKeyValuePairs$' --manual=true
go test $tags $timeout -run='TestPushValueLogLimit' --manual=true
go test $tags $timeout -run='TestKeyCount' --manual=true
go test $tags $timeout -run='TestIteratePrefix' --manual=true
go test $tags $timeout -run='TestIterateParallel' --manual=true
go test $tags $timeout -run='TestBigStream' --manual=true
go test $tags $timeout -run='TestGoroutineLeak' --manual=true
go test $tags $timeout -run='TestGetMore' --manual=true
go test $tags $timeout $covermode $coverprofile -run='TestBigKeyValuePairs$' --manual=true && write_coverage
go test $tags $timeout $covermode $coverprofile -run='TestPushValueLogLimit' --manual=true && write_coverage
go test $tags $timeout $covermode $coverprofile -run='TestKeyCount' --manual=true && write_coverage
go test $tags $timeout $covermode $coverprofile -run='TestIteratePrefix' --manual=true && write_coverage
go test $tags $timeout $covermode $coverprofile -run='TestIterateParallel' --manual=true && write_coverage
go test $tags $timeout $covermode $coverprofile -run='TestBigStream' --manual=true && write_coverage
go test $tags $timeout $covermode $coverprofile -run='TestGoroutineLeak' --manual=true && write_coverage
go test $tags $timeout $covermode $coverprofile -run='TestGetMore' --manual=true && write_coverage

echo "==> DONE manual tests"
}
Expand All @@ -61,7 +70,7 @@ root() {

echo "==> Running root level tests."
set -e
go test $tags -timeout=25m . -v -race -parallel 16
go test $tags -v -race -parallel=16 -timeout=25m $covermode $coverprofile . && write_coverage
echo "==> DONE root level tests"
}

Expand All @@ -84,13 +93,18 @@ stream() {
return 0
}

export -f stream
export -f manual
export -f root
write_coverage() {
if [ $CI = "true" ]; then
if [ -f cover_tmp.out ]; then
sed -i '1d' cover_tmp.out
cat cover_tmp.out >> cover.out && rm cover_tmp.out
fi
fi

}

# parallel tests currently not working
# parallel --halt now,fail=1 --progress --line-buffer ::: stream manual root

# run tests in sequence
root
stream
Expand Down