forked from maximhq/bifrost
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-framework.sh
More file actions
executable file
·61 lines (51 loc) · 1.84 KB
/
Copy pathtest-framework.sh
File metadata and controls
executable file
·61 lines (51 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
set -euo pipefail
# Test framework component
# Usage: ./test-framework.sh
# Setup Go workspace for CI
source "$(dirname "$0")/setup-go-workspace.sh"
echo "🧪 Running framework tests..."
# Cleanup function to ensure Docker services are stopped
cleanup_docker() {
echo "🧹 Cleaning up Docker services..."
if command -v docker-compose >/dev/null 2>&1; then
docker-compose -f tests/docker-compose.yml down 2>/dev/null || true
elif docker compose version >/dev/null 2>&1; then
docker compose -f tests/docker-compose.yml down 2>/dev/null || true
fi
}
# Register cleanup handler to run on script exit (success or failure)
trap cleanup_docker EXIT
# Starting dependencies of framework tests
echo "🔧 Starting dependencies of framework tests..."
# Use docker compose (v2) if available, fallback to docker-compose (v1)
if command -v docker-compose >/dev/null 2>&1; then
docker-compose -f tests/docker-compose.yml up -d
elif docker compose version >/dev/null 2>&1; then
docker compose -f tests/docker-compose.yml up -d
else
echo "❌ Neither docker-compose nor docker compose is available"
exit 1
fi
sleep 20
# Validate framework build
echo "🔨 Validating framework build..."
cd framework
go build ./...
echo "✅ Framework build validation successful"
# Run framework tests with coverage
echo "🧪 Running framework tests with coverage..."
go test --race -coverprofile=coverage.txt -coverpkg=./... ./...
# Upload coverage to Codecov
if [ -n "${CODECOV_TOKEN:-}" ]; then
echo "📊 Uploading coverage to Codecov..."
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -t "$CODECOV_TOKEN" -f coverage.txt -F framework
rm -f codecov coverage.txt
else
echo "ℹ️ CODECOV_TOKEN not set, skipping coverage upload"
rm -f coverage.txt
fi
cd ..
echo "✅ Framework tests completed successfully"