Skip to content

Separate e2e snapshots and enable parallel test suites for percy #9054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ jobs:
non-rust: ${{ steps.changed-files-non-rust.outputs.any_modified }}
rust-lockfile: ${{ steps.changed-files-rust-lockfile.outputs.any_modified }}

percy-nonce:
name: Frontend / Percy Nonce
runs-on: ubuntu-latest
needs: changed-files
if: needs.changed-files.outputs.non-rust == 'true'

# persist job results to other jobs in the workflow
outputs:
nonce: ${{ steps.percy-nonce.outputs.nonce }}

steps:
# persist step results to other steps in the job
- id: percy-nonce
# adding a timestamp makes the nonce more unique for re-runs
run: echo "nonce=${{ github.run_id }}-$(date +%s)" >> $GITHUB_OUTPUT

backend-lint:
name: Backend / Lint
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -177,7 +193,7 @@ jobs:
frontend-test:
name: Frontend / Test
runs-on: ubuntu-22.04
needs: changed-files
needs: [changed-files, percy-nonce]
if: needs.changed-files.outputs.non-rust == 'true'

env:
Expand All @@ -186,6 +202,8 @@ jobs:
# Percy secrets are included here to enable Percy's GitHub integration
# on community-submitted PRs
PERCY_TOKEN: web_0a783d8086b6f996809f3e751d032dd6d156782082bcd1423b9b860113c75054
PERCY_PARALLEL_NONCE: ${{ needs.percy-nonce.outputs.nonce }}
PERCY_PARALLEL_TOTAL: 2

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand All @@ -202,15 +220,15 @@ jobs:
- run: pnpm install

- if: github.repository == 'rust-lang/crates.io'
run: pnpm percy exec -- pnpm test-coverage
run: pnpm percy exec --parallel -- pnpm test-coverage

- if: github.repository != 'rust-lang/crates.io'
run: pnpm test-coverage

e2e-test:
name: Frontend / Test (playwright)
runs-on: ubuntu-22.04
needs: changed-files
needs: [changed-files, percy-nonce]
timeout-minutes: 60
if: needs.changed-files.outputs.non-rust == 'true'

Expand All @@ -220,6 +238,8 @@ jobs:
# Percy secrets are included here to enable Percy's GitHub integration
# on community-submitted PRs
PERCY_TOKEN: web_0a783d8086b6f996809f3e751d032dd6d156782082bcd1423b9b860113c75054
PERCY_PARALLEL_NONCE: ${{ needs.percy-nonce.outputs.nonce }}
PERCY_PARALLEL_TOTAL: 2

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand All @@ -238,7 +258,7 @@ jobs:
- run: pnpm playwright install chromium

- if: github.repository == 'rust-lang/crates.io'
run: pnpm percy exec -- pnpm e2e
run: pnpm percy exec --parallel -- pnpm e2e

- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4
if: ${{ !cancelled() }}
Expand Down
4 changes: 3 additions & 1 deletion e2e/fixtures/percy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export class PercyPage {
private title(): string {
// Skip the filename
const paths = this.testInfo.titlePath.slice(1);
return paths.join(' | ');
// Add an "e2e" prefix to differentiate the snapshots from the QUnit tests.
// This address the visual changes caused by the font not loading in QUnit tests (#9052).
return ['e2e'].concat(paths).join(' | ');
}

async snapshot(options?: Parameters<typeof percySnapshot>[2]) {
Expand Down
Loading