Skip to content

Commit

Permalink
ci: add shard matrix (taiga-family#9689)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored and shiv9604 committed Nov 22, 2024
1 parent 60cf64a commit 94c683d
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ name: ⚙️ E2E testing
on:
pull_request:

env:
CYPRESS_BASELINE_REPO: 'baseline'
CYPRESS_RESULTS_FOLDER: 'projects/demo-cypress/tests-results'
CYPRESS_BASELINE_SNAPSHOTS: 'projects/demo-cypress/tests-results/snapshots/baseline'
CYPRESS_BASELINE_SNAPSHOTS_KEY: 'cy_baseline_${{ github.event.pull_request.head.sha }}'

jobs:
build-demo:
if: ${{ !contains(github.head_ref , 'release/') }}
Expand Down Expand Up @@ -35,6 +29,11 @@ jobs:
cypress:
runs-on: ubuntu-latest
name: Cypress / Component Testing
env:
CYPRESS_BASELINE_REPO: 'baseline'
CYPRESS_RESULTS_FOLDER: 'projects/demo-cypress/tests-results'
CYPRESS_BASELINE_SNAPSHOTS: 'projects/demo-cypress/tests-results/snapshots/baseline'
CYPRESS_BASELINE_SNAPSHOTS_KEY: 'cy_baseline_${{ github.event.pull_request.head.sha }}'
steps:
- uses: actions/checkout@v4.2.2
with:
Expand Down Expand Up @@ -92,10 +91,21 @@ jobs:
needs: [build-demo]
strategy:
fail-fast: false
max-parallel: 9
matrix:
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9]
shardTotal: [9]
name: Playwright / (${{ matrix.shardIndex }} of ${{ matrix.shardTotal }})
shard: [
# Chrome
{index: 1, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 2, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 3, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 4, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 5, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 6, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 7, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 8, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 9, os: 'ubuntu-latest', project: 'chromium', total: 9},
]
name: Playwright / ${{ matrix.shard.os }} / ${{ matrix.shard.index }} of ${{ matrix.shard.total }}
steps:
- uses: actions/checkout@v4.2.2
- uses: taiga-family/ci/actions/setup/variables@v1.94.0
Expand All @@ -105,6 +115,7 @@ jobs:
id: playwright-version
run: |
echo "PLAYWRIGHT_VERSION=$(node -p 'require("./projects/demo-playwright/package.json").devDependencies["@playwright/test"]')" >> $GITHUB_ENV
- uses: actions/cache/restore@v4.1.2
id: playwright-cache
with:
Expand All @@ -131,7 +142,11 @@ jobs:
replaceBaseUrl: false

- name: Run screenshot tests on ${{ env.DIST }}
run: npx nx e2e demo-playwright -- --update-snapshots --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
run: |
npx nx e2e demo-playwright -- \
--update-snapshots \
--project=${{ matrix.shard.project }} \
--shard=${{ matrix.shard.index }}/${{ matrix.shard.total }}
- uses: taiga-family/ci/actions/run/clone@v1.94.0
with:
Expand All @@ -146,7 +161,10 @@ jobs:

- name: Run screenshot tests on ${{ env.DIST_NEXT }}
continue-on-error: true
run: npx nx e2e demo-playwright --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
run: |
npx nx e2e demo-playwright -- \
--project=${{ matrix.shard.project }} \
--shard=${{ matrix.shard.index }}/${{ matrix.shard.total }}
- name: Combine images to get diff reports
run: |
Expand All @@ -164,7 +182,7 @@ jobs:
path: |
./projects/demo-playwright/tests-results/**/*.diff.png
!./projects/demo-playwright/tests-results/**/*-retry*/*.diff.png
name: '${{ env.PLAYWRIGHT_SNAPSHOTS_ARTIFACTS_KEY }}_${{ matrix.shardIndex }}'
name: '${{ env.PLAYWRIGHT_SNAPSHOTS_ARTIFACTS_KEY }}_${{ matrix.shard.project }}_${{ matrix.shard.index }}'
if-no-files-found: ignore
compression-level: 0
retention-days: 1
Expand Down

0 comments on commit 94c683d

Please sign in to comment.