Fix/fixes wf #8
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: perf | |
| on: | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - 'web/**' | |
| - '.github/workflows/perf.yml' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| lighthouse: | |
| name: Lighthouse CI | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: web | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: web/package-lock.json | |
| - name: Install | |
| run: npm ci --legacy-peer-deps | |
| - name: Build | |
| run: npm run build | |
| - name: Bundle-size budget (strict) | |
| run: npm run perf:check | |
| - name: Start preview server | |
| run: | | |
| npx vite preview --port 4173 --strictPort > preview.log 2>&1 & | |
| echo $! > preview.pid | |
| # Wait for server to be reachable | |
| for i in $(seq 1 30); do | |
| if curl -fsS http://localhost:4173/ -o /dev/null; then | |
| echo "preview server is up" | |
| exit 0 | |
| fi | |
| sleep 1 | |
| done | |
| echo "preview server failed to start" | |
| cat preview.log | |
| exit 1 | |
| - name: Lighthouse CI | |
| uses: treosh/lighthouse-ci-action@v12 | |
| with: | |
| urls: | | |
| http://localhost:4173/ | |
| http://localhost:4173/vehicles | |
| http://localhost:4173/drives | |
| http://localhost:4173/analytics | |
| http://localhost:4173/charging | |
| uploadArtifacts: true | |
| temporaryPublicStorage: true | |
| configPath: ./web/lighthouserc.json | |
| runs: 1 | |
| - name: Stop preview server | |
| if: always() | |
| run: | | |
| if [ -f preview.pid ]; then | |
| kill "$(cat preview.pid)" 2>/dev/null || true | |
| fi |