|
| 1 | +# Test Sharding Workflows |
| 2 | + |
| 3 | +This document explains the GitHub Actions workflows that demonstrate the new test sharding functionality in CodeceptJS. |
| 4 | + |
| 5 | +## Updated/Created Workflows |
| 6 | + |
| 7 | +### 1. `acceptance-tests.yml` (Updated) |
| 8 | + |
| 9 | +**Purpose**: Demonstrates sharding with acceptance tests across multiple browser configurations. |
| 10 | + |
| 11 | +**Key Features**: |
| 12 | +- Runs traditional docker-compose tests (for backward compatibility) |
| 13 | +- Adds new sharded acceptance tests using CodeceptJS directly |
| 14 | +- Tests across multiple browser configurations (Puppeteer, Playwright) |
| 15 | +- Uses 2x2 matrix: 2 configs × 2 shards = 4 parallel jobs |
| 16 | + |
| 17 | +**Example Output**: |
| 18 | +``` |
| 19 | +- Sharded Tests: codecept.Puppeteer.js (Shard 1/2) |
| 20 | +- Sharded Tests: codecept.Puppeteer.js (Shard 2/2) |
| 21 | +- Sharded Tests: codecept.Playwright.js (Shard 1/2) |
| 22 | +- Sharded Tests: codecept.Playwright.js (Shard 2/2) |
| 23 | +``` |
| 24 | + |
| 25 | +### 2. `sharding-demo.yml` (New) |
| 26 | + |
| 27 | +**Purpose**: Comprehensive demonstration of sharding features with larger test suite. |
| 28 | + |
| 29 | +**Key Features**: |
| 30 | +- Uses sandbox tests (38 test files) for meaningful sharding demonstration |
| 31 | +- Shows basic sharding with 4-way split (`1/4`, `2/4`, `3/4`, `4/4`) |
| 32 | +- Demonstrates combination of `--shuffle` + `--shard` options |
| 33 | +- Comprehensive documentation and examples |
| 34 | + |
| 35 | +### 3. `test.yml` (Updated) |
| 36 | + |
| 37 | +**Purpose**: Clarifies which tests support sharding. |
| 38 | + |
| 39 | +**Changes**: |
| 40 | +- Added comment explaining that runner tests are mocha-based and don't support sharding |
| 41 | +- Points to sharding-demo.yml for examples of CodeceptJS-based sharding |
| 42 | + |
| 43 | +## Sharding Commands Used |
| 44 | + |
| 45 | +### Basic Sharding |
| 46 | +```bash |
| 47 | +npx codeceptjs run --config ./codecept.js --shard 1/4 |
| 48 | +npx codeceptjs run --config ./codecept.js --shard 2/4 |
| 49 | +# etc. |
| 50 | +``` |
| 51 | + |
| 52 | +### Combined with Other Options |
| 53 | +```bash |
| 54 | +npx codeceptjs run --config ./codecept.js --shuffle --shard 1/2 --verbose |
| 55 | +``` |
| 56 | + |
| 57 | +## Test Distribution |
| 58 | + |
| 59 | +The sharding algorithm distributes tests evenly: |
| 60 | + |
| 61 | +- **38 tests across 4 shards**: ~9-10 tests per shard |
| 62 | +- **6 acceptance tests across 2 shards**: 3 tests per shard |
| 63 | +- **Uneven splits handled gracefully**: Earlier shards get extra tests when needed |
| 64 | + |
| 65 | +## Benefits Demonstrated |
| 66 | + |
| 67 | +1. **Parallel Execution**: Tests run simultaneously across multiple CI workers |
| 68 | +2. **No Manual Configuration**: Automatic test distribution without maintaining test lists |
| 69 | +3. **Load Balancing**: Even distribution ensures balanced execution times |
| 70 | +4. **Flexibility**: Works with any number of shards and test configurations |
| 71 | +5. **Integration**: Compatible with existing CodeceptJS features (`--shuffle`, `--verbose`, etc.) |
| 72 | + |
| 73 | +## CI Matrix Integration |
| 74 | + |
| 75 | +The workflows show practical CI matrix usage: |
| 76 | + |
| 77 | +```yaml |
| 78 | +strategy: |
| 79 | + matrix: |
| 80 | + config: ['codecept.Puppeteer.js', 'codecept.Playwright.js'] |
| 81 | + shard: ['1/2', '2/2'] |
| 82 | +``` |
| 83 | +
|
| 84 | +This creates 4 parallel jobs: |
| 85 | +- Config A, Shard 1/2 |
| 86 | +- Config A, Shard 2/2 |
| 87 | +- Config B, Shard 1/2 |
| 88 | +- Config B, Shard 2/2 |
| 89 | +
|
| 90 | +Perfect for scaling test execution across multiple machines and configurations. |
0 commit comments