Skip to content

Commit ff8d52e

Browse files
Copilotkobenguyent
andcommitted
Changes before error encountered
Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
1 parent 81a7aa7 commit ff8d52e

File tree

3 files changed

+51
-33
lines changed

3 files changed

+51
-33
lines changed

.github/SHARDING_WORKFLOWS.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ This document explains the GitHub Actions workflows that demonstrate the new tes
99
**Purpose**: Demonstrates sharding with acceptance tests across multiple browser configurations.
1010

1111
**Key Features**:
12+
1213
- Runs traditional docker-compose tests (for backward compatibility)
1314
- Adds new sharded acceptance tests using CodeceptJS directly
1415
- Tests across multiple browser configurations (Puppeteer, Playwright)
1516
- Uses 2x2 matrix: 2 configs × 2 shards = 4 parallel jobs
1617

1718
**Example Output**:
19+
1820
```
1921
- Sharded Tests: codecept.Puppeteer.js (Shard 1/2)
2022
- Sharded Tests: codecept.Puppeteer.js (Shard 2/2)
21-
- Sharded Tests: codecept.Playwright.js (Shard 1/2)
23+
- Sharded Tests: codecept.Playwright.js (Shard 1/2)
2224
- Sharded Tests: codecept.Playwright.js (Shard 2/2)
2325
```
2426

@@ -27,29 +29,32 @@ This document explains the GitHub Actions workflows that demonstrate the new tes
2729
**Purpose**: Comprehensive demonstration of sharding features with larger test suite.
2830

2931
**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+
33+
- Uses sandbox tests (2 main test files) for sharding demonstration
34+
- Shows basic sharding with 2-way split (`1/2`, `2/2`)
3235
- Demonstrates combination of `--shuffle` + `--shard` options
33-
- Comprehensive documentation and examples
36+
- Uses `DONT_FAIL_ON_EMPTY_RUN=true` to handle cases where some shards may be empty
3437

3538
### 3. `test.yml` (Updated)
3639

3740
**Purpose**: Clarifies which tests support sharding.
3841

3942
**Changes**:
43+
4044
- Added comment explaining that runner tests are mocha-based and don't support sharding
4145
- Points to sharding-demo.yml for examples of CodeceptJS-based sharding
4246

4347
## Sharding Commands Used
4448

4549
### Basic Sharding
50+
4651
```bash
47-
npx codeceptjs run --config ./codecept.js --shard 1/4
48-
npx codeceptjs run --config ./codecept.js --shard 2/4
49-
# etc.
52+
npx codeceptjs run --config ./codecept.js --shard 1/2
53+
npx codeceptjs run --config ./codecept.js --shard 2/2
5054
```
5155

5256
### Combined with Other Options
57+
5358
```bash
5459
npx codeceptjs run --config ./codecept.js --shuffle --shard 1/2 --verbose
5560
```
@@ -59,7 +64,7 @@ npx codeceptjs run --config ./codecept.js --shuffle --shard 1/2 --verbose
5964
The sharding algorithm distributes tests evenly:
6065

6166
- **38 tests across 4 shards**: ~9-10 tests per shard
62-
- **6 acceptance tests across 2 shards**: 3 tests per shard
67+
- **6 acceptance tests across 2 shards**: 3 tests per shard
6368
- **Uneven splits handled gracefully**: Earlier shards get extra tests when needed
6469

