Skip to content

Commit 6e4c6aa

Browse files
committed
fix: resolve ESLint errors and improve CI/CD workflows
ESLint fixes: - Replace `as any` with proper union type in channels route - Replace `{} as any` with typed assertion in messaging-metrics - Replace require('zlib') with top-level gunzipSync import in database-session-store and session-archiver CI/CD improvements: - Upgrade setup-bun@v1 to @v2 (v1 deprecated) - Add bun dependency caching via actions/cache@v4 - Add concurrency groups to prevent duplicate CI runs and overlapping deploys - Fix `bun test` to `bun test --run` to prevent watch mode hang - Upgrade appleboy/ssh-action@v1.0.0 to @v1 - Upgrade getsentry/action-release@v1 to @V3 (v1 deprecated) - Add guard to skip Sentry step when auth token is missing - Add retry logic (3 attempts) to health check - Remove redundant deployment notification step
1 parent 037c7f5 commit 6e4c6aa

6 files changed

Lines changed: 49 additions & 26 deletions

File tree

.github/workflows/ci.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
push:
77
branches: [main, develop]
88

9+
concurrency:
10+
group: ci-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
lint-and-type-check:
1115
name: Lint and Type Check
@@ -16,20 +20,25 @@ jobs:
1620
uses: actions/checkout@v4
1721

1822
- name: Setup Bun
19-
uses: oven-sh/setup-bun@v1
23+
uses: oven-sh/setup-bun@v2
2024
with:
2125
bun-version: latest
2226

27+
- name: Cache bun dependencies
28+
uses: actions/cache@v4
29+
with:
30+
path: ~/.bun/install/cache
31+
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
32+
restore-keys: bun-${{ runner.os }}-
33+
2334
- name: Install dependencies
2435
run: bun install --frozen-lockfile
2536

2637
- name: Run ESLint
2738
run: bun run lint
28-
continue-on-error: false
2939

3040
- name: Run TypeScript type check
3141
run: bun run tsc --noEmit
32-
continue-on-error: false
3342

3443
test:
3544
name: Run Tests
@@ -41,10 +50,17 @@ jobs:
4150
uses: actions/checkout@v4
4251

4352
- name: Setup Bun
44-
uses: oven-sh/setup-bun@v1
53+
uses: oven-sh/setup-bun@v2
4554
with:
4655
bun-version: latest
4756

57+
- name: Cache bun dependencies
58+
uses: actions/cache@v4
59+
with:
60+
path: ~/.bun/install/cache
61+
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
62+
restore-keys: bun-${{ runner.os }}-
63+
4864
- name: Install dependencies
4965
run: bun install --frozen-lockfile
5066

.github/workflows/deploy-production.yml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
branches: [main]
66
workflow_dispatch:
77

8+
concurrency:
9+
group: deploy-production
10+
cancel-in-progress: false
11+
812
jobs:
913
test:
1014
name: Run Tests and Linting
@@ -19,14 +23,21 @@ jobs:
1923
with:
2024
bun-version: latest
2125

26+
- name: Cache bun dependencies
27+
uses: actions/cache@v4
28+
with:
29+
path: ~/.bun/install/cache
30+
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
31+
restore-keys: bun-${{ runner.os }}-
32+
2233
- name: Install dependencies
2334
run: bun install --frozen-lockfile
2435

2536
- name: Run linting
2637
run: bun run lint
2738

2839
- name: Run tests
29-
run: bun test
40+
run: bun test --run
3041

3142
deploy:
3243
name: Deploy to Production
@@ -43,7 +54,7 @@ jobs:
4354
fetch-depth: 0
4455

