Test Sharding for CI Matrix Purposes with GitHub Workflows #1837
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: 7.4 | |
| - name: Install dependencies | |
| run: npm install --ignore-scripts | |
| env: | |
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true | |
| PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true | |
| - name: Setup Chrome | |
| uses: browser-actions/setup-chrome@v1 | |
| - name: Install Playwright Browsers | |
| if: contains(matrix.config, 'Playwright') | |
| run: npx playwright install chromium --with-deps | |
| - name: Verify browser setup | |
| run: | | |
| which google-chrome || which chromium-browser || echo "Chrome not found in PATH" | |
| - name: Start PHP Server | |
| run: | | |
| php -S 127.0.0.1:8000 -t test/data/app & | |
| sleep 2 | |
| # Wait for server to be ready | |
| timeout 10 bash -c 'until curl -s http://127.0.0.1:8000 >/dev/null; do sleep 1; done' || echo "Server may not be fully ready" | |
| - name: Run Acceptance Tests with Sharding | |
| run: npx codeceptjs run --config ./test/acceptance/${{ matrix.config }} --shard ${{ matrix.shard }} --verbose | |
| env: | |
| FORCE_COLOR: 1 | |
| DONT_FAIL_ON_EMPTY_RUN: true | |
| - name: Display Test Info | |
| run: | | |
| echo "Configuration: ${{ matrix.config }}" | |
| echo "Shard: ${{ matrix.shard }}" | |
| echo "This demonstrates test sharding across different browser configurations" |