This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
squad-list-failures
executable file
·103 lines (81 loc) · 2.62 KB
/
squad-list-failures
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env python3
import argparse
import json
import logging
import sys
from squad_client.core.api import SquadApi
from squad_client.core.models import ALL, Squad
from squad_client.utils import getid
SquadApi.configure(cache=3600, url="https://qa-reports.linaro.org/")
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def arg_parser():
parser = argparse.ArgumentParser(description="List all results for a squad build")
parser.add_argument(
"--group",
required=True,
help="squad group",
)
parser.add_argument(
"--project",
required=True,
help="squad project",
)
parser.add_argument(
"--build",
required=True,
help="squad build",
)
return parser
def run():
args = arg_parser().parse_args()
group = Squad().group(args.group)
if group is None:
logger.error(f"Get group failed. Group not found: '{args.group}'.")
return -1
project = group.project(args.project)
if project is None:
logger.error(f"Get project failed. Project not found: '{args.project}'.")
return -1
build = project.build(args.build)
if build is None:
logger.error(f"Get build failed. Build not found: '{args.build}'.")
return -1
environments = project.environments(count=ALL, ordering="slug").values()
if not environments:
logger.error("Get environments failed. No environments found.")
return -1
suites = project.suites(count=ALL, ordering="slug").values()
if not suites:
logger.error("Get suites failed. No suites found.")
return -1
# https://qa-reports.linaro.org/api/tests/
filters = {
"has_known_issues": False,
"result": False,
}
tests = build.tests(count=ALL, **filters).values()
if not tests:
logger.error("Get tests failed. No tests found.")
return -1
flat = []
for test in tests:
# StopIteration
environment = next(e for e in environments if e.id == getid(test.environment))
# StopIteration
suite = next(s for s in suites if s.id == getid(test.suite))
flat.append(
{
"group": group.slug,
"project": project.slug,
"build": build.version,
"environment": environment.slug,
"suite": suite.slug,
"test": test.short_name,
"status": test.status,
"has_known_issues": test.has_known_issues,
}
)
print(json.dumps(flat, indent=2))
if __name__ == "__main__":
sys.exit(run())