Files
mohomo-docker/scripts/test.sh
T
rogee 37643321fc
Docker image / Test (push) Successful in 38s
Docker image / Build and publish (push) Failing after 31s
HH-594: generate ACL4SSR subscription config (#1)
2026-08-24 12:45:44 +08:00

29 lines
774 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
SUBSCRIPTION_URL=https://subscription.example.invalid/mihomo docker compose config --quiet
fi