Q15 of 17 · Framework design
How do you integrate a test automation framework into a CI/CD pipeline effectively?
Framework designSeniorframework-designci-cdgithub-actionspipelinesharding
Short answer
Short answer: Run fast, targeted tests (smoke/unit) on every PR commit, full regression nightly. Fail the build on test failure, publish reports as artifacts, shard for parallelism, and separate flaky tests into a non-blocking job.
Detail
GitHub Actions example — Playwright:
name: E2E Tests
on:
push:
branches: [main]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '20' }
- name: Install dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Run tests (shard)
run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
env:
ENV: staging
BASE_URL: ${{ secrets.STAGING_URL }}
- name: Upload Allure results
uses: actions/upload-artifact@v4
if: always()
with:
name: allure-results-${{ matrix.shardIndex }}
path: allure-results/
report:
needs: test
runs-on: ubuntu-latest
steps:
- name: Download all shard results
uses: actions/download-artifact@v4
- name: Merge and publish Allure report
run: npx allure generate allure-results* --clean -o allure-report
Key principles:
- Fail fast — smoke tests run first (<5 min); full regression only if smoke passes
- Secrets in CI vault —
secrets.STAGING_URL, never in code - Always upload reports —
if: always()ensures reports are available even when tests fail - Separate flaky job —
@quarantinetagged tests run in a separate non-blocking job - Retry on failure —
--retries=2for known-flaky environments (but fix the root cause) - Cache browser binaries —
actions/cachefor Playwright browsers reduces install time by 60%
// EXAMPLE
# PR pipeline: smoke only (fast feedback)
- name: Smoke tests
run: npx playwright test --grep @smoke --project=chromium
# Nightly pipeline: full regression, all browsers
- name: Full regression
run: npx playwright test --project=chromium,firefox,webkit// WHAT INTERVIEWERS LOOK FOR
Sharding for parallelism. Smoke on PR / regression nightly split. Always-upload reports. Secrets from CI vault. Flaky test non-blocking job.
// Related questions