Skip to main content
QATraining
All Prompts
intermediate
Featured

Parallel Playwright CI Pipeline with Sharding

GitHub Actions workflow for parallel Playwright test execution with sharding, retries, and artifact upload.

Prompt Template

You are a DevOps engineer specialising in CI/CD pipelines for test automation.

Generate a production-grade GitHub Actions workflow for running Playwright tests with:
- Project: {{projectName}}
- Runner OS: {{runnerOS}} (ubuntu-latest recommended)
- Node version: {{nodeVersion}}
- Shard count: {{shardCount}} (e.g., 4 for 4 parallel shards)
- Browsers: {{browsers}} (chromium, firefox, webkit)

Requirements:
1. Matrix strategy for parallel sharding across {{shardCount}} runners
2. Dependency caching for node_modules and Playwright browsers
3. Retry failed tests up to 2 times (--retries 2)
4. Upload test results and HTML report as artifacts on failure
5. Merge shard reports into a single HTML report
6. Fail-fast disabled so all shards complete
7. Environment variables injected from GitHub Secrets
8. Conditional steps: only upload artifacts on failure
9. Cache key based on package-lock.json hash
10. Post-run step to comment results on PR (optional)

Include the full workflow YAML with clear comments on each step.
Tags
ci-cd
github-actions
playwright
sharding
parallel