|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + node-version: [20.x, 22.6] # Need to use 22.6 due to Next.js build errors: https://github.com/vercel/next.js/issues/69263 |
| 14 | + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ |
| 15 | + |
| 16 | + name: Build with ${{ matrix.node-version }} |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v3 |
| 21 | + - name: Use Node.js ${{ matrix.node-version }} |
| 22 | + uses: actions/setup-node@v3 |
| 23 | + with: |
| 24 | + node-version: ${{ matrix.node-version }} |
| 25 | + cache: npm |
| 26 | + - run: npm ci |
| 27 | + - run: npm run build |
| 28 | + |
| 29 | + test: |
| 30 | + strategy: |
| 31 | + matrix: |
| 32 | + node-version: [20.x] |
| 33 | + |
| 34 | + name: Run all tests |
| 35 | + runs-on: ubuntu-latest |
| 36 | + |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v3 |
| 39 | + with: |
| 40 | + fetch-depth: 0 # Retrieve Git history, needed to verify commits |
| 41 | + - name: Use Node.js ${{ matrix.node-version }} |
| 42 | + uses: actions/setup-node@v3 |
| 43 | + with: |
| 44 | + node-version: ${{ matrix.node-version }} |
| 45 | + cache: npm |
| 46 | + - run: npm ci |
| 47 | + |
| 48 | + - name: Build Next.js for E2E tests |
| 49 | + run: npm run build |
| 50 | + env: |
| 51 | + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} |
| 52 | + |
| 53 | + - if: github.event_name == 'pull_request' |
| 54 | + name: Validate all commits from PR |
| 55 | + run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose |
| 56 | + |
| 57 | + - name: Linter |
| 58 | + run: npm run lint |
| 59 | + |
| 60 | + - name: Type checking |
| 61 | + run: npm run check-types |
| 62 | + |
| 63 | + - name: Run unit tests |
| 64 | + run: npm run test -- --coverage |
| 65 | + |
| 66 | + - name: Upload coverage reports to Codecov |
| 67 | + uses: codecov/codecov-action@v4 |
| 68 | + env: |
| 69 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 70 | + |
| 71 | + - name: Install Playwright (used for Storybook and E2E tests) |
| 72 | + run: npx playwright install --with-deps |
| 73 | + |
| 74 | + - name: Run storybook tests |
| 75 | + run: npm run test-storybook:ci |
| 76 | + |
| 77 | + - name: Run E2E tests |
| 78 | + run: npx percy exec -- npm run test:e2e |
| 79 | + env: |
| 80 | + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} |
| 81 | + CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }} |
| 82 | + |
| 83 | + - uses: actions/upload-artifact@v4 |
| 84 | + if: always() |
| 85 | + with: |
| 86 | + name: test-results |
| 87 | + path: test-results/ |
| 88 | + retention-days: 7 |
| 89 | + |
| 90 | + synchronize-with-crowdin: |
| 91 | + name: GitHub PR synchronize with Crowdin |
| 92 | + runs-on: ubuntu-latest |
| 93 | + |
| 94 | + needs: [build, test] |
| 95 | + if: github.event_name == 'pull_request' |
| 96 | + |
| 97 | + steps: |
| 98 | + - uses: actions/checkout@v4 |
| 99 | + with: |
| 100 | + ref: ${{ github.event.pull_request.head.sha }} # Crowdin Actions needs to push commits to the PR branch, checkout HEAD commit instead of merge commit |
| 101 | + fetch-depth: 0 |
| 102 | + |
| 103 | + - name: crowdin action |
| 104 | + uses: crowdin/github-action@v2 |
| 105 | + with: |
| 106 | + upload_sources: true |
| 107 | + upload_translations: true |
| 108 | + download_translations: true |
| 109 | + create_pull_request: false |
| 110 | + localization_branch_name: ${{ github.head_ref || github.ref_name }} # explanation here: https://stackoverflow.com/a/71158878 |
| 111 | + commit_message: 'chore: new Crowdin translations by GitHub Action' |
| 112 | + env: |
| 113 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 114 | + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} |
| 115 | + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} |
0 commit comments