-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_all.py
executable file
·55 lines (41 loc) · 1.52 KB
/
check_all.py
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
#!/usr/bin/env python3
from itertools import combinations
from os import system, environ
import argparse
def flatten(l):
return [
item for sublist in l
for item in sublist
]
def main():
is_ci = bool(environ.get("GITHUB_ACTIONS"))
p = argparse.ArgumentParser(description='Test all combinations of flags', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
p.add_argument('-d', '--do', action='store_true', help='actually run cargo check')
p.add_argument('-v', '--verbose', action='store_true', help='increase verbosity')
p.add_argument('-e', '--examples', action='store_true', help='run for examples')
p.add_argument('-n', '--nofail', action='store_true', help='Keep going on fail')
p.add_argument('crate', choices=['roblib', 'roblib-server', 'roblib-client'], help='The crate to test')
p.add_argument('features', nargs='+', help='The features to test')
config = p.parse_args()
feature_combinations = flatten([
combinations(config.features, i + 1)
for i in range(len(config.features))
]) + [()]
for (i, f) in enumerate(feature_combinations):
cmd = f'cargo clippy -p {config.crate}'
if len(f) != 0:
cmd += f' --features \'{" ".join(f)}\''
if config.examples:
cmd += ' --examples'
if is_ci:
print('##[group]', end='')
print(f'{i + 1}/{len(feature_combinations)} {cmd}', flush=True)
if config.do:
exit_code = system(cmd)
if exit_code != 0 and not config.nofail:
exit(1)
print('\n\n', flush=True)
if is_ci:
print('##[endgroup]', flush=True)
if __name__ == '__main__':
main()