-
Notifications
You must be signed in to change notification settings - Fork 7
214 lines (183 loc) · 6.53 KB
/
Copy pathci.yml
File metadata and controls
214 lines (183 loc) · 6.53 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: CI
env:
go-version: "1.25.5"
lint-version: "v2.8.0"
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
# Required: allow read access to the content for analysis.
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read
# Optional: allow write access to checks to allow the action to annotate code in the PR.
checks: write
jobs:
# Test the Go client implementations
test-go-clients:
name: Test Go Clients
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: ${{ env.go-version }}
cache: true
- uses: actions/checkout@v4
- name: Build Proxy Client
run: |
cd grpc_proxy_client
go build -o proxy-client ./proxy_client.go
echo "Proxy client built successfully"
- name: Build Key Generator
run: |
cd keygen
go build -o generate-p2p-key ./generate_p2p_key.go
echo "Key generator built successfully"
- name: Test Key Generation
run: |
cd keygen
go run ./generate_p2p_key.go
echo "Key generation test passed"
# Lint Go code
golangci:
name: Lint Go Code
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: ${{ env.go-version }}
cache: true
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: ${{ env.lint-version }}
args: --timeout 10m
only-new-issues: true
working-directory: ./
continue-on-error: true
# Test Docker Compose setup
test-docker-setup:
name: Test Docker Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Generate P2P Identity
run: |
chmod +x ./script/generate-identity.sh
# Generate identity and capture the BOOTSTRAP_PEER_ID
source ./script/generate-identity.sh
echo "BOOTSTRAP_PEER_ID=$BOOTSTRAP_PEER_ID" >> $GITHUB_ENV
echo "P2P identity generated successfully"
- name: Start Services
run: |
echo "Starting services with BOOTSTRAP_PEER_ID=$BOOTSTRAP_PEER_ID"
BOOTSTRAP_PEER_ID=$BOOTSTRAP_PEER_ID docker-compose -f docker-compose-optimum.yml up --build -d
echo "Services started successfully"
- name: Wait for Services
run: |
echo "Waiting for services to be ready..."
sleep 60
docker-compose -f docker-compose-optimum.yml ps
echo "Checking service logs..."
docker-compose -f docker-compose-optimum.yml logs --tail=30
- name: Health Check Services
run: |
echo "Waiting for services to be healthy..."
max_attempts=30
attempt=1
# Wait for proxy to be ready
while [ $attempt -le $max_attempts ]; do
if curl -f http://localhost:8081/api/v1/health >/dev/null 2>&1; then
echo "Proxy is ready (attempt $attempt)"
break
fi
echo "Waiting for proxy... (attempt $attempt/$max_attempts)"
sleep 10
attempt=$((attempt + 1))
done
if [ $attempt -gt $max_attempts ]; then
echo "Proxy failed to start after $max_attempts attempts"
docker-compose -f docker-compose-optimum.yml logs proxy-1
exit 1
fi
# Wait for P2P node to be ready
attempt=1
while [ $attempt -le $max_attempts ]; do
if curl -f http://localhost:9091/api/v1/health >/dev/null 2>&1; then
echo "P2P node is ready (attempt $attempt)"
break
fi
echo "Waiting for P2P node... (attempt $attempt/$max_attempts)"
sleep 10
attempt=$((attempt + 1))
done
if [ $attempt -gt $max_attempts ]; then
echo "P2P node failed to start after $max_attempts attempts"
docker-compose -f docker-compose-optimum.yml logs p2pnode-1
exit 1
fi
echo "All services are healthy and ready!"
- name: Run Test Suite
run: |
chmod +x ./test_suite.sh
./test_suite.sh
- name: Cleanup
if: always()
run: |
docker-compose -f docker-compose-optimum.yml down -v
echo "Cleanup completed"
# Test shell scripts
test-scripts:
name: Test Shell Scripts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test Generate Identity Script
run: |
chmod +x ./script/generate-identity.sh
./script/generate-identity.sh
echo "Generate identity script test passed"
- name: Test Proxy Client Script
run: |
chmod +x ./script/proxy_client.sh
# Test help output
./script/proxy_client.sh || true
echo "Proxy client script test passed"
- name: Test Makefile
run: |
make help
echo "Makefile help test passed"
# Validate configuration files
validate-config:
name: Validate Configuration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Validate Docker Compose
run: |
docker-compose -f docker-compose-optimum.yml config
docker-compose -f docker-compose-gossipsub.yml config
echo "Docker Compose configurations are valid"
- name: Validate Go Modules
run: |
cd grpc_p2p_client && go mod verify
cd ../grpc_proxy_client && go mod verify
cd ../keygen && go mod verify
echo "All Go modules are valid"