Skip to content

Commit 4cd9f4d

Browse files
Add README
1 parent 5a22ffe commit 4cd9f4d

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# split_tests
2+
3+
Splits a test suite into groups of equal time, based on previous tests timings.
4+
5+
This is necessary for running the tests in parallel. As the execution time of test files might vary drastically, you will not get the best split by simply dividing them into even groups.
6+
7+
## Compatibility
8+
9+
This tool was written for Ruby and CircleCI, but it can be used with any file-based test suite on any CI.
10+
11+
It is written in Golang, released as a binary, and has no external dependencies.
12+
13+
## Usage
14+
15+
Download and extract the latest build from the releases page.
16+
17+
### Using the CircleCI API
18+
19+
Get an API key and set `CIRCLECI_API_KEY` in the project config.
20+
21+
```
22+
rspec $(split_tests -circle-project github.com/leonid-shevtsov/split_tests)
23+
```
24+
25+
(The tool returns the set of files for the current split, joined by spaces.)
26+
27+
### Using a JUnit report
28+
29+
```
30+
rspec $(split_tests -junit -junit-path=report.xml -split-index=$CI_NODE_INDEX -split-total=$CI_NODE_TOTAL)
31+
```
32+
33+
Or, if it's easier to pipe the report file:
34+
35+
```
36+
rspec $(curl http://my.junit.url | split_tests -junit -split-index=$CI_NODE_INDEX -split-total=$CI_NODE_TOTAL)
37+
```
38+
39+
### Naive split by line count
40+
41+
If you don't have test times, it might be reasonable for your project to assume runtime proportional to test length.
42+
43+
```
44+
rspec $(split_tests -line-count)
45+
```
46+
47+
### Naive split by file count
48+
49+
In the absence of prior test times, `split_tests` can still split files into even groups by count.
50+
51+
```
52+
rspec $(split_tests)
53+
```
54+
55+
## Arguments
56+
57+
``` plain
58+
$./split_tests -help
59+
60+
-circleci-branch string
61+
Current branch for CircleCI (or set CIRCLE_BRANCH) - required to use CircleCI
62+
-circleci-key string
63+
CircleCI API key (or set CIRCLECI_API_KEY environment variable) - required to use CircleCI
64+
-circleci-project string
65+
CircleCI project name (e.g. github/leonid-shevtsov/split_tests) - required to use CircleCI
66+
-glob string
67+
Glob pattern to find test files (default "spec/**/*_spec.rb")
68+
-help
69+
Show this help text
70+
-junit
71+
Use a JUnit XML report for test times
72+
-junit-path string
73+
Path to a JUnit XML report (leave empty to read from stdin)
74+
-line-count
75+
Use line count to estimate test times
76+
-split-index int
77+
This test container's index (or set CIRCLE_NODE_INDEX) (default -1)
78+
-split-total int
79+
Total number of containers (or set CIRCLE_NODE_TOTAL) (default -1)
80+
```
81+
82+
## Compilation
83+
84+
This tool is written in Go.
85+
86+
* Install Go.
87+
* Install the [Glide](https://glide.sh) dependency manager.
88+
* Checkout the code
89+
* `glide install`
90+
* `make`
91+
92+
* * *
93+
94+
(c) [Leonid Shevtsov](https://leonid.shevtsov.me) 2017

0 commit comments

Comments
 (0)