diff --git a/.github/workflows/server-health-check.yml b/.github/workflows/server-health-check.yml new file mode 100644 index 0000000..5526b0e --- /dev/null +++ b/.github/workflows/server-health-check.yml @@ -0,0 +1,84 @@ +name: Server Health Check + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test-servers: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + # ------------------------- + # Backend DB Setup + # ------------------------- + - name: Create backend db directory + run: cmd /c "mkdir backend\db" + + - name: Create backend database file + run: cmd /c "type nul > backend\db\progress-dashboard.db" + + # ------------------------- + # Install wait-on + # ------------------------- + - name: Install wait-on + run: npm install -g wait-on + + # ------------------------- + # Install Dependencies + # ------------------------- + - name: Install backend dependencies + run: npm ci + working-directory: backend + + - name: Install frontend dependencies + run: npm ci + working-directory: frontend + + # ------------------------- + # Build + # ------------------------- + - name: Build backend (TypeScript) + run: npx tsc + working-directory: backend + + - name: Build frontend (Vite) + run: npm run build + working-directory: frontend + + # ------------------------- + # Start Backend + # ------------------------- + - name: Start backend + run: | + cd backend + start /B node dist/index.js + shell: cmd + + - name: Wait for backend + run: wait-on http://localhost:4000 + + # ------------------------- + # Start Frontend (Vite Preview) + # ------------------------- + - name: Start frontend + run: | + cd frontend + start /B npm run preview + shell: cmd + + - name: Wait for frontend + run: wait-on http://localhost:5173 + + # ------------------------- + # ✅ Basic Health Check Tests + # ------------------------- + - name: Test backend API + run: curl http://localhost:4000 + + - name: Test frontend + run: curl http://localhost:5173