blob: 2d1d7f2fd7f052b0b272a75d2edfb340a57b6704 (
plain)
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
62
63
64
65
66
67
|
#!/bin/bash
set -e
# Create temporary directory with random name
TEST_DIR=$(mktemp -d -t grasp-audit-run-XXXXXXXXXX)
# Pick a random port in the range 20000-30000
PORT=$((20000 + RANDOM % 10000))
# Generate a unique container name suffix
CONTAINER_SUFFIX=$RANDOM
echo "๐งน Using temporary directory: $TEST_DIR"
echo "๐ Using port: $PORT"
# Cleanup function
cleanup() {
echo "๐ Stopping relay..."
docker stop "grasp-audit-run-$CONTAINER_SUFFIX" 2>/dev/null || true
echo "๐งน Cleaning up temporary directory..."
docker run --rm -v "$TEST_DIR:/data" alpine sh -c "rm -rf /data/*" 2>/dev/null || true
rm -rf "$TEST_DIR"
}
# Set trap to cleanup on exit
trap cleanup EXIT
echo "๐ Creating data directories..."
mkdir -p "$TEST_DIR"/{repos,blossom,relay-db,logs}
echo "๐ Starting ngit-relay..."
# Remove any existing container with this name
CONTAINER_NAME="grasp-audit-run-$CONTAINER_SUFFIX"
docker rm -f "$CONTAINER_NAME" 2>/dev/null || true
docker run --rm -d \
--name "$CONTAINER_NAME" \
-p "$PORT:8081" \
-e NGIT_DOMAIN=localhost \
-e NGIT_RELAY_NAME="ngit-relay test instance" \
-e NGIT_RELAY_DESCRIPTION="Test instance for grasp-audit" \
-e NGIT_OWNER_NPUB="npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr" \
-e NGIT_PROACTIVE_SYNC_GIT=false \
-e NGIT_PROACTIVE_SYNC_BLOSSOM=false \
-e NGIT_PROACTIVE_SYNC_NOSTR=false \
-e NGIT_LOG_LEVEL=INFO \
-v "$TEST_DIR/repos:/srv/ngit-relay/repos" \
-v "$TEST_DIR/blossom:/srv/ngit-relay/blossom" \
-v "$TEST_DIR/relay-db:/srv/ngit-relay/relay-db" \
-v "$TEST_DIR/logs:/var/log/ngit-relay" \
ghcr.io/danconwaydev/ngit-relay:latest
echo "โณ Waiting for relay to start..."
sleep 3
echo "๐งช Running tests..."
echo ""
echo "Note: ngit-relay only accepts Git-related events (NIP-34)."
echo "Some NIP-01 smoke tests will fail (expected behavior)."
echo "Validation tests should pass."
echo ""
# Run the CLI tool (cleanup happens via trap even on failure)
cargo run -- audit --relay "ws://localhost:$PORT" --mode ci --spec nip01-smoke || {
echo "โ ๏ธ Some tests failed (expected for ngit-relay)"
echo " Validation tests should have passed"
}
echo "โ
Done!"
|