Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:
types:
- opened
- syncronize
- synchronize
- reopened
env:
total-runners: 5
Expand All @@ -24,7 +24,7 @@ jobs:
MAX_INDEX=$((${{ env.total-runners }}-1))
INDEX_LIST=$(seq 0 ${MAX_INDEX})
INDEX_JSON=$(jq --null-input --compact-output '. |= [inputs]' <<< ${INDEX_LIST})
echo "::set-output name=json::${INDEX_JSON}"
echo "json=${INDEX_JSON}" >> "$GITHUB_OUTPUT"

run-parallel-tests:
runs-on: ubuntu-latest
Expand All @@ -39,7 +39,7 @@ jobs:
with:
repository: eliotsykes/rspec-rails-examples
path: examples/
- uses: chaosaffe/split-tests@v1-alpha.1
- uses: scruplelesswizard/split-tests@v1
id: split-tests
name: Split tests
with:
Expand Down
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
# split-tests

_Github Action for splitting a test suite into equal time groups for parallel execution._
[![Smoke Tests](https://github.com/scruplelesswizard/split-tests/actions/workflows/smoke-tests.yaml/badge.svg)](https://github.com/scruplelesswizard/split-tests/actions/workflows/smoke-tests.yaml)
[![Latest release](https://img.shields.io/github/v/release/scruplelesswizard/split-tests)](https://github.com/scruplelesswizard/split-tests/releases)

_GitHub Action for splitting a test suite into equal time groups for parallel execution._

## Introduction

This actions allows you to split up a suite of tests so they can be executed in parallel across a fleet of runners. The overall goal is to reduce developer feedback time by distributing the load.
This action splits a suite of tests so they can run in parallel across a fleet of runners. The goal is to reduce developer feedback time by distributing the load evenly, so no single runner is left running the slow tests while the others sit idle.

- **Any test runner.** The action only decides which test _files_ each runner gets, and outputs them as a space-separated string. Pass that string to RSpec, pytest, Jest, `go test` or anything else.
- **Three ways to split:** by file count, by line count, or by real durations from a previous JUnit report.
- **Pinned and checksummed.** The `split_tests` binary is pinned to a specific release and verified by SHA256. A weekly workflow opens a PR when upstream releases a new version.

Runs on `ubuntu` (Linux) runners only, because `split_tests` is installed as a Linux binary.

## Quick start

Runs on `ubuntu` (Linux) runners only — `split_tests` is installed as a Linux binary.
```yaml
- uses: actions/checkout@v4
- uses: scruplelesswizard/split-tests@v1
id: split
with:
glob: "test/**/*_test.py"
split-total: 4
split-index: ${{ matrix.index }} # 0..3, one per matrix job
- run: pytest ${{ steps.split.outputs.test-suite }}
```

The `glob` default is `spec/**/*_spec.rb` (RSpec), so set it for other languages. See the full matrix example [below](#example-workflow).

## Usage

Expand All @@ -24,6 +46,8 @@ Another naive split, but this time based on the number of lines per test. It is

This is the most intelligent split mechanism, using previous execution durations for each test from the JUnit report. It is used by setting the `junit-path` to the location of a previous execution's JUnit results report in your repository

Timings must be per test **file**. If your runner writes one report per worker, or per-test-case reports, merge them first with [junit-munger](https://github.com/scruplelesswizard/junit-munger), then point `junit-path` at the merged file.

### Inputs

| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Split Tests
author: chaosaffe@users.noreply.github.com
author: scruplelesswizard
description: Splits test suite for parallelization with equal time
inputs:
split-total:
Expand Down
Loading