diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a0b26c57ea2..a5aff70220c6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,8 @@ jobs: os: [ubuntu-latest] node: [18, 20] experimental: [false] + shardIndex: [1, 2, 3, 4] + shardTotal: [4] # include: # - os: windows-latest # node: 16 @@ -80,6 +82,7 @@ jobs: run: | node -v npm -v - yarn test --silent + yarn test --silent --shard=${{ matrix.shardIndex}}/${{ matrix.shardTotal }} env: SANITY_CI_CLI_AUTH_TOKEN: ${{ secrets.SANITY_CI_CLI_AUTH_TOKEN }} + GITHUB_SHARD_IDENTIFIER: ${{ matrix.shardIndex }}_${{ matrix.shardTotal }} diff --git a/packages/@sanity/cli/test/shared/environment.ts b/packages/@sanity/cli/test/shared/environment.ts index eda5681eabb1..4710470835a9 100644 --- a/packages/@sanity/cli/test/shared/environment.ts +++ b/packages/@sanity/cli/test/shared/environment.ts @@ -58,7 +58,7 @@ const getTestId = () => { const localId = readFileSync(testIdPath, 'utf8').trim() const ghRunId = `${process.env.GITHUB_RUN_ID || ''}`.slice(-4) - const ghId = `${ghRunId}-${process.env.GITHUB_RUN_NUMBER}-${process.env.GITHUB_RUN_ATTEMPT}` + const ghId = `${ghRunId}-${process.env.GITHUB_RUN_NUMBER}-${process.env.GITHUB_RUN_ATTEMPT}-${process.env.GITHUB_SHARD_IDENTIFIER}` const githubId = process.env.GITHUB_RUN_ID ? `gh-${ghId}` : '' const runId = `${githubId || localId}`.replace(/\W/g, '-').replace(/(^-+|-+$)/g, '')