From dcf45937aab570cb3d6943c81b34c35a5f949dda Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 5 Jan 2024 16:59:48 +0000 Subject: [PATCH] Shard Jest tests to run complete them faster (#12061) --- .github/workflows/sonarqube.yml | 4 +++- .github/workflows/tests.yml | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 1293e6e6656..509cbaaf787 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -10,7 +10,9 @@ concurrency: jobs: sonarqube: name: 🩻 SonarQube - if: github.event.workflow_run.event != 'merge_group' + if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event != 'merge_group' uses: matrix-org/matrix-js-sdk/.github/workflows/sonarcloud.yml@develop secrets: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + sharded: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a3808c4295f..5767c9525ff 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,6 +30,11 @@ jobs: jest: name: Jest runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # Run multiple instances in parallel to speed up the tests + runner: [1, 2] steps: - name: Checkout code uses: actions/checkout@v4 @@ -62,7 +67,17 @@ jobs: --coverage=${{ env.ENABLE_COVERAGE }} \ --ci \ --max-workers ${{ steps.cpu-cores.outputs.count }} \ + --shard ${{ matrix.runner }}/${{ strategy.job-total }} \ --cacheDirectory /tmp/jest_cache + env: + JEST_SONAR_UNIQUE_OUTPUT_NAME: true + + # tell jest to use coloured output + FORCE_COLOR: true + + - name: Move coverage files into place + if: env.ENABLE_COVERAGE == 'true' + run: mv coverage/lcov.info coverage/${{ steps.setupNode.outputs.node-version }}-${{ matrix.runner }}.lcov.info - name: Upload Artifact if: env.ENABLE_COVERAGE == 'true'