Files
mohomo-docker/scripts/test.sh
Rogee 05e78dc882
Docker image / Test (push) Canceled after 0s
Docker image / Build and publish (push) Canceled after 0s
ci: publish amd64 image to GHCR
2026-08-21 13:55:26 +08:00

29 lines
713 B
Bash
Executable File

#!/bin/sh
set -eu
project_root=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
cd "$project_root"
./tests/workflow-contract.sh
unformatted=$(gofmt -l cmd internal)
if [ -n "$unformatted" ]; then
echo "Go files require formatting:" >&2
echo "$unformatted" >&2
exit 1
fi
go test -race -coverprofile=coverage.out ./internal/...
coverage=$(go tool cover -func=coverage.out | awk '/^total:/ { gsub(/%/, "", $3); print $3 }')
awk -v coverage="$coverage" 'BEGIN { if (coverage + 0 < 65) exit 1 }' || {
echo "unit test coverage ${coverage}% is below required 65%" >&2
exit 1
}
echo "unit test coverage: ${coverage}%"
go test ./...
if command -v docker >/dev/null 2>&1; then
docker compose config --quiet
fi