From b9171f01358fd39cc18c62c186f8b4a55e0b5245 Mon Sep 17 00:00:00 2001 From: Harxhit Date: Sun, 24 May 2026 17:07:11 +0530 Subject: [PATCH 1/2] fix: Fixed linting issues --- apps/backend/src/app.ts | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/apps/backend/src/app.ts b/apps/backend/src/app.ts index 6a937a88..f817eb46 100644 --- a/apps/backend/src/app.ts +++ b/apps/backend/src/app.ts @@ -1,30 +1,31 @@ -import Fastify from 'fastify'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +import cookie from '@fastify/cookie'; import cors from '@fastify/cors'; import helmet from '@fastify/helmet'; import jwt from '@fastify/jwt'; -import cookie from '@fastify/cookie'; import multipart from '@fastify/multipart'; -import fastifyStatic from '@fastify/static'; import rateLimit from '@fastify/rate-limit'; -import path from 'path'; -import { fileURLToPath } from 'url'; +import fastifyStatic from '@fastify/static'; +import Fastify, {type FastifyInstance} from 'fastify'; import { prismaPlugin } from './plugins/prisma.js'; import { redisPlugin } from './plugins/redis.js'; +import { analyticsRoutes } from './routes/analytics.js'; import { authRoutes } from './routes/auth.js'; -import { profileRoutes } from './routes/profiles.js'; import { cardRoutes } from './routes/cards.js'; -import { publicRoutes } from './routes/public.js'; -import { followRoutes } from './routes/follow.js'; import { connectRoutes } from './routes/connect.js'; -import { analyticsRoutes } from './routes/analytics.js'; -import { nfcRoutes } from './routes/nfc.js'; import { eventRoutes } from './routes/event.js'; +import { followRoutes } from './routes/follow.js'; +import { nfcRoutes } from './routes/nfc.js'; +import { profileRoutes } from './routes/profiles.js'; +import { publicRoutes } from './routes/public.js'; import { validateEnv } from './utils/validateEnv.js'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); -export async function buildApp() { +export async function buildApp():Promise { // Validate all required secrets before registering any plugin. // If validation fails the process exits here — no partially-initialised // auth state can exist because Fastify is not yet instantiated. @@ -93,7 +94,7 @@ export async function buildApp() { app.decorate('authenticate', async function (request: any, reply: any) { try { await request.jwtVerify(); - } catch (err) { + } catch (_err) { reply.status(401).send({ error: 'Unauthorized' }); } }); From 37b768469fbdd24bfaa00c7a38a3c4009acde06c Mon Sep 17 00:00:00 2001 From: Harxhit Date: Tue, 2 Jun 2026 01:37:36 +0530 Subject: [PATCH 2/2] fix(ci): improve workflow reporting and add collaborator support --- .github/scripts/ciScript.js | 78 ++++++++++++++++----------- .github/scripts/discordPinReminder.js | 5 +- .github/scripts/unassignIssues.js | 3 +- .github/workflows/ci.yml | 47 +++++++++++++++- 4 files changed, 98 insertions(+), 35 deletions(-) diff --git a/.github/scripts/ciScript.js b/.github/scripts/ciScript.js index 810a91fb..f054146b 100644 --- a/.github/scripts/ciScript.js +++ b/.github/scripts/ciScript.js @@ -6,6 +6,7 @@ module.exports = async ({ github, context, core }) => { const prState = pr.state; const backendFiles = []; + const backendTests = []; const mobileFiles = []; const webFiles = []; @@ -33,6 +34,17 @@ module.exports = async ({ github, context, core }) => { if (fileName.startsWith('apps/backend/')) { backendFiles.push(fileName); + + const relative = fileName.replace('apps/backend/src/', ''); + const baseName = relative + .split('/') + .pop() + ?.replace(/\.(ts|tsx|js|jsx)$/, ''); + + if (baseName) { + backendTests.push(`src/__tests__/${baseName}.test.ts`); + } + } else if (fileName.startsWith('apps/mobile/')) { mobileFiles.push(fileName); } else if (fileName.startsWith('apps/web/')) { @@ -40,36 +52,42 @@ module.exports = async ({ github, context, core }) => { } }); - console.log({ - backendFiles, - mobileFiles, - webFiles - }); - - core.setOutput( - "backendFiles", - backendFiles - .map(file => file.replace("apps/backend/", "")) - .join(" ") - ) - - core.setOutput( - "mobileFiles", - mobileFiles - .map(file => file.replace("apps/mobile/", "")) - .join(" ") - ) - - core.setOutput( - "webFiles", - webFiles - .map(file => file.replace("apps/web/", "")) - .join(" ") - ) - - core.setOutput("backendChanged", backendFiles.length > 0) - core.setOutput("mobileChanged", mobileFiles.length > 0) - core.setOutput("webChanged", webFiles.length > 0) + console.log({ + backendFiles, + backendTests, + mobileFiles, + webFiles + }); + + core.setOutput( + "backendFiles", + backendFiles + .map(file => file.replace("apps/backend/", "")) + .join(" ") + ); + + core.setOutput( + "backendTests", + [...new Set(backendTests)].join(" ") + ); + + core.setOutput( + "mobileFiles", + mobileFiles + .map(file => file.replace("apps/mobile/", "")) + .join(" ") + ); + + core.setOutput( + "webFiles", + webFiles + .map(file => file.replace("apps/web/", "")) + .join(" ") + ); + + core.setOutput("backendChanged", backendFiles.length > 0); + core.setOutput("mobileChanged", mobileFiles.length > 0); + core.setOutput("webChanged", webFiles.length > 0); } catch (error) { console.error(error); diff --git a/.github/scripts/discordPinReminder.js b/.github/scripts/discordPinReminder.js index 5e4df420..d5724578 100644 --- a/.github/scripts/discordPinReminder.js +++ b/.github/scripts/discordPinReminder.js @@ -2,11 +2,12 @@ module.exports = async ({ github, context }) => { const pr = context.payload.pull_request; const ignoreUsers = [ 'ShantKhatri', - 'Harxhit' + 'Harxhit', + 'blankirigaya' ] try { // Only continue if merged - if (!pr || !pr.merged) { + if (!pr || !pr.merged) { console.log('PR not merged.'); return; } diff --git a/.github/scripts/unassignIssues.js b/.github/scripts/unassignIssues.js index 017d641c..b4886e91 100644 --- a/.github/scripts/unassignIssues.js +++ b/.github/scripts/unassignIssues.js @@ -4,7 +4,8 @@ module.exports = async ({ github, context }) => { const PROTECTED_ASSIGNEES = [ 'ShantKhatri', - 'Harxhit' + 'Harxhit', + 'blankirigaya' ]; // Fetch all open issues (excluding PRs) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25f71019..e3c4e311 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,11 @@ jobs: if: needs.detect-changes.outputs.backendChanged == 'true' runs-on: ubuntu-latest + outputs: + backend_lint: ${{ steps.backend_lint.outcome }} + backend_test: ${{ steps.backend_test.outcome }} + backend_typecheck: ${{ steps.backend_typecheck.outcome }} + steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd @@ -49,21 +54,32 @@ jobs: - name: Backend lint id: backend_lint + continue-on-error: true run: cd apps/backend && pnpm eslint ${{ needs.detect-changes.outputs.backendFiles }} - name: Backend test id: backend_test + continue-on-error: true run: cd apps/backend && pnpm test ${{ needs.detect-changes.outputs.backendFiles }} - name: Backend typecheck id: backend_typecheck + continue-on-error: true run: cd apps/backend && pnpm typecheck ${{ needs.detect-changes.outputs.backendFiles }} + - name: Fail backend if checks failed + if: steps.backend_lint.outcome == 'failure' || steps.backend_test.outcome == 'failure' || steps.backend_typecheck.outcome == 'failure' + run: exit 1 + web-ci: needs: detect-changes if: needs.detect-changes.outputs.webChanged == 'true' runs-on: ubuntu-latest + outputs: + web_check: ${{ steps.web_check.outcome }} + web_build: ${{ steps.web_build.outcome }} + steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd @@ -77,17 +93,27 @@ jobs: - name: Web check id: web_check + continue-on-error: true run: cd apps/web && pnpm check - name: Web build id: web_build + continue-on-error: true run: cd apps/web && pnpm build + - name: Fail web if checks failed + if: steps.web_check.outcome == 'failure' || steps.web_build.outcome == 'failure' + run: exit 1 + mobile-ci: needs: detect-changes if: needs.detect-changes.outputs.mobileChanged == 'true' runs-on: ubuntu-latest + outputs: + mobile_lint: ${{ steps.mobile_lint.outcome }} + mobile_test: ${{ steps.mobile_test.outcome }} + steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd @@ -101,12 +127,18 @@ jobs: - name: Mobile lint id: mobile_lint + continue-on-error: true run: cd apps/mobile && pnpm eslint ${{ needs.detect-changes.outputs.mobileFiles }} - name: Mobile test id: mobile_test + continue-on-error: true run: cd apps/mobile && pnpm test + - name: Fail mobile if checks failed + if: steps.mobile_lint.outcome == 'failure' || steps.mobile_test.outcome == 'failure' + run: exit 1 + comment-results: needs: - backend-ci @@ -128,7 +160,18 @@ jobs: await script({ github, context, + backend: '${{ needs.backend-ci.result }}', web: '${{ needs.web-ci.result }}', - mobile: '${{ needs.mobile-ci.result }}' - }); \ No newline at end of file + mobile: '${{ needs.mobile-ci.result }}', + + backendLint: '${{ needs.backend-ci.outputs.backend_lint }}', + backendTest: '${{ needs.backend-ci.outputs.backend_test }}', + backendTypecheck: '${{ needs.backend-ci.outputs.backend_typecheck }}', + + mobileLint: '${{ needs.mobile-ci.outputs.mobile_lint }}', + mobileTest: '${{ needs.mobile-ci.outputs.mobile_test }}', + + webCheck: '${{ needs.web-ci.outputs.web_check }}', + webBuild: '${{ needs.web-ci.outputs.web_build }}' + }); \ No newline at end of file