-
Notifications
You must be signed in to change notification settings - Fork 14
/
action.yml
69 lines (65 loc) · 2.39 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Split Tests
author: chaosaffe@users.noreply.github.com
description: Splits test suite for parallelization with equal time
inputs:
split-total:
description: Total number of instances executing the tests (integer)
required: true
split-index:
description: Index of this instance executing the tests (integer)
required: true
glob:
description: Glob pattern to find test files (default "spec/**/*_spec.rb") (string)
required: false
default: spec/**/*_spec.rb
exclude-glob:
description: Glob pattern to exclude test files (string)
required: false
default: ""
junit-path:
description: Path to a JUnit XML report to use for test timings (string)
required: false
line-count:
description: Use line count to estimate test times (boolean)
required: false
outputs:
test-suite:
description: "A subset of tests, based on the the split index and split type"
value: ${{ steps.split-tests.outputs.test-suite }}
split-total:
description: Total number of instances executing the tests
value: ${{ inputs.split-total }}
split-index:
description: Index of this instance executing the tests
value: ${{ inputs.split-index }}
runs:
using: composite
steps:
- name: Install split_tests
run: curl -L "https://github.com/leonid-shevtsov/split_tests/releases/latest/download/split_tests.linux.gz" | gunzip -v > split_tests && chmod +x split_tests
shell: bash
- name: Split Tests
id: split-tests
run: |
# setup split type
if [ -n "${{ inputs.junit-path }}" ]; then
echo "junit-path set. Splitting based on JUnit timings"
SPLIT_BY="-junit -junit-path=${{ inputs.junit-path }}"
elif [ -n "${{ inputs.line-count }}" ]; then
echo "line-count set. Splitting based on test line count"
SPLIT_BY="-line-count"
else
echo "No split type arguments set. Using default"
SPLIT_BY=""
fi
EXCLUDE_GLOB=""
if [ -n "${{ inputs.exclude-glob }}" ]; then
EXCLUDE_GLOB="-exclude-glob='${{ inputs.exclude-glob }}'"
fi
TESTS=$(./split_tests ${SPLIT_BY} -split-index=${{ inputs.split-index }} -split-total=${{ inputs.split-total }} -glob='${{ inputs.glob }}' ${EXCLUDE_GLOB})
echo $TESTS
echo "test-suite=${TESTS}" >> $GITHUB_OUTPUT
shell: bash
branding:
icon: shuffle
color: orange