Skip to content

Commit 77991ad

Browse files
committed
feat(ci,privacy,workflow): multiple improvements and fixes
- Switch CI matrix to Go 1.23 and 1.24 - Replace Node setup with Go setup and download dependencies - Add build, test, and coverage steps using Make - Upload coverage artifacts - Add PII detection, input validation, and WebSocket security tests
1 parent f888b90 commit 77991ad

File tree

10 files changed

+680
-247
lines changed

10 files changed

+680
-247
lines changed

.github/dependabot.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
version: 2
2+
3+
updates:
4+
# Go modules
5+
- package-ecosystem: "gomod"
6+
directory: "/"
7+
schedule:
8+
interval: "weekly"
9+
day: "monday"
10+
time: "09:00"
11+
open-pull-requests-limit: 10
12+
reviewers:
13+
- "@raaihank"
14+
assignees:
15+
- "@raaihank"
16+
commit-message:
17+
prefix: "deps"
18+
prefix-development: "deps-dev"
19+
include: "scope"
20+
labels:
21+
- "dependencies"
22+
- "go"
23+
allow:
24+
- dependency-type: "direct"
25+
- dependency-type: "indirect"
26+
27+
# Docker
28+
- package-ecosystem: "docker"
29+
directory: "/"
30+
schedule:
31+
interval: "weekly"
32+
day: "monday"
33+
time: "10:00"
34+
open-pull-requests-limit: 5
35+
reviewers:
36+
- "@raaihank"
37+
assignees:
38+
- "@raaihank"
39+
commit-message:
40+
prefix: "docker"
41+
include: "scope"
42+
labels:
43+
- "dependencies"
44+
- "docker"
45+
46+
# GitHub Actions
47+
- package-ecosystem: "github-actions"
48+
directory: "/"
49+
schedule:
50+
interval: "weekly"
51+
day: "monday"
52+
time: "11:00"
53+
open-pull-requests-limit: 5
54+
reviewers:
55+
- "@raaihank"
56+
assignees:
57+
- "@raaihank"
58+
commit-message:
59+
prefix: "ci"
60+
include: "scope"
61+
labels:
62+
- "dependencies"
63+
- "github-actions"
64+
- "ci"

.github/workflows/build.yml

Lines changed: 116 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ name: CI - Build
22

33
on:
44
push:
5+
branches: [ main, develop ]
56
pull_request:
7+
branches: [ main, develop ]
68

79
permissions:
810
contents: read
@@ -13,80 +15,82 @@ concurrency:
1315

1416
jobs:
1517
build:
16-
name: Node ${{ matrix.node }} - Build & Test
17-
runs-on: ubuntu-latest
18+
name: Go ${{ matrix.go-version }} - Build & Test
19+
runs-on: ${{ matrix.os }}
1820
timeout-minutes: 30
1921
strategy:
2022
fail-fast: false
2123
matrix:
22-
node: [18, 20, 22]
24+
os: [ubuntu-latest, macos-latest, windows-latest]
25+
go-version: ['1.23', '1.24']
2326

2427
env:
25-
CI: true
26-
FORCE_COLOR: 1
27-
NODE_ENV: production
28+
CGO_ENABLED: 0
2829

2930
steps:
3031
- name: Checkout
3132
uses: actions/checkout@v4
3233

33-
- name: Setup Node.js
34-
uses: actions/setup-node@v4
34+
- name: Setup Go
35+
uses: actions/setup-go@v5
3536
with:
36-
node-version: ${{ matrix.node }}
37+
go-version: ${{ matrix.go-version }}
3738
check-latest: true
38-
cache: npm
39-
cache-dependency-path: package-lock.json
39+
cache: true
4040

41-
- name: Install dependencies
41+
- name: Verify Go installation
4242
run: |
43-
if [ -f package-lock.json ]; then
44-
echo "Installing server dependencies with npm ci..."
45-
npm ci
46-
else
47-
echo "No lockfile found; running npm install"
48-
npm install
49-
fi
43+
go version
44+
go env GOVERSION
45+
go env GOOS
46+
go env GOARCH
5047
51-
- name: Type check
52-
run: npm run typecheck
48+
- name: Download dependencies
49+
run: go mod download
5350

54-
- name: Build (server + dashboard)
55-
run: npm run build
51+
- name: Verify dependencies
52+
run: go mod verify
5653

