|
| 1 | +# Run Tauri E2E tests when someone comments /e2e-tauri on a PR. |
| 2 | +# Usage: Add a comment "/e2e-tauri" on any PR to trigger desktop E2E tests. |
| 3 | + |
| 4 | +name: E2E Tauri (Comment Trigger) |
| 5 | + |
| 6 | +on: |
| 7 | + issue_comment: |
| 8 | + types: [created] |
| 9 | + |
| 10 | +jobs: |
| 11 | + e2e-tauri: |
| 12 | + # Only run when comment on a PR contains /e2e-tauri |
| 13 | + if: | |
| 14 | + github.event.issue.pull_request != null && |
| 15 | + contains(github.event.comment.body, '/e2e-tauri') |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - os: ubuntu-latest |
| 21 | + - os: windows-latest |
| 22 | + |
| 23 | + runs-on: ${{ matrix.os }} |
| 24 | + permissions: |
| 25 | + contents: read |
| 26 | + pull-requests: read |
| 27 | + steps: |
| 28 | + - name: Get PR head ref |
| 29 | + id: pr |
| 30 | + uses: actions/github-script@v7 |
| 31 | + with: |
| 32 | + script: | |
| 33 | + const pr = await github.rest.pulls.get({ |
| 34 | + owner: context.repo.owner, |
| 35 | + repo: context.repo.repo, |
| 36 | + pull_number: context.issue.number, |
| 37 | + }); |
| 38 | + core.setOutput('ref', pr.data.head.ref); |
| 39 | + core.setOutput('sha', pr.data.head.sha); |
| 40 | + core.setOutput('pr_number', context.issue.number); |
| 41 | +
|
| 42 | + - uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + ref: ${{ steps.pr.outputs.sha }} |
| 45 | + |
| 46 | + - uses: dtolnay/rust-toolchain@stable |
| 47 | + - uses: Swatinem/rust-cache@v2 |
| 48 | + with: |
| 49 | + key: ${{ matrix.os }}-e2e-comment |
| 50 | + |
| 51 | + - uses: pnpm/action-setup@v4 |
| 52 | + - uses: actions/setup-node@v4 |
| 53 | + with: |
| 54 | + node-version: 20 |
| 55 | + cache: 'pnpm' |
| 56 | + |
| 57 | + - name: Install Linux deps |
| 58 | + if: matrix.os == 'ubuntu-latest' |
| 59 | + run: | |
| 60 | + sudo apt-get update |
| 61 | + sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libsecret-1-dev webkit2gtk-driver xvfb |
| 62 | +
|
| 63 | + - name: Cache tauri-driver |
| 64 | + uses: actions/cache@v4 |
| 65 | + id: tauri-driver-cache |
| 66 | + with: |
| 67 | + path: ~/.cargo/bin/tauri-driver* |
| 68 | + key: tauri-driver-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }} |
| 69 | + |
| 70 | + - name: Install tauri-driver |
| 71 | + if: steps.tauri-driver-cache.outputs.cache-hit != 'true' |
| 72 | + run: cargo install tauri-driver --locked |
| 73 | + |
| 74 | + - run: pnpm install --frozen-lockfile |
| 75 | + |
| 76 | + - name: Build app |
| 77 | + run: pnpm build |
| 78 | + env: |
| 79 | + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} |
| 80 | + |
| 81 | + - name: Run Tauri E2E tests (Linux) |
| 82 | + if: matrix.os == 'ubuntu-latest' |
| 83 | + run: xvfb-run --auto-servernum pnpm test:e2e |
| 84 | + |
| 85 | + - name: Run Tauri E2E tests (Windows) |
| 86 | + if: matrix.os == 'windows-latest' |
| 87 | + run: pnpm test:e2e |
0 commit comments