Browse Source

ci(04-01): extend workflow for frontend tests

- Add frontend-test job for Vitest tests
- Add frontend-e2e job for Playwright tests
- Update paths trigger to include frontend files
- Configure Node.js 20 with npm caching
- Install Playwright browsers in CI
- Upload Playwright report on failure
tuanchris 1 tuần trước cách đây
mục cha
commit
92071351ea
1 tập tin đã thay đổi với 71 bổ sung0 xóa
  1. 71 0
      .github/workflows/test.yml

+ 71 - 0
.github/workflows/test.yml

@@ -8,6 +8,7 @@ on:
       - 'requirements*.txt'
       - 'pyproject.toml'
       - 'tests/**'
+      - 'frontend/**'
       - '.github/workflows/test.yml'
   pull_request:
     branches: [ "main" ]
@@ -16,11 +17,13 @@ on:
       - 'requirements*.txt'
       - 'pyproject.toml'
       - 'tests/**'
+      - 'frontend/**'
       - '.github/workflows/test.yml'
   # Allow manual trigger
   workflow_dispatch:
 
 jobs:
+  # Backend tests
   test:
     runs-on: ubuntu-latest
 
@@ -78,3 +81,71 @@ jobs:
         run: |
           ruff check --output-format=github .
         continue-on-error: true
+
+  # Frontend unit/integration tests
+  frontend-test:
+    runs-on: ubuntu-latest
+
+    defaults:
+      run:
+        working-directory: frontend
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v4
+
+      - name: Set up Node.js
+        uses: actions/setup-node@v4
+        with:
+          node-version: '20'
+          cache: 'npm'
+          cache-dependency-path: frontend/package-lock.json
+
+      - name: Install dependencies
+        run: npm ci
+
+      - name: Run Vitest tests
+        run: npm test
+
+      - name: Run Vitest with coverage
+        run: npm run test:coverage
+        continue-on-error: true
+
+  # Frontend E2E tests
+  frontend-e2e:
+    runs-on: ubuntu-latest
+    timeout-minutes: 10
+
+    defaults:
+      run:
+        working-directory: frontend
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v4
+
+      - name: Set up Node.js
+        uses: actions/setup-node@v4
+        with:
+          node-version: '20'
+          cache: 'npm'
+          cache-dependency-path: frontend/package-lock.json
+
+      - name: Install dependencies
+        run: npm ci
+
+      - name: Install Playwright browsers
+        run: npx playwright install --with-deps chromium
+
+      - name: Run Playwright tests
+        run: npm run test:e2e
+        env:
+          CI: true
+
+      - name: Upload Playwright report
+        uses: actions/upload-artifact@v4
+        if: failure()
+        with:
+          name: playwright-report
+          path: frontend/playwright-report/
+          retention-days: 7