Skip to content

Commit a0584bc

Browse files
committed
Adding tools/repeat_command.py, using in ci.yml
1 parent aac8681 commit a0584bc

File tree

2 files changed

+50
-11
lines changed

2 files changed

+50
-11
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109
run: cmake --build . -j 2
110110

111111
- name: Python tests C++11
112-
run: cmake --build . --target pytest -j 2
112+
run: python tools/repeat_command.py 100 cmake --build . --target pytest -j 2
113113

114114
- name: C++11 tests
115115
# TODO: Figure out how to load the DLL on Python 3.8+
@@ -137,7 +137,7 @@ jobs:
137137
run: cmake --build build2 -j 2
138138

139139
- name: Python tests
140-
run: cmake --build build2 --target pytest
140+
run: python tools/repeat_command.py 100 cmake --build build2 --target pytest
141141

142142
- name: C++ tests
143143
# TODO: Figure out how to load the DLL on Python 3.8+
@@ -176,7 +176,7 @@ jobs:
176176
include:
177177
- python-version: 3.9
178178
python-debug: true
179-
valgrind: true
179+
valgrind: false
180180
- python-version: 3.10-dev
181181
python-debug: false
182182

@@ -237,7 +237,7 @@ jobs:
237237
run: cmake --build build -j 2
238238

239239
- name: Python tests
240-
run: cmake --build build --target pytest
240+
run: python tools/repeat_command.py 100 cmake --build build --target pytest
241241

242242
- name: C++ tests
243243
run: cmake --build build --target cpptest
@@ -292,7 +292,7 @@ jobs:
292292
run: cmake --build build -j 2
293293

294294
- name: Python tests
295-
run: cmake --build build --target pytest
295+
run: python3 tools/repeat_command.py 100 cmake --build build --target pytest
296296

297297
- name: C++ tests
298298
run: cmake --build build --target cpptest
@@ -321,7 +321,7 @@ jobs:
321321
run: cmake --build build -j2 --verbose
322322

323323
- name: Python tests
324-
run: cmake --build build --target pytest
324+
run: python3 tools/repeat_command.py 100 cmake --build build --target pytest
325325

326326

327327
# TODO: Internal compiler error - report to NVidia
@@ -359,7 +359,7 @@ jobs:
359359
# run: cmake --build build -j 2 --verbose
360360
#
361361
# - name: Python tests
362-
# run: cmake --build build --target pytest
362+
# run: python3 tools/repeat_command.py 100 cmake --build build --target pytest
363363
#
364364
# - name: C++ tests
365365
# run: cmake --build build --target cpptest
@@ -460,7 +460,7 @@ jobs:
460460
run: cmake --build build -j 2
461461

462462
- name: Python tests
463-
run: cmake --build build --target pytest
463+
run: python3 tools/repeat_command.py 100 cmake --build build --target pytest
464464

465465
- name: C++ tests
466466
run: cmake --build build --target cpptest
@@ -617,7 +617,7 @@ jobs:
617617
run: cmake --build build -j 2
618618

619619
- name: Python tests
620-
run: cmake --build build --target pytest
620+
run: python3 tools/repeat_command.py 100 cmake --build build --target pytest
621621

622622
- name: C++ tests
623623
run: cmake --build build --target cpptest
@@ -653,6 +653,9 @@ jobs:
653653
- name: Copy tests to new directory
654654
run: cp -a tests /pybind11-tests
655655

656+
- name: Copy tools/repeat_command.py to /tmp
657+
run: cp -a tools/repeat_command.py /tmp
658+
656659
- name: Make a new test directory
657660
run: mkdir /build-tests
658661

@@ -665,7 +668,7 @@ jobs:
665668
working-directory: /build-tests
666669

667670
- name: Run tests
668-
run: make pytest -j 2
671+
run: python3 /tmp/repeat_command.py 100 make pytest -j 2
669672
working-directory: /build-tests
670673

671674

@@ -761,7 +764,7 @@ jobs:
761764
run: cmake --build build -j 2
762765

763766
- name: Run tests
764-
run: cmake --build build -t pytest
767+
run: python3 tools/repeat_command.py 100 cmake --build build -t pytest
765768

766769
win32-msvc2015:
767770
name: "🐍 ${{ matrix.python }} • MSVC 2015 • x64"

tools/repeat_command.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import absolute_import
4+
from __future__ import division
5+
from __future__ import print_function
6+
7+
import subprocess
8+
import sys
9+
10+
11+
def run(args):
12+
num_repeats = int(args[0])
13+
cmd_and_args = args[1:]
14+
assert num_repeats > 0
15+
assert cmd_and_args
16+
print("REPEAT_COMMAND:CMD_AND_ARGS", cmd_and_args)
17+
print()
18+
sys.stdout.flush()
19+
first_non_zero_retcode = 0
20+
for ix in range(num_repeats):
21+
print("REPEAT_COMMAND:CALL", ix + 1)
22+
sys.stdout.flush()
23+
retcode = subprocess.call(cmd_and_args)
24+
print("REPEAT_COMMAND:RETCODE", retcode)
25+
print()
26+
sys.stdout.flush()
27+
if retcode and not first_non_zero_retcode:
28+
first_non_zero_retcode = retcode
29+
print("REPEAT_COMMAND:FIRST_NON_ZERO_RETCODE", first_non_zero_retcode)
30+
print()
31+
sys.stdout.flush()
32+
return first_non_zero_retcode
33+
34+
35+
if __name__ == "__main__":
36+
sys.exit(run(args=sys.argv[1:]))

0 commit comments

Comments
 (0)