54+
- name: Build binary
55+
run: |
56+
echo "Building LLM-Sentinel binary..."
57+
make build
58+
5759
- name: Verify build artifacts
60+
shell: bash
5861
run: |
59-
echo "Checking server build..."
60-
test -f dist/cli.js || (echo "Missing dist/cli.js" && exit 1)
61-
test -f dist/proxy-server.js || (echo "Missing dist/proxy-server.js" && exit 1)
62-
63-
echo "Checking dashboard build..."
64-
test -f dist/dashboard/index.html || (echo "Missing dist/dashboard/index.html" && exit 1)
65-
62+
echo "Checking build artifacts..."
63+
if [[ "$RUNNER_OS" == "Windows" ]]; then
64+
test -f bin/sentinel.exe || (echo "Missing bin/sentinel.exe" && exit 1)
65+
echo "Windows binary created: bin/sentinel.exe"
66+
else
67+
test -f bin/sentinel || (echo "Missing bin/sentinel" && exit 1)
68+
echo "Unix binary created: bin/sentinel"
69+
fi
6670
echo "Build verification complete ✅"
6771
68-
- name: Test production server start
72+
- name: Test binary execution
73+
shell: bash
6974
run: |
70-
echo "Testing production server startup..."
71-
timeout 10s node dist/cli.js start -p 5050 &
72-
SERVER_PID=$!
73-
sleep 5
74-
75-
# Test health endpoint
76-
curl -f http://localhost:5050/health || (echo "Health check failed" && exit 1)
77-
78-
# Test dashboard
79-
curl -f http://localhost:5050 | grep -q "LLM-Sentinel" || (echo "Dashboard not loading" && exit 1)
80-
81-
kill $SERVER_PID || true
82-
echo "Production server test passed ✅"
75+
echo "Testing binary execution..."
76+
if [[ "$RUNNER_OS" == "Windows" ]]; then
77+
./bin/sentinel.exe --version
78+
./bin/sentinel.exe --help
79+
else
80+
./bin/sentinel --version
81+
./bin/sentinel --help
82+
fi
83+
echo "Binary execution test passed ✅"
8384
84-
- name: Upload dist artifact
85+
- name: Upload binary artifact
8586
uses: actions/upload-artifact@v4
8687
with:
87-
name: dist-node-${{ matrix.node }}
88-
path: dist
88+
name: sentinel-${{ matrix.os }}-go${{ matrix.go-version }}
89+
path: |
90+
bin/sentinel*
91+
configs/
8992
if-no-files-found: error
93+
retention-days: 7
9094

9195
docker:
9296
name: Docker Build Test
@@ -98,30 +102,90 @@ jobs:
98102
- name: Checkout
99103
uses: actions/checkout@v4
100104

105+
- name: Set up Docker Buildx
106+
uses: docker/setup-buildx-action@v3
107+
101108
- name: Build Docker image
102109
run: |
103110
echo "Building Docker image..."
104111
docker build -t llm-sentinel:test .
105112
113+
- name: Test Docker image size
114+
run: |
115+
echo "Checking Docker image size..."
116+
docker images llm-sentinel:test
117+
SIZE=$(docker images llm-sentinel:test --format "table {{.Size}}" | tail -1)
118+
echo "Image size: $SIZE"
119+
106120
- name: Test Docker container
107121
run: |
108122
echo "Starting Docker container..."
109-
docker run -d -p 5050:5050 --name test-container llm-sentinel:test
123+
docker run -d -p 8080:8080 --name test-container llm-sentinel:test
110124
111125
# Wait for container to start
126+
echo "Waiting for container to start..."
112127
sleep 10
113128
114129
# Test health endpoint
115-
curl -f http://localhost:5050/health || (echo "Docker health check failed" && exit 1)
130+
echo "Testing health endpoint..."
131+
curl -f http://localhost:8080/health || (echo "Docker health check failed" && exit 1)
132+
133+
# Test info endpoint
134+
echo "Testing info endpoint..."
135+
curl -f http://localhost:8080/info || (echo "Docker info check failed" && exit 1)
116136
117137
# Test dashboard
118-
curl -f http://localhost:5050 | grep -q "LLM-Sentinel" || (echo "Docker dashboard not loading" && exit 1)
138+
echo "Testing dashboard..."
139+
curl -f http://localhost:8080/ | grep -q "LLM-Sentinel" || (echo "Docker dashboard not loading" && exit 1)
119140
120-
# Check logs
141+
# Check container logs
142+
echo "Container logs:"
121143
docker logs test-container
122144
123145
# Cleanup
124146
docker stop test-container
125147
docker rm test-container
126148
127-
echo "Docker test passed ✅"
149+
echo "Docker test passed ✅"
150+
151+
lint:
152+
name: Go Lint & Format Check
153+
runs-on: ubuntu-latest
154+
timeout-minutes: 10
155+
156+
steps:
157+
- name: Checkout
158+
uses: actions/checkout@v4
159+
160+
- name: Setup Go
161+
uses: actions/setup-go@v5
162+
with:
163+
go-version: '1.23'
164+
check-latest: true
165+
cache: true
166+
167+
- name: golangci-lint
168+
uses: golangci/golangci-lint-action@v6
169+
with:
170+
version: latest
171+
args: --timeout=5m
172+
173+
- name: Check formatting
174+
run: |
175+
echo "Checking Go formatting..."
176+
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
177+
echo "❌ Go files are not formatted. Run 'make fmt' to fix:"
178+
gofmt -s -l .
179+
exit 1
180+
fi
181+
echo "✅ All Go files are properly formatted"
182+
183+
- name: Check mod tidy
184+
run: |
185+
echo "Checking go mod tidy..."
186+
go mod tidy
187+
if ! git diff --exit-code go.mod go.sum; then
188+
echo "❌ go.mod or go.sum is not tidy. Run 'go mod tidy' to fix."
189+
exit 1
190+
fi
191+
echo "✅ go.mod and go.sum are tidy"

0 commit comments

Comments
 (0)