File tree 2 files changed +51
-19
lines changed
2 files changed +51
-19
lines changed Original file line number Diff line number Diff line change
1
+ import itertools
2
+ from pathlib import Path
3
+ import json
4
+ import re
5
+
6
+
7
+ def get_test_functions (tests_path ):
8
+ test_functions_regex = re .compile (r"^def (test_[a-zA-Z_]*)\(" )
9
+ test_functions = []
10
+ for test_file in tests_path .glob ("test_*.py" ):
11
+
12
+ for line in test_file .read_text ().splitlines ():
13
+ if match := test_functions_regex .match (line ):
14
+ test_functions .append (f"{ test_file } ::{ match .group (1 )} " )
15
+ return test_functions
16
+
17
+
18
+ if __name__ == "__main__" :
19
+ import sys
20
+
21
+ tests_path = sys .argv [1 ]
22
+ test_functions = get_test_functions (Path (tests_path ))
23
+
24
+ # We split the test functions in 80 different lists because the maximum jobs
25
+ # that can be run on Github Workflows generated by the matrix syntax is 256.
26
+ # Since we run all tests on Linux, Windows and Mac OS the number of this list
27
+ # must be multiplied by 3. 80 * 3 == 240 so we're in the green.
28
+ TESTS_SPLIT = 80
29
+ cycle = itertools .cycle (range (TESTS_SPLIT ))
30
+ groups = [[] for _ in range (TESTS_SPLIT )]
31
+ for f in test_functions :
32
+ index = next (cycle )
33
+ groups [index ].append (f )
34
+
35
+ print (json .dumps ([" " .join (g ) for g in groups ]))
Original file line number Diff line number Diff line change @@ -57,33 +57,30 @@ jobs:
57
57
58
58
echo "::set-output name=result::$RESULT"
59
59
60
- test :
60
+ tests-collector :
61
+ runs-on : ubuntu-latest
61
62
needs : run-determination
62
63
if : needs.run-determination.outputs.result == 'true'
64
+ outputs :
65
+ tests-data : ${{ steps.collection.outputs.tests-data }}
66
+ steps :
67
+ - name : Checkout repository
68
+ uses : actions/checkout@v2
69
+
70
+ - name : Collect tests
71
+ id : collection
72
+ run : |
73
+ echo "::set-output name=tests-data::$(python .github/tools/get_integration_tests.py ./test/)"
63
74
75
+ test :
76
+ needs : tests-collector
64
77
strategy :
65
78
matrix :
66
79
operating-system :
67
80
- ubuntu-latest
68
81
- windows-latest
69
82
- macos-latest
70
- test-file :
71
- - test/test_board.py
72
- - test/test_cache.py
73
- - test/test_compile.py
74
- - test/test_completion.py
75
- - test/test_config.py
76
- - test/test_core.py
77
- - test/test_daemon.py
78
- - test/test_debug.py
79
- - test/test_lib.py
80
- - test/test_main.py
81
- - test/test_outdated.py
82
- - test/test_sketch.py
83
- - test/test_update.py
84
- - test/test_upgrade.py
85
- - test/test_upload_mock.py
86
- - test/test_upload.py
83
+ tests : ${{ fromJSON(needs.tests-collector.outputs.tests-data) }}
87
84
88
85
runs-on : ${{ matrix.operating-system }}
89
86
@@ -121,4 +118,4 @@ jobs:
121
118
run : task poetry:install-deps
122
119
123
120
- name : Run integration tests
124
- run : poetry run pytest ${{ matrix.test-file }}
121
+ run : poetry run pytest ${{ matrix.tests }}
You can’t perform that action at this time.
0 commit comments