Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit dcf4593

Browse files
authored
Shard Jest tests to run complete them faster (#12061)
1 parent db7f0ba commit dcf4593

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

.github/workflows/sonarqube.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ concurrency:
1010
jobs:
1111
sonarqube:
1212
name: 🩻 SonarQube
13-
if: github.event.workflow_run.event != 'merge_group'
13+
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event != 'merge_group'
1414
uses: matrix-org/matrix-js-sdk/.github/workflows/sonarcloud.yml@develop
1515
secrets:
1616
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
17+
with:
18+
sharded: true

.github/workflows/tests.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ jobs:
3030
jest:
3131
name: Jest
3232
runs-on: ubuntu-latest
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
# Run multiple instances in parallel to speed up the tests
37+
runner: [1, 2]
3338
steps:
3439
- name: Checkout code
3540
uses: actions/checkout@v4
@@ -62,7 +67,17 @@ jobs:
6267
--coverage=${{ env.ENABLE_COVERAGE }} \
6368
--ci \
6469
--max-workers ${{ steps.cpu-cores.outputs.count }} \
70+
--shard ${{ matrix.runner }}/${{ strategy.job-total }} \
6571
--cacheDirectory /tmp/jest_cache
72+
env:
73+
JEST_SONAR_UNIQUE_OUTPUT_NAME: true
74+
75+
# tell jest to use coloured output
76+
FORCE_COLOR: true
77+
78+
- name: Move coverage files into place
79+
if: env.ENABLE_COVERAGE == 'true'
80+
run: mv coverage/lcov.info coverage/${{ steps.setupNode.outputs.node-version }}-${{ matrix.runner }}.lcov.info
6681

6782
- name: Upload Artifact
6883
if: env.ENABLE_COVERAGE == 'true'

0 commit comments

Comments
 (0)