Skip to content

Sharding

--shard 2/4 runs shard 2 of 4. Each selected test goes to a shard by a stable hash of its path, so the shards are roughly (not exactly) equal and together cover every selected test exactly once. A shard with nothing to run exits 0.

test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v6
with: { fetch-depth: 0 }
- run: curl -fsSL https://raw.githubusercontent.com/RabinApps/trimtest/main/install.sh | sh
- run: ~/.local/bin/trimtest run --base origin/${{ github.base_ref }} --shard ${{ matrix.shard }}/4

--project pytest@api (repeatable; alias --only) runs only projects whose name contains that text. Names look like <adapter>@<dir>; trimtest detect lists them.

A narrowed run (--shard or --project) only knows about its own part, so it keeps the failures recorded for the rest and does not clear them.

trimtest select --format github writes a matrix output of {adapter, cwd, command} entries, one per runner command, so a job can fan out over the exact commands trimtest would run:

strategy:
matrix: ${{ fromJSON(needs.select.outputs.matrix) }}
steps:
- run: ${{ matrix.command }}
working-directory: ${{ matrix.cwd }}