-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (118 loc) · 3.84 KB
/
Copy pathtest.yaml
File metadata and controls
139 lines (118 loc) · 3.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: tests
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
on:
push:
paths:
- 'neutrino_server/**'
- 'docker-compose.yml'
- '.github/workflows/test.yaml'
pull_request:
paths:
- 'neutrino_server/**'
- 'docker-compose.yml'
- '.github/workflows/test.yaml'
workflow_dispatch:
workflow_call:
jobs:
test-neutrino:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- name: Set up Go
uses: actions/setup-go@v6.4.0
with:
go-version: '1.25'
cache-dependency-path: neutrino_server/go.sum
- name: Install dependencies
working-directory: neutrino_server
run: go mod download
- name: Run go vet
working-directory: neutrino_server
run: go vet ./...
- name: Run staticcheck
working-directory: neutrino_server
run: |
go install honnef.co/go/tools/cmd/staticcheck@v0.7.0
staticcheck ./...
- name: Run tests
working-directory: neutrino_server
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
- name: Upload coverage
uses: codecov/codecov-action@v6.0.1
with:
files: ./neutrino_server/coverage.out
flags: unittests
if: ${{ always() && hashFiles('neutrino_server/coverage.out') != '' }}
test-docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- name: Build Docker image
run: docker build -t neutrino-api:test ./neutrino_server
- name: Test Docker image runs
run: |
docker run -d --name neutrino-test -p 8334:8334 \
-e NETWORK=regtest \
-e LOG_LEVEL=debug \
neutrino-api:test
sleep 5
docker logs neutrino-test
docker stop neutrino-test
test-integration:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6.0.2
- name: Start services
run: docker compose up -d --build
- name: Wait for Bitcoin
run: |
echo "Waiting for Bitcoin..."
for i in {1..60}; do
if docker compose exec -T bitcoin bitcoin-cli -chain=regtest \
-rpcport=18443 -rpcuser=test -rpcpassword=test getblockchaininfo 2>/dev/null; then
echo "Bitcoin ready"
break
fi
echo "Attempt $i/60..."
sleep 2
done
- name: Wait for Neutrino
run: |
echo "Waiting for Neutrino..."
for i in {1..60}; do
if curl -s http://localhost:8334/v1/status 2>/dev/null | grep -q "synced"; then
echo "Neutrino ready"
break
fi
echo "Attempt $i/60..."
sleep 2
done
- name: Test API endpoints
run: |
# Test status endpoint
echo "Testing /v1/status..."
STATUS=$(curl -s http://localhost:8334/v1/status)
echo "Status response: $STATUS"
# Verify response has expected fields
echo "$STATUS" | jq -e '.synced != null' || exit 1
echo "$STATUS" | jq -e '.block_height != null' || exit 1
echo "$STATUS" | jq -e '.filter_height != null' || exit 1
echo "$STATUS" | jq -e '.peers != null' || exit 1
# Test peers endpoint
echo "Testing /v1/peers..."
PEERS=$(curl -s http://localhost:8334/v1/peers)
echo "Peers response: $PEERS"
echo "$PEERS" | jq -e '.count != null' || exit 1
- name: Show logs on failure
if: failure()
run: |
echo "=== Neutrino logs ==="
docker compose logs neutrino
echo ""
echo "=== Bitcoin logs ==="
docker compose logs bitcoin
- name: Cleanup
if: always()
run: docker compose down -v