Skip to content

Test Sharding for CI Matrix Purposes with GitHub Workflows #1832

Test Sharding for CI Matrix Purposes with GitHub Workflows

Test Sharding for CI Matrix Purposes with GitHub Workflows #1832

name: Acceptance Tests with Sharding
on:
push:
branches:
- '3.x'
pull_request:
branches:
- '**'
env:
CI: true
# Force terminal colors. @see https://www.npmjs.com/package/colors
FORCE_COLOR: 1
jobs:
# Traditional docker-compose tests (kept for compatibility)
docker-tests:
runs-on: ubuntu-latest
name: Docker-based Tests
strategy:
matrix:
node-version: [20.x]
steps:
# Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v5
# Install Docker Compose
- name: Install Docker Compose
run: |
sudo apt-get update --allow-releaseinfo-change
sudo apt-get install -y docker-compose
# Run rest tests using docker-compose
- name: Run REST Tests
run: docker-compose run --rm test-rest
working-directory: test
# Run WebDriverIO acceptance tests using docker-compose
- name: Run WebDriverIO Acceptance Tests
run: docker-compose run --rm test-acceptance.webdriverio
working-directory: test
# Run faker BDD tests using docker-compose
- name: Run Faker BDD Tests
run: docker-compose run --rm test-bdd.faker
working-directory: test
# New sharded acceptance tests using CodeceptJS directly
sharded-acceptance-tests:
runs-on: ubuntu-latest
name: "Sharded Tests: ${{ matrix.config }} (Shard ${{ matrix.shard }})"
strategy:
fail-fast: false
matrix:
node-version: [20.x]
config: ['codecept.Puppeteer.js', 'codecept.Playwright.js']
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 --ignore-scripts
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- name: Run Acceptance Tests with Sharding
run: npx codeceptjs run --config ./test/acceptance/${{ matrix.config }} --shard ${{ matrix.shard }} --verbose
env:
FORCE_COLOR: 1
- name: Display Test Info
run: |
echo "Configuration: ${{ matrix.config }}"
echo "Shard: ${{ matrix.shard }}"
echo "This demonstrates test sharding across different browser configurations"