#!/usr/bin/env bash set -euo pipefail export GOPROXY=off GOFLAGS=-mod=mod git diff --quiet HEAD -- semver.go || { echo "semver.go was modified"; exit 1; } ls *_test.go >/dev/null 2>&1 || { echo "no test file was written"; exit 1; } go test ./... 2>&1 cov=$(go test -cover ./... 2>/dev/null | grep -o '[0-9.]*% of statements' | grep -o '^[0-9.]*') echo "coverage: ${cov}%" awk -v c="$cov" 'BEGIN { exit (c+0 >= 80) ? 0 : 1 }' || { echo "coverage ${cov}% is below 80%"; exit 1; } grep -q 'Compare' *_test.go || { echo "Compare is untested"; exit 1; }