From ec1a7fc2e9fd095585d194a08813ed5465676e06 Mon Sep 17 00:00:00 2001 From: Torben Sorensen Date: Tue, 2 Dec 2025 19:09:33 -0800 Subject: [PATCH] move to centralized secret --- .env.test | 37 ------------------------------------- .gitea/workflows/deploy.yml | 16 +--------------- .gitignore | 1 + package.json | 8 ++++---- 4 files changed, 6 insertions(+), 56 deletions(-) delete mode 100644 .env.test diff --git a/.env.test b/.env.test deleted file mode 100644 index 32de49ad..00000000 --- a/.env.test +++ /dev/null @@ -1,37 +0,0 @@ -# .env.test -# Environment variables for the test environment. -# This file is loaded by `tsx` when running the `npm run test:integration` command. - -# --- Test Database Connection --- -# IMPORTANT: These should point to your *test* database, not production. -# These values will be used by the backend server when it starts for integration tests. -DB_HOST=localhost -DB_PORT=5432 -DB_USER=flyer_crawler_user -DB_PASSWORD=WoA2kFtqqHdTLqdZsoCa -DB_DATABASE=flyer-crawler-test -DB_NAME=flyer-crawler-test - -# --- Test JWT Secret --- -JWT_SECRET=a-secure-secret-for-testing-only - -# --- Other Test Variables --- -# These can be dummy values if the feature is not being tested directly. -FRONTEND_URL=http://localhost:3000 -GEMINI_API_KEY=dummy-api-key-for-testing - -# --- Worker Configuration --- -WORKER_CONCURRENCY=5 - -# --- Redis Connection URL --- -REDIS_URL=redis://127.0.0.1:6379 -REDIS_PASSWORD=TLLRXw6XadGo2hhGJkHo - -# --- Email (SMTP) Configuration for Nodemailer --- -# For testing, these can be dummy values or point to a local test server like MailHog. -SMTP_HOST=localhost -SMTP_PORT=1025 -SMTP_SECURE=false -SMTP_USER= -SMTP_PASS= -SMTP_FROM_EMAIL=noreply@flyer-crawler.projectium.com \ No newline at end of file diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 636ea802..5773ca41 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -79,23 +79,9 @@ jobs: # coverage data into a single report. It combines the environment variables # needed for both test suites. env: - # --- Database credentials for both test suites --- - DB_HOST: ${{ secrets.DB_HOST }} - DB_PORT: ${{ secrets.DB_PORT }} - DB_USER: ${{ secrets.DB_USER }} - DB_PASSWORD: ${{ secrets.DB_PASSWORD }} - DB_DATABASE: "flyer-crawler-test" - DB_NAME: "flyer-crawler-test" - # --- Integration test specific variables --- - JWT_SECRET: "test-secret-for-ci" - GOOGLE_CLIENT_ID: "dummy_client_id" - GOOGLE_CLIENT_SECRET: "dummy_client_secret" - GITHUB_CLIENT_ID: "dummy_github_id" - GITHUB_CLIENT_SECRET: "dummy_github_secret" FRONTEND_URL: "http://localhost:3000" VITE_API_BASE_URL: "http://localhost:3001/api" - GEMINI_API_KEY: ${{ secrets.VITE_GOOGLE_GENAI_API_KEY }} # --- Increase Node.js memory limit to prevent heap out of memory errors --- # This is crucial for memory-intensive tasks like running tests and coverage. @@ -261,7 +247,7 @@ jobs: # 1. Copy the backend source code and project files first. # CRITICAL: We exclude '.env', 'node_modules', '.git', 'dist', and now 'flyer-images' to protect user content. - rsync -avz --delete --exclude '.env' --exclude 'node_modules' --exclude '.git' --exclude 'dist' --exclude 'flyer-images' ./ "$APP_PATH/" + rsync -avz --delete --exclude '.env' --exclude '.env.test' --exclude 'node_modules' --exclude '.git' --exclude 'dist' --exclude 'flyer-images' ./ "$APP_PATH/" # 2. Copy the built frontend assets into the same directory. # This will correctly place index.html and the assets/ folder in the webroot. diff --git a/.gitignore b/.gitignore index 4e4f9053..3912cc15 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ dist-ssr # secrets .env .env.local +.env.test \ No newline at end of file diff --git a/package.json b/package.json index 12934110..4f0a4612 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,10 @@ "start": "npm run start:prod", "build": "vite build", "preview": "vite preview", - "test": "node --max-old-space-size=8192 ./node_modules/vitest/vitest.mjs run", - "test:coverage": "npm run clean; npm run test:unit -- --coverage --reporter=verbose --reporter=tree --includeTaskLocation --testTimeout=20000; npm run test:integration -- --coverage --reporter=verbose --reporter=tree --includeTaskLocation --testTimeout=20000", - "test:unit": "node --max-old-space-size=8192 ./node_modules/vitest/vitest.mjs run --project unit -c vite.config.ts", - "test:integration": "node --max-old-space-size=8192 ./node_modules/vitest/vitest.mjs run --project integration -c vitest.config.integration.ts", + "test": "NODE_ENV=test tsx -r ./preload.ts ./node_modules/vitest/vitest.mjs run", + "test:coverage": "npm run clean && npm run test:unit -- --coverage && npm run test:integration -- --coverage", + "test:unit": "NODE_ENV=test tsx -r ./preload.ts ./node_modules/vitest/vitest.mjs run --project unit -c vite.config.ts", + "test:integration": "NODE_ENV=test tsx -r ./preload.ts ./node_modules/vitest/vitest.mjs run --project integration -c vitest.config.integration.ts", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "clean": "rimraf coverage .coverage", "start:dev": "NODE_ENV=development tsx -r ./preload.ts server.ts",