6570
## Benefits Demonstrated
@@ -82,9 +87,10 @@ strategy:
8287
```
8388
8489
This creates 4 parallel jobs:
90+
8591
- Config A, Shard 1/2
86-
- Config A, Shard 2/2
92+
- Config A, Shard 2/2
8793
- Config B, Shard 1/2
8894
- Config B, Shard 2/2
8995
90-
Perfect for scaling test execution across multiple machines and configurations.
96+
Perfect for scaling test execution across multiple machines and configurations.

.github/workflows/acceptance-tests.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
# New sharded acceptance tests using CodeceptJS directly
5353
sharded-acceptance-tests:
5454
runs-on: ubuntu-latest
55-
name: "Sharded Tests: ${{ matrix.config }} (Shard ${{ matrix.shard }})"
55+
name: 'Sharded Tests: ${{ matrix.config }} (Shard ${{ matrix.shard }})'
5656

5757
strategy:
5858
fail-fast: false
@@ -64,23 +64,39 @@ jobs:
6464
steps:
6565
- name: Checkout Repository
6666
uses: actions/checkout@v5
67-
67+
6868
- name: Use Node.js ${{ matrix.node-version }}
6969
uses: actions/setup-node@v4
7070
with:
7171
node-version: ${{ matrix.node-version }}
72-
72+
73+
- name: Setup PHP
74+
uses: shivammathur/setup-php@v2
75+
with:
76+
php-version: 7.4
77+
7378
- name: Install dependencies
7479
run: npm install --ignore-scripts
7580
env:
7681
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
7782
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
7883

84+
- name: Install Puppeteer Browser
85+
if: contains(matrix.config, 'Puppeteer')
86+
run: npx puppeteer browsers install chrome
87+
88+
- name: Install Playwright Browsers
89+
if: contains(matrix.config, 'Playwright')
90+
run: npx playwright install chromium && npx playwright install-deps
91+
92+
- name: Start PHP Server
93+
run: php -S 127.0.0.1:8000 -t test/data/app &
94+
7995
- name: Run Acceptance Tests with Sharding
8096
run: npx codeceptjs run --config ./test/acceptance/${{ matrix.config }} --shard ${{ matrix.shard }} --verbose
8197
env:
8298
FORCE_COLOR: 1
83-
99+
84100
- name: Display Test Info
85101
run: |
86102
echo "Configuration: ${{ matrix.config }}"

.github/workflows/sharding-demo.yml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,45 +16,43 @@ jobs:
1616
# Demonstrate sharding with a larger test suite (sandbox tests)
1717
sharded-sandbox-tests:
1818
runs-on: ubuntu-latest
19-
name: "Sandbox Tests (Shard ${{ matrix.shard }})"
19+
name: 'Sandbox Tests (Shard ${{ matrix.shard }})'
2020

2121
strategy:
2222
fail-fast: false
2323
matrix:
2424
node-version: [20.x]
25-
# Split 38 sandbox tests across 4 shards for demonstration
26-
shard: ['1/4', '2/4', '3/4', '4/4']
25+
# Split 2 sandbox tests across 2 shards for demonstration
26+
shard: ['1/2', '2/2']
2727

2828
steps:
2929
- name: Checkout Repository
3030
uses: actions/checkout@v5
31-
31+
3232
- name: Use Node.js ${{ matrix.node-version }}
3333
uses: actions/setup-node@v4
3434
with:
3535
node-version: ${{ matrix.node-version }}
36-
36+
3737
- name: Install dependencies
3838
run: npm install
39-
env:
40-
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
41-
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
4239

4340
- name: Run Sandbox Tests with Sharding
4441
run: npx codeceptjs run --config ./test/data/sandbox/codecept.js --shard ${{ matrix.shard }} --verbose
4542
working-directory: test/data/sandbox
4643
env:
4744
FORCE_COLOR: 1
48-
45+
DONT_FAIL_ON_EMPTY_RUN: true
46+
4947
- name: Display Shard Info
5048
run: |
51-
echo "This shard (${{ matrix.shard }}) ran a subset of the total sandbox tests"
49+
echo "This shard (${{ matrix.shard }}) ran a subset of the available test files"
5250
echo "All shards together cover the complete test suite without duplication"
5351
5452
# Show combination with shuffle option
5553
sharded-shuffled-tests:
56-
runs-on: ubuntu-latest
57-
name: "Shuffled + Sharded Tests (Shard ${{ matrix.shard }})"
54+
runs-on: ubuntu-latest
55+
name: 'Shuffled + Sharded Tests (Shard ${{ matrix.shard }})'
5856

5957
strategy:
6058
fail-fast: false
@@ -65,25 +63,23 @@ jobs:
6563
steps:
6664
- name: Checkout Repository
6765
uses: actions/checkout@v5
68-
66+
6967
- name: Use Node.js ${{ matrix.node-version }}
7068
uses: actions/setup-node@v4
7169
with:
7270
node-version: ${{ matrix.node-version }}
73-
71+
7472
- name: Install dependencies
7573
run: npm install
76-
env:
77-
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
78-
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
7974

8075
- name: Run Tests with Shuffle + Sharding
8176
run: npx codeceptjs run --config ./test/data/sandbox/codecept.js --shuffle --shard ${{ matrix.shard }} --verbose
8277
working-directory: test/data/sandbox
8378
env:
8479
FORCE_COLOR: 1
85-
80+
DONT_FAIL_ON_EMPTY_RUN: true
81+
8682
- name: Display Combined Options Info
8783
run: |
8884
echo "This demonstrates sharding combined with shuffle option"
89-
echo "Tests are first shuffled, then sharded for this worker (${{ matrix.shard }})"
85+
echo "Tests are first shuffled, then sharded for this worker (${{ matrix.shard }})"

0 commit comments

Comments
 (0)