ci: add GitHub Actions workflow and update docs for React stack #27
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: | |
| pull_request: | |
| jobs: | |
| build: | |
| name: Lint, typecheck, test and build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Typecheck | |
| run: npx tsc --noEmit | |
| - name: Lint | |
| run: npx eslint . | |
| - name: Unit tests | |
| run: npm test | |
| - name: Build | |
| run: npm run build | |
| e2e: | |
| name: Playwright end-to-end tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Check for Playwright config | |
| id: playwright_config | |
| run: | | |
| if [ -f playwright.config.ts ]; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Install dependencies | |
| if: steps.playwright_config.outputs.exists == 'true' | |
| run: npm ci | |
| - name: Install Playwright browsers | |
| if: steps.playwright_config.outputs.exists == 'true' | |
| run: npx playwright install --with-deps chromium | |
| - name: Run end-to-end tests | |
| if: steps.playwright_config.outputs.exists == 'true' | |
| continue-on-error: false | |
| run: npm run test:e2e | |
| - name: Check for Playwright report | |
| id: playwright_report | |
| if: always() && steps.playwright_config.outputs.exists == 'true' | |
| run: | | |
| if [ -d playwright-report ]; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Upload Playwright report | |
| if: always() && steps.playwright_report.outputs.exists == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: playwright-report | |
| retention-days: 7 |