fix: make husky prepare script fail-safe for production deployment #3
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 | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| jobs: | |
| quality-check: | |
| name: Code Quality Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Check code formatting | |
| run: npm run format:check | |
| - name: Run ESLint | |
| run: npm run lint:check | |
| - name: Type check | |
| run: npm run type-check | |
| test: | |
| name: Run Tests | |
| runs-on: ubuntu-latest | |
| needs: quality-check | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run unit tests | |
| run: npm run test:coverage | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage/lcov.info | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| build: | |
| name: Build Application | |
| runs-on: ubuntu-latest | |
| needs: [quality-check, test] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build application | |
| run: npm run build | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-files | |
| path: .next/ | |
| retention-days: 7 | |
| e2e-tests: | |
| name: E2E Tests | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-files | |
| path: .next/ | |
| - name: Start application | |
| run: npm start & | |
| - name: Wait for application to start | |
| run: | | |
| timeout 30 bash -c 'until curl -f http://localhost:3000; do sleep 1; done' | |
| - name: Run Cypress tests | |
| uses: cypress-io/github-action@v6 | |
| with: | |
| start: npm start | |
| wait-on: 'http://localhost:3000' | |
| browser: chrome | |
| record: false | |
| - name: Upload Cypress screenshots | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: cypress-screenshots | |
| path: cypress/screenshots/ | |
| retention-days: 7 | |
| - name: Upload Cypress videos | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: cypress-videos | |
| path: cypress/videos/ | |
| retention-days: 7 | |