yapapaway / .github /workflows /scripts /test-core.sh
shinmentakezo07
Add source files required for Space build
8baf122
Raw
History Blame Contribute Delete
1.57 kB
#!/usr/bin/env bash
set -euo pipefail
# Test core component
# Usage: ./test-core.sh
# Setup Go workspace for CI
source "$(dirname "$0")/setup-go-workspace.sh"
echo "πŸ§ͺ Running core tests..."
# Build MCP test servers for STDIO tests
echo "πŸ”§ Building MCP test servers..."
for mcp_dir in examples/mcps/*/; do
if [ -d "$mcp_dir" ]; then
mcp_name=$(basename "$mcp_dir")
if [ -f "$mcp_dir/go.mod" ]; then
echo " Building $mcp_name (Go)..."
mkdir -p "$mcp_dir/bin"
pushd "$mcp_dir" > /dev/null
GOWORK=off go build -o "bin/$mcp_name" .
popd > /dev/null
elif [ -f "$mcp_dir/package.json" ]; then
echo " Building $mcp_name (TypeScript)..."
pushd "$mcp_dir" > /dev/null
npm install --silent && npm run build
popd > /dev/null
fi
fi
done
echo "βœ… MCP test servers built"
# Validate core build
echo "πŸ”¨ Validating core build..."
cd core
go mod download
go build ./...
echo "βœ… Core build validation successful"
# Run core tests with coverage
echo "πŸ§ͺ Running core tests with coverage..."
go test -race -timeout 20m -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 core
rm -f codecov coverage.txt
else
echo "ℹ️ CODECOV_TOKEN not set, skipping coverage upload"
rm -f coverage.txt
fi
cd ..
echo "βœ… Core tests completed successfully"