Fix CI: Use local wrangler config for tests to avoid remote AI binding #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Fullstack Auto Test | |
| # Chạy khi có code được push vào nhánh master hoặc có Pull Request | |
| on: | |
| push: | |
| branches: ["master"] | |
| pull_request: | |
| branches: ["master"] | |
| jobs: | |
| # Job 1: Test phần Backend | |
| test-backend: | |
| name: Backend Test (Cloudflare Worker) | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./be-worker | |
| steps: | |
| - uses: actions/checkout@v4 # Update to v4 usually better | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 # Update to v4 | |
| with: | |
| node-version: "20" # Recommend LTS v20 | |
| cache: 'npm' | |
| cache-dependency-path: './be-worker/package-lock.json' | |
| - name: Install Backend Dependencies | |
| run: npm ci # Use ci for clean install | |
| - name: Run Backend Unit Tests | |
| run: npm test | |
| # Job 2: Test phần Frontend | |
| test-frontend: | |
| name: Frontend Test (React + Vitest) | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./fe-agent | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: 'npm' | |
| cache-dependency-path: './fe-agent/package-lock.json' | |
| - name: Install Frontend Dependencies | |
| run: npm ci | |
| - name: Run Frontend Unit Tests | |
| # Vitest tự động chạy 1 lần trong môi trường CI, không cần --watchAll=false | |
| # Tuy nhiên để chắc chắn, ta có thể dùng `npm test -- --run` | |
| run: npm test -- --run |