Skip to content

Test Sharding for CI Matrix Purposes with GitHub Workflows #2

Test Sharding for CI Matrix Purposes with GitHub Workflows

Test Sharding for CI Matrix Purposes with GitHub Workflows #2

Workflow file for this run

name: Test Sharding Demonstration
on:
push:
branches:
- '3.x'
pull_request:
branches:
- '**'
env:
CI: true
FORCE_COLOR: 1
jobs:
# Demonstrate sharding with a larger test suite (sandbox tests)
sharded-sandbox-tests:
runs-on: ubuntu-latest
name: 'Sandbox Tests (Shard ${{ matrix.shard }})'
strategy:
fail-fast: false
matrix:
node-version: [20.x]
# Split 2 sandbox tests across 2 shards for demonstration
shard: ['1/2', '2/2']
steps:
- name: Checkout Repository
uses: actions/checkout@v5
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Run Sandbox Tests with Sharding
run: npx codeceptjs run --config ./test/data/sandbox/codecept.js --shard ${{ matrix.shard }} --verbose
working-directory: test/data/sandbox
env:
FORCE_COLOR: 1
DONT_FAIL_ON_EMPTY_RUN: true
- name: Display Shard Info
run: |
echo "This shard (${{ matrix.shard }}) ran a subset of the available test files"
echo "All shards together cover the complete test suite without duplication"
# Show combination with shuffle option
sharded-shuffled-tests:
runs-on: ubuntu-latest
name: 'Shuffled + Sharded Tests (Shard ${{ matrix.shard }})'
strategy:
fail-fast: false
matrix:
node-version: [20.x]
shard: ['1/2', '2/2']
steps:
- name: Checkout Repository
uses: actions/checkout@v5
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Run Tests with Shuffle + Sharding
run: npx codeceptjs run --config ./test/data/sandbox/codecept.js --shuffle --shard ${{ matrix.shard }} --verbose
working-directory: test/data/sandbox
env:
FORCE_COLOR: 1
DONT_FAIL_ON_EMPTY_RUN: true
- name: Display Combined Options Info
run: |
echo "This demonstrates sharding combined with shuffle option"
echo "Tests are first shuffled, then sharded for this worker (${{ matrix.shard }})"