New tempii #92
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: CI Pipeline (Lint + Build + Test + Validate) | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| lint_and_test: | |
| name: Lint & Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js 20 | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Install ESLint | |
| run: npm install --save-dev eslint@8 | |
| - name: Run ESLint | |
| run: npx eslint src --ext .js,.jsx --max-warnings=0 | |
| - name: Run Jest tests | |
| run: npm run test:ci | |
| - name: Upload test coverage | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage/ | |
| retention-days: 7 | |
| build_and_validate: | |
| name: Build & Validate | |
| runs-on: ubuntu-latest | |
| needs: lint_and_test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js 20 | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Install serve | |
| run: npm install -g serve | |
| - name: Build project | |
| run: | | |
| npm run build | |
| ls -la build | |
| - name: Set Public Url | |
| run: echo "PUBLIC_URL=." >> $GITHUB_ENV | |
| - name: Start Server and Log Output | |
| run: | | |
| npx serve -s build -l 8080 > server.log 2>&1 & | |
| - name: Wait for server | |
| run: npx wait-on http://localhost:8080 | |
| - name: Display Server Logs | |
| run: cat server.log | |
| - name: Verify server running | |
| run: | | |
| for i in {1..3}; do | |
| echo "Attempt $i to check server status..." | |
| if curl -s http://localhost:8080 | grep -q "<html>"; then | |
| echo "Server is up!" | |
| break | |
| else | |
| echo "Server not ready yet... retrying in 5 seconds" | |
| sleep 5 | |
| fi | |
| done | |
| curl -I http://localhost:8080 || (echo "Server is not running after 3 attempts" && exit 1) | |
| - name: Check service worker | |
| run: | | |
| grep -i "serviceWorker" build/index.html || echo "❌ No service worker registered" | |
| ls build/service-worker.js || echo "❌ service-worker.js not found" | |
| - name: Debug Build Output | |
| run: | | |
| echo "🔍 manifest.json:" | |
| cat build/manifest.json || echo "❌ missing" | |
| echo "🔍 index.html link to manifest:" | |
| grep -i "manifest" build/index.html || echo "❌ not linked" | |
| echo "🔍 apple-touch-icon:" | |
| grep -i "apple-touch-icon" build/index.html || echo "❌ not linked" | |
| echo "🔍 icons folder:" | |
| ls -lh build/icons || echo "❌ missing" | |
| # | |
| # - name: Run Lighthouse audit | |
| # uses: treosh/lighthouse-ci-action@v9 | |
| # with: | |
| # configPath: './.lighthouserc.json' | |
| # temporaryPublicStorage: false | |
| # - name: Check bundle size | |
| # run: | | |
| # npm install -g size-limit | |
| # size-limit | |
| - name: Package Extension | |
| run: npm run package | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: production-artifacts | |
| path: | | |
| build/ | |
| dist/ | |
| retention-days: 7 |