4556
- name: Deploy to VPS via SSH
46-
uses: appleboy/ssh-action@v1.0.0
57+
uses: appleboy/ssh-action@v1
4758
with:
4859
host: ${{ secrets.PRODUCTION_VPS_HOST }}
4960
username: ${{ secrets.PRODUCTION_VPS_USER }}
@@ -143,26 +154,24 @@ jobs:
143154
144155
- name: Health check
145156
run: |
146-
sleep 15
147-
curl -f https://luvora.love/api/health || exit 1
157+
for i in 1 2 3; do
158+
sleep 10
159+
if curl -sf --max-time 10 https://luvora.love/api/health; then
160+
echo "Health check passed"
161+
exit 0
162+
fi
163+
echo "Attempt $i failed, retrying..."
164+
done
165+
echo "Health check failed after 3 attempts"
166+
exit 1
148167
149168
- name: Notify Sentry of deployment
150-
if: success()
151-
uses: getsentry/action-release@v1
169+
if: success() && env.SENTRY_AUTH_TOKEN != ''
170+
uses: getsentry/action-release@v3
152171
env:
153172
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
154173
SENTRY_ORG: akash-hasendra
155174
SENTRY_PROJECT: luvora
156175
with:
157176
environment: production
158177
version: ${{ github.sha }}
159-
160-
- name: Deployment notification
161-
if: always()
162-
run: |
163-
if [ "${{ job.status }}" == "success" ]; then
164-
echo "Production deployment successful!"
165-
else
166-
echo "Production deployment failed!"
167-
exit 1
168-
fi

src/app/api/messaging/channels/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export async function GET(request: NextRequest) {
4545
const channels = (['telegram', 'whatsapp', 'discord'] as const).map(platform => {
4646
const config = channelConfigs.find(c => c.platform === platform);
4747
const isRunning = messagingService.isChannelRunning(userId, platform);
48-
const channel = messagingService.getChannel(userId, platform as any);
48+
const channel = messagingService.getChannel(userId, platform as 'telegram' | 'whatsapp' | 'discord');
4949

5050
return {
5151
platform,

src/lib/messaging/database-session-store.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
import PocketBase from 'pocketbase';
20-
import { brotliCompressSync, brotliDecompressSync, constants } from 'zlib';
20+
import { brotliCompressSync, brotliDecompressSync, gunzipSync, constants } from 'zlib';
2121
import fs from 'fs';
2222
import path from 'path';
2323

@@ -271,7 +271,6 @@ export class DatabaseSessionStore {
271271
// Fall back to gzip for legacy sessions
272272
// This allows gradual migration without breaking existing sessions
273273
console.warn('[DatabaseSessionStore] Brotli decompression failed, trying gzip fallback');
274-
const { gunzipSync } = require('zlib');
275274
return gunzipSync(data).toString('utf8');
276275
}
277276
}

src/lib/messaging/messaging-metrics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class MessagingMetrics {
133133
platforms: Record<MessagingPlatform, MetricsSummary>;
134134
} {
135135
const platforms: MessagingPlatform[] = ['telegram', 'whatsapp', 'discord'];
136-
const platformMetrics: Record<MessagingPlatform, MetricsSummary> = {} as any;
136+
const platformMetrics = {} as Record<MessagingPlatform, MetricsSummary>;
137137

138138
let totalSent = 0;
139139
let totalFailed = 0;

src/lib/messaging/session-archiver.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import fs from 'fs';
1515
import path from 'path';
16-
import { brotliCompressSync, brotliDecompressSync, constants } from 'zlib';
16+
import { brotliCompressSync, brotliDecompressSync, gunzipSync, constants } from 'zlib';
1717
import { execSync } from 'child_process';
1818

1919
export interface SessionArchive {
@@ -120,7 +120,6 @@ export class SessionArchiver {
120120
} catch (error) {
121121
// Fall back to gzip for legacy archives
122122
console.warn('[SessionArchiver] Brotli decompression failed, trying gzip fallback');
123-
const { gunzipSync } = require('zlib');
124123
tarball = gunzipSync(compressed);
125124
}
126125

0 commit comments

Comments
 (0)