Skip to content

Chore: CI restoration, linting, and code hygiene improvements - #68

Merged
Mahakisore7 merged 6 commits into
mainfrom
chore/ci-lint-and-hygiene
Sep 29, 2026
Merged

Mahakisore7 merged 6 commits into
mainfrom
chore/ci-lint-and-hygiene

Conversation

@Mahakisore7

Copy link
Copy Markdown
Member

Restore CI with a dedicated test database and document local testing. Clean up linting issues and type-check findings across the codebase. Update React components to adhere to best practices and improve overall code hygiene. Ensure migrations and tests are properly aligned with the database schema.

Mahakisore7 and others added 6 commits September 29, 2026 20:56
The suite used DATABASE_URL, i.e. whatever the app used — the real
Supabase project — and one prefix (LimitDish-) was missing from the
cleanup list, so test dishes could be left in the live catalogue.

- conftest reads TEST_DATABASE_URL and refuses any Supabase host.
- scripts/test-db.ps1 starts pgvector/pgvector:pg16 on :55432, applies a
  minimal Supabase shim (auth.users, anon/authenticated with Supabase's
  default grants) and migrates to head. All 18 migrations now build a
  database from scratch and downgrade/upgrade cleanly.
- Fixed tests that relied on the live catalogue or created dishes without
  the now-required diet_type. Full suite: 396 passed on a fresh database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dish_feedback existed only as a hand-run SQL script while the Plate and
Menu pages already used it, so any database built by alembic lacked it and
the feedback endpoints failed. Migration 019 creates it idempotently with
RLS (read totals when signed in, write only your own vote) and validates
meal_type; reading totals now requires sign-in like every other endpoint.

The suite used to connect as a superuser, which bypasses RLS, so no policy
was ever tested. The test database now has messfit_app/messfit_worker
logins and the app side runs as messfit_app, as in production. New
isolation tests prove cross-user reads/writes and self-promotion to admin
are refused; they fail if RLS is switched off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ruff: stray mid-file imports moved to the top, unused imports removed;
  per-file ignores only for seed scripts (sys.path setup) and alembic env.
- alembic env.py now imports the analytics models, so autogenerate sees
  every table.
- mypy: Sequence for the regression helper, typed validator return,
  pywebpush has no stubs, CursorResult.rowcount.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…actions

The React Compiler lint rules flagged state copied into effects, clock reads
during render and a ref written during render. Rewritten to the documented
patterns: useSyncExternalStore for online status, the analytics opt-out
(now also live across tabs) and the current meal slot; state adjusted
during render for prop changes; derived state for the OCR review copy and
the More sheet; the rest timer's deadline set when it starts. useFlash could
leave 'Saved' on screen forever if the flag cleared within 2s; fixed.
Two justified exceptions (localStorage restore, click-handler Date.now).

New e2e: rest timer countdown/extend/skip/self-close, weight prefill and the
Saved confirmation, the mobile More sheet. 95 e2e pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- eslint.config.mjs (Next 16 flat config: core-web-vitals + typescript);
  ESLint pinned to 9.x because eslint-plugin-react doesn't support 10.
  pnpm exec eslint . is clean.
- Removed deprecated/unused @supabase/auth-helpers-nextjs, tw-animate-css
  and @types/uuid (uuid ships types); shadcn is a dev tool, not a runtime
  dependency. Production audit: 81 -> 43 advisories, none critical.
- Removed the stray npm package-lock.json (the repo uses pnpm).
- Every production build rewrote the committed public/sw.js. The
  hand-written dev worker is now public/sw-dev.js (registered by next dev);
  the generated sw.js is ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI was removed in June because it ran against infrastructure that didn't
exist. It now brings its own: a pgvector Postgres service plus the Supabase
shim, and runs as the RLS-restricted app role.

API job: ruff, mypy, migrations from scratch and down/up, pytest, the
50-scenario optimizer eval, pip-audit. Web job: tsc, eslint, webpack build,
pnpm audit (fails on critical), Playwright. Every step was run locally
first, including the API suite with no .env and dummy secrets only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Mahakisore7
Mahakisore7 merged commit e366d1d into main Sep 29, 2026
0 of 3 checks passed
@gitguardian

gitguardian Bot commented Sep 29, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
27250866 Triggered Generic Password a44046e .github/workflows/ci.yml View secret
27250866 Triggered Generic Password 0f4ea1c services/api/scripts/test-db.ps1 View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant