diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 51d9db3e..d32e0301 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -47,20 +47,28 @@ jobs: - name: Install Dependencies run: npm ci # 'ci' is faster and safer for CI/CD than 'install'. +# ----------------------------------------------------------------------- + # UPDATED STEP: Fixes server startup and test file naming # ----------------------------------------------------------------------- - # ADD THIS NEW STEP HERE - # ----------------------------------------------------------------------- - - name: Fix Package Scripts for CI + - name: Fix Package Scripts and Install TSX run: | - npm pkg set scripts.test:integration="vitest run -c vitest.config.integration.ts" - npm pkg set scripts.start:server="ts-node --esm server.ts" + # 1. Install tsx to handle running the server (it handles ESM automatically) + npm install -D tsx + + # 2. Update the server start script to use tsx + npm pkg set scripts.start:server="tsx server.ts" - # Also ensure test files are moved if they haven't been committed yet - # This prevents the 'Run Unit Tests' step from crashing on integration files + # 3. Ensure the integration test command uses the correct config + npm pkg set scripts.test:integration="vitest run -c vitest.config.integration.ts" + + # 4. SAFETY NET: Rename test files if they haven't been renamed in Git yet. + # This ensures Vitest finds them regardless of your local git state. if [ -f src/services/db.test.ts ]; then + echo "Renaming db.test.ts to db.integration.test.ts" mv src/services/db.test.ts src/services/db.integration.test.ts fi if [ -f src/services/shopping-list.test.ts ]; then + echo "Renaming shopping-list.test.ts to shopping-list.integration.test.ts" mv src/services/shopping-list.test.ts src/services/shopping-list.integration.test.ts fi # -----------------------------------------------------------------------