Skip to content

Conversation

Copy link

Copilot AI commented Aug 29, 2025

This PR implements test sharding for Playwright tests across multiple OS platforms to significantly reduce CI build time. The implementation includes:

Key Features

  • Test Sharding: Splits tests into 4 shards across 3 operating systems (Ubuntu, Windows, macOS)
  • Workflow Optimization: Added a common Setup job that prepares the environment once and shares cached dependencies across all test matrix jobs
  • Enhanced Caching: Implements aggressive caching for both pnpm dependencies and Playwright browsers per OS
  • Report Merging: Combines test reports from all shards into a single comprehensive report

Technical Implementation

  • Added PLAYWRIGHT_SHARD environment variable to enable blob reporting mode
  • Extracted reporter configuration logic into a reusable getPlaywrightReporters() function in playwright.config.ts
  • Implemented proper artifact management with appropriate retention periods
  • Added comprehensive caching strategy to reduce redundant setup work

Benefits

  • Reduces CI execution time by running tests in parallel across multiple shards
  • Minimizes redundant dependency installation across jobs through shared caching
  • Maintains full test coverage while improving build efficiency
  • Preserves backward compatibility with existing test infrastructure

The workflow now runs a Setup job once to prepare cached dependencies, then executes 12 parallel test jobs (3 OS × 4 shards) that leverage the shared cache, followed by a merge job that combines all test reports into a unified result.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits August 29, 2025 06:46
Co-authored-by: hudson-newey <33742269+hudson-newey@users.noreply.github.com>
Co-authored-by: hudson-newey <33742269+hudson-newey@users.noreply.github.com>
Copilot AI changed the title [WIP] Can you complete issue #457 (Shard tests in CI). Perform a minimal number of changes to complete the task, and no not expand scope past the original issue description. Use pnpm Implement test sharding in CI to reduce build time Aug 29, 2025
Copilot AI requested a review from hudson-newey August 29, 2025 06:51
Comment on lines 48 to 49
name: blob-report-${{ matrix.os }}-${{ matrix.shard }}
path: blob-report/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert blob-report name change.

Suggested change
name: blob-report-${{ matrix.os }}-${{ matrix.shard }}
path: blob-report/
name: test-report-${{ matrix.os }}-${{ matrix.shard }}
path: test-report/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the artifact name back to test-report-${{ matrix.os }}-${{ matrix.shard }} and updated path to test-report/ as requested. Commit 5ecd98a

Comment on lines 71 to 72
path: all-blob-reports/
pattern: blob-report-*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
path: all-blob-reports/
pattern: blob-report-*
path: all-test-reports/
pattern: test-report-*

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use path: all-test-reports/ and pattern: test-report-* as suggested. Commit 5ecd98a

path: all-blob-reports/
pattern: blob-report-*

- name: Merge Blob Reports
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Merge Blob Reports
- name: Merge Test Reports

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to "Merge Test Reports" for clarity. Commit 5ecd98a

- recursive: true
- args: [--frozen-lockfile]
- name: Download All Blob Reports
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Download All Blob Reports
- name: Download All Test Reports

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to "Download All Test Reports" for clarity. Commit 5ecd98a

pattern: blob-report-*

- name: Merge Blob Reports
run: pnpm exec playwright merge-reports --reporter=html,github all-blob-reports/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
run: pnpm exec playwright merge-reports --reporter=html,github all-blob-reports/
run: pnpm exec playwright merge-reports --reporter=html,github all-test-reports/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated run command to use all-test-reports/ directory. Commit 5ecd98a

Comment on lines 37 to 55
reporter: process.env.PLAYWRIGHT_SHARD
? [
["blob"],
["github"],
]
: [
// create a HTML report of the test results
// this is the best way to debug why tests are failing locally
[
"html",
{
outputFolder: "test-report",
open: "never",
},
],
// print the test results out to the console.
// this can be useful for seeing why a test has failed in CI
isCi ? ["github"] : ["list"],
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a TypeScript file.

Extract this out to a function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted the reporter configuration logic into a getPlaywrightReporters() function to improve code organization in the TypeScript file. Commit 5ecd98a

@hudson-newey
Copy link
Member

@copilot Address review feedback

…ction

Co-authored-by: hudson-newey <33742269+hudson-newey@users.noreply.github.com>
Copy link
Author

Copilot AI commented Aug 29, 2025

@copilot Address review feedback

All review feedback has been addressed in commit 5ecd98a. Changes include: reverting artifact naming, adding retention settings, improving comments, renaming workflow steps, updating paths/patterns, and extracting TypeScript logic into a function.

@hudson-newey
Copy link
Member

Good starter. I might have to do some minor formatting changes, but copilot seems to have (almost) nailed it

@hudson-newey
Copy link
Member

@copilot Instead of cloning and pnpm installing dependencies on each testing shard, can you use a common base workflow task to set up the environment and use that as the base for all subsequent tests

Co-authored-by: hudson-newey <33742269+hudson-newey@users.noreply.github.com>
Copy link
Author

Copilot AI commented Aug 29, 2025

@copilot Instead of cloning and pnpm installing dependencies on each testing shard, can you use a common base workflow task to set up the environment and use that as the base for all subsequent tests

Added a Setup job that runs once to prepare the environment and shared dependency cache across all test matrix jobs. Enhanced caching for both pnpm dependencies and Playwright browsers per OS. This reduces redundant setup work while maintaining the cross-platform testing matrix. Commit b5c7e9b

Copilot AI changed the title Implement test sharding in CI to reduce build time Implement test sharding in CI with workflow optimization to reduce build time Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants