E2E Tests #356
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
| # | |
| # Vercel bot will build a preview environment for each pull request. | |
| # This workflow will run E2E tests against that preview environment. | |
| # E2E run is connected to sha | |
| # | |
| # Created August 16th, 2025 | |
| # @author: ywarezk | |
| # @license: MIT | |
| # | |
| name: E2E Tests | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| repository: | |
| description: "Repository to checkout (owner/name)" | |
| required: false | |
| ref: | |
| description: "Commit SHA or branch to test" | |
| required: true | |
| sha: | |
| description: "Optional commit SHA for creating a check run" | |
| required: false | |
| url: | |
| description: "Preview environment URL" | |
| required: true | |
| jobs: | |
| run-e2es: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/create-github-app-token@v3.0.0 | |
| id: app-token | |
| with: | |
| app-id: ${{ vars.ACADEMEEZ_APP_ID }} | |
| private-key: ${{ secrets.ACADEMEEZ_APP_PRIVATE_KEY }} | |
| - name: Checkout code | |
| uses: actions/checkout@v5.0.0 | |
| with: | |
| repository: ${{ inputs.repository || github.repository }} | |
| ref: ${{ inputs.ref }} | |
| fetch-depth: 1 | |
| - name: Resolve checkout SHA | |
| id: checkout-sha | |
| run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
| - name: E2E check | |
| uses: actions/github-script@v7.0.1 | |
| id: e2e-check | |
| with: | |
| github-token: ${{ steps.app-token.outputs.token }} | |
| script: | | |
| const headSha = `${{ inputs.sha }}` || `${{ steps.checkout-sha.outputs.sha }}` | |
| const response = await github.rest.checks.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| name: `E2E`, | |
| head_sha: headSha, | |
| status: 'in_progress', | |
| started_at: new Date().toISOString(), | |
| }); | |
| console.log('response is:', response.data); | |
| return response.data.id; | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v5.0.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6.3.0 | |
| with: | |
| node-version-file: '.nvmrc' # automatically reads Node version from .nvmrc | |
| cache: 'pnpm' # enables pnpm cache based on lock file | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Install Playwright browsers | |
| run: pnpm exec playwright install --with-deps | |
| - name: run tests | |
| env: | |
| BASE_URL: ${{ inputs.url }} # 👈 preview env URL | |
| run: | | |
| pnpm exec playwright test | |
| # Upload *all* artifacts (videos, screenshots, traces, html report) | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v7.0.0 | |
| with: | |
| name: playwright-test-results | |
| path: | | |
| test-results/ | |
| retention-days: 7 | |
| if-no-files-found: warn | |
| - name: Upload playwright report | |
| if: always() | |
| uses: actions/upload-artifact@v7.0.0 | |
| with: | |
| name: playwright-report | |
| path: | | |
| playwright-report/ | |
| retention-days: 7 | |
| if-no-files-found: warn | |
| - name: Get latest commit on main | |
| id: main-commit | |
| run: | | |
| git fetch origin main | |
| echo "sha=$(git rev-parse origin/main)" >> "$GITHUB_OUTPUT" | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v6 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| override_branch: main | |
| override_commit: ${{ steps.main-commit.outputs.sha }} | |
| flags: e2e-preview | |
| name: E2E Coverage from Preview | |
| verbose: true | |
| fail_ci_if_error: false | |
| - name: Set e2e check to success | |
| if: ${{ success() && steps.e2e-check.outputs.result != '' }} | |
| uses: actions/github-script@v8.0.0 | |
| with: | |
| github-token: ${{ steps.app-token.outputs.token }} | |
| script: | | |
| github.rest.checks.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| check_run_id: ${{ steps.e2e-check.outputs.result }}, | |
| conclusion: 'success', | |
| status: 'completed', | |
| }); | |
| - name: Update deploy check on fail | |
| if: (failure() || cancelled()) && steps.e2e-check.outputs.result != '' | |
| uses: actions/github-script@v8.0.0 | |
| with: | |
| github-token: ${{ steps.app-token.outputs.token }} | |
| script: | | |
| github.rest.checks.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| check_run_id: ${{ steps.e2e-check.outputs.result }}, | |
| conclusion: 'failure', | |
| status: 'completed', | |
| }); |