Skip to content

Commit 5a46e4a

Browse files
ci: add dynamic sharding for E2E tests [WPB-24724] (#21155)
* ci: add dynamic sharding for E2E tests [WPB-24724] * fix: transform shards array using fromJSON * refactor: log number of computed shards
1 parent 233cd9a commit 5a46e4a

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

.github/workflows/e2e-tests.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,47 @@ jobs:
9696
TEST_SERVICE_URL: http://localhost:8080
9797
run: yarn playwright test -c apps/webapp/playwright.config.ts apps/webapp/test/e2e_tests/specs/CriticalFlow/startupHasNoConsoleErrors.spec.ts
9898

99+
# Since not always all e2e tests are run the number of shards to start up is computed dynamically from the amount of tests which will run
100+
compute_shards:
101+
name: Compute number of shards to use
102+
runs-on: ubuntu-24.04
103+
104+
outputs:
105+
matrixShards: ${{ steps.computeShards.outputs.matrixShards }}
106+
107+
steps:
108+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
109+
110+
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f
111+
with:
112+
node-version-file: '.nvmrc'
113+
cache: 'yarn'
114+
- run: yarn --immutable
115+
116+
- name: Compute shards
117+
id: computeShards
118+
env:
119+
GREP: ${{ inputs.grep }}
120+
run: |
121+
NUMBER_OF_TESTS=$(yarn nx run webapp:e2e --list --grep=\"$GREP\" | grep 'Total:' | awk '{print $2}')
122+
NUMBER_OF_SHARDS=$(( $NUMBER_OF_TESTS > 64 ? 64 : $NUMBER_OF_TESTS )) # Limit the number of shards to 64
123+
MATRIX_SHARDS=$(jq -nc --argjson len "$NUMBER_OF_SHARDS" '[range(1; $len + 1)]')
124+
echo "matrixShards=$MATRIX_SHARDS" >> $GITHUB_OUTPUT
125+
echo "$NUMBER_OF_TESTS tests will be run across $NUMBER_OF_SHARDS shards"
126+
99127
test:
100128
name: Run E2E Tests
101129
runs-on: ubuntu-24.04
102130
timeout-minutes: 45
103-
needs: [bootstrap_smoke_test]
131+
needs: [bootstrap_smoke_test, compute_shards]
104132
container:
105133
image: mcr.microsoft.com/playwright:v1.59.1-noble
106134
options: --ipc=host
107135

108136
strategy:
109137
fail-fast: false
110138
matrix:
111-
# prettier-ignore
112-
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64]
139+
shard: ${{ fromJSON(needs.compute_shards.outputs.matrixShards) }}
113140

114141
services:
115142
# Run the kalium testservice as service container of the current job

0 commit comments

Comments
 (0)