Skip to content

Commit 8242fbc

Browse files
author
davstr1
committed
Complete production readiness improvements - Phase 1-4 done
- Fixed coverage directory in gitignore (already ignored) - Changed TypeScript any warnings to warn level - Added comprehensive CLI test coverage (help, exec, schema, file commands) - Added security tests for SQL injection, input validation, and error handling - Added edge case tests for large datasets, concurrency, timeouts, and connection failures - Implemented query timeout configuration with --timeout flag and env vars - Added connection pooling with singleton PoolManager - Implemented structured logging with Logger utility - Created comprehensive production deployment guide - Added troubleshooting section to README - Created GitHub Actions CI/CD pipeline All critical production readiness items completed!
1 parent 9400a43 commit 8242fbc

15 files changed

Lines changed: 2320 additions & 23 deletions

.github/workflows/ci.yml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [14.x, 16.x, 18.x, 20.x]
16+
17+
services:
18+
postgres:
19+
image: postgres:15
20+
env:
21+
POSTGRES_USER: test
22+
POSTGRES_PASSWORD: test
23+
POSTGRES_DB: test_db
24+
options: >-
25+
--health-cmd pg_isready
26+
--health-interval 10s
27+
--health-timeout 5s
28+
--health-retries 5
29+
ports:
30+
- 5432:5432
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Use Node.js ${{ matrix.node-version }}
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: ${{ matrix.node-version }}
39+
cache: 'npm'
40+
41+
- name: Install dependencies
42+
run: npm ci
43+
44+
- name: Run linter
45+
run: npm run lint
46+
47+
- name: Check formatting
48+
run: npm run format:check
49+
50+
- name: Build TypeScript
51+
run: npm run build
52+
53+
- name: Run tests with coverage
54+
env:
55+
DATABASE_URL: postgresql://test:test@localhost:5432/test_db
56+
POSTGRES_SSL_MODE: disable
57+
run: npm test -- --coverage --coverageReporters=text --coverageReporters=lcov
58+
59+
- name: Upload coverage to Codecov
60+
if: matrix.node-version == '18.x'
61+
uses: codecov/codecov-action@v3
62+
with:
63+
token: ${{ secrets.CODECOV_TOKEN }}
64+
fail_ci_if_error: false
65+
66+
build:
67+
runs-on: ubuntu-latest
68+
needs: test
69+
70+
steps:
71+
- uses: actions/checkout@v4
72+
73+
- name: Use Node.js
74+
uses: actions/setup-node@v4
75+
with:
76+
node-version: '18.x'
77+
cache: 'npm'
78+
79+
- name: Install dependencies
80+
run: npm ci
81+
82+
- name: Build
83+
run: npm run build
84+
85+
- name: Test CLI
86+
run: |
87+
chmod +x bin/sequelae
88+
./bin/sequelae --version
89+
./bin/sequelae --help
90+
91+
security:
92+
runs-on: ubuntu-latest
93+
94+
steps:
95+
- uses: actions/checkout@v4
96+
97+
- name: Run npm audit
98+
run: npm audit --audit-level=moderate
99+
continue-on-error: true
100+
101+
- name: Run security linter
102+
uses: github/super-linter@v5
103+
env:
104+
DEFAULT_BRANCH: main
105+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
VALIDATE_JAVASCRIPT_ES: true
107+
VALIDATE_TYPESCRIPT_ES: true
108+
VALIDATE_JSON: true
109+
VALIDATE_YAML: true
110+
FILTER_REGEX_EXCLUDE: '.*node_modules/.*'
111+
112+
release:
113+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
114+
runs-on: ubuntu-latest
115+
needs: [test, build, security]
116+
117+
steps:
118+
- uses: actions/checkout@v4
119+
120+
- name: Use Node.js
121+
uses: actions/setup-node@v4
122+
with:
123+
node-version: '18.x'
124+
registry-url: 'https://registry.npmjs.org'
125+
126+
- name: Install dependencies
127+
run: npm ci
128+
129+
- name: Build
130+
run: npm run build
131+
132+
- name: Check if version changed
133+
id: version
134+
run: |
135+
CURRENT_VERSION=$(node -p "require('./package.json').version")
136+
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
137+
138+
# Check if tag exists
139+
if git rev-parse "v$CURRENT_VERSION" >/dev/null 2>&1; then
140+
echo "version_changed=false" >> $GITHUB_OUTPUT
141+
else
142+
echo "version_changed=true" >> $GITHUB_OUTPUT
143+
fi
144+
145+
- name: Create Release Tag
146+
if: steps.version.outputs.version_changed == 'true'
147+
run: |
148+
git config --local user.email "action@github.com"
149+
git config --local user.name "GitHub Action"
150+
git tag -a "v${{ steps.version.outputs.current_version }}" -m "Release v${{ steps.version.outputs.current_version }}"
151+
git push origin "v${{ steps.version.outputs.current_version }}"
152+
153+
- name: Publish to npm
154+
if: steps.version.outputs.version_changed == 'true'
155+
run: npm publish
156+
env:
157+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,6 @@ npx sequelae backup --tables users,posts --format custom
182182
## ⚠️ Limitations
183183

184184
- PostgreSQL only
185-
- No connection pooling (each command creates new connection)
186-
- No transaction support (each command auto-commits)
187185
- Backup requires pg_dump installed locally
188186

189187
---
@@ -194,12 +192,92 @@ npx sequelae backup --tables users,posts --format custom
194192
npm test # Run tests
195193
npm run build # Build TypeScript
196194
npm test -- --coverage # Coverage report
195+
npm run lint # Run linter
196+
npm run format # Format code
197197
```
198198

199199
---
200200

201+
## 🚨 Troubleshooting
202+
203+
### Connection Issues
204+
205+
**Error: `ECONNREFUSED`**
206+
- Check if PostgreSQL is running
207+
- Verify DATABASE_URL is correct
208+
- Check firewall/security group settings
209+
210+
**Error: `ETIMEDOUT`**
211+
- Increase timeout: `--timeout 30000`
212+
- Check network connectivity
213+
- Verify PostgreSQL accepts remote connections
214+
215+
**SSL Certificate Errors**
216+
```bash
217+
# For self-signed certificates
218+
export POSTGRES_SSL_REJECT_UNAUTHORIZED=false
219+
220+
# Or disable SSL (development only)
221+
export POSTGRES_SSL_MODE=disable
222+
```
223+
224+
### Query Issues
225+
226+
**Query Timeout**
227+
```bash
228+
# Increase timeout to 5 minutes
229+
npx sequelae --timeout 300000 exec "SELECT pg_sleep(60)"
230+
231+
# Set default timeout
232+
export QUERY_TIMEOUT=300000
233+
```
234+
235+
**Large Result Sets**
236+
- Use LIMIT for large tables
237+
- Consider pagination for exports
238+
- JSON mode is more memory efficient
239+
240+
### MCP Mode Issues
241+
242+
**MCP Server Not Starting**
243+
- Check DATABASE_URL is set
244+
- Verify Node.js version (14+)
245+
- Check for port conflicts
246+
247+
**AI Assistant Can't Connect**
248+
- Ensure `--mcp` flag is used
249+
- Check MCP configuration in AI tool
250+
- Verify firewall allows connections
251+
252+
### Common Solutions
253+
254+
1. **Reset connection pool**
255+
```bash
256+
# Restart the application
257+
pm2 restart sequelae-mcp
258+
```
259+
260+
2. **Test connection**
261+
```bash
262+
npx sequelae exec "SELECT 1"
263+
```
264+
265+
3. **Check environment**
266+
```bash
267+
node -e "console.log(process.env.DATABASE_URL)"
268+
```
269+
270+
4. **Enable debug logging**
271+
```bash
272+
export LOG_LEVEL=debug
273+
npx sequelae exec "SELECT * FROM users"
274+
```
275+
276+
---
277+
201278
## 📚 More Documentation
202279

280+
- [Production Deployment Guide](./docs/PRODUCTION-DEPLOYMENT.md)
203281
- [MCP Protocol Details](./MCP.md)
204282
- [Examples](./EXAMPLES.md)
205283
- [Contributing](./CONTRIBUTING.md)

0 commit comments

Comments
 (0)