feat: Add frontend testing infrastructure and refactor components #1
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: Frontend CI | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'frontend/**' | |
| - '.github/workflows/frontend-ci.yml' | |
| pull_request: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'frontend/**' | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [16.x, 18.x, 20.x] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install dependencies | |
| working-directory: ./frontend | |
| run: npm ci | |
| - name: Lint code | |
| working-directory: ./frontend | |
| run: | | |
| if npm run lint --if-present 2>/dev/null; then | |
| echo "Linting completed" | |
| else | |
| echo "No lint script found or linting completed with warnings" | |
| fi | |
| continue-on-error: true | |
| - name: Run tests | |
| working-directory: ./frontend | |
| run: npm test -- --coverage --watchAll=false | |
| env: | |
| CI: true | |
| continue-on-error: true | |
| - name: Build application | |
| working-directory: ./frontend | |
| run: npm run build | |
| env: | |
| CI: false | |
| - name: Check build size | |
| working-directory: ./frontend | |
| run: | | |
| echo "Build size:" | |
| du -sh build/ | |
| du -sh build/static/js/ | |
| du -sh build/static/css/ | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: frontend-build-${{ matrix.node-version }} | |
| path: frontend/build | |
| retention-days: 7 | |
| - name: Upload coverage reports | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./frontend/coverage/coverage-final.json | |
| flags: frontend | |
| name: frontend-coverage-${{ matrix.node-version }} | |
| continue-on-error: true | |
| dependency-audit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| - name: Run npm audit | |
| working-directory: ./frontend | |
| run: | | |
| npm audit --audit-level=moderate | |
| continue-on-error: true | |
| - name: Check for outdated packages | |
| working-directory: ./frontend | |
| run: | | |
| npm outdated || true | |
| continue-on-error: true |