Skip to content

Commit

Permalink
refactor(tree-details-summary): alter response
Browse files Browse the repository at this point in the history
- Changed all fields to snake case
- Refactored the response structure

Part of #731
Part of #700
  • Loading branch information
murilx committed Jan 15, 2025
1 parent 1179171 commit 8d12fd6
Show file tree
Hide file tree
Showing 3 changed files with 296 additions and 298 deletions.
89 changes: 40 additions & 49 deletions backend/kernelCI_app/typeModels/treeDetails.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from datetime import datetime
from pydantic import BaseModel
from typing import List, Dict, Optional, Union
from typing import List, Dict, Optional, Set, Union


class TreeLatestPathParameters(BaseModel):
tree_name: str
branch: str


class StatusCount(BaseModel):
class TestStatusCount(BaseModel):
PASS: Optional[int] = None
ERROR: Optional[int] = None
FAIL: Optional[int] = None
Expand All @@ -19,34 +19,25 @@ class StatusCount(BaseModel):
class TestArchSummaryItem(BaseModel):
arch: str
compiler: str
status: StatusCount
status: TestStatusCount


class BuildsSummary(BaseModel):
class BuildStatusCount(BaseModel):
valid: int
invalid: int
null: int


class Configs(BaseModel):
class BuildConfigs(BuildStatusCount):
valid: int
invalid: int
null: int


class Architectures(BaseModel):
valid: int
invalid: int
null: int
class BuildArchitectures(BuildStatusCount):
compilers: List[str]


class BuildsSummaryDetails(BaseModel):
builds: BuildsSummary
configs: Dict[str, Configs]
architectures: Dict[str, Architectures]


class IncidentsInfo(BaseModel):
incidentsCount: int

Expand All @@ -58,18 +49,12 @@ class TestIssuesItem(BaseModel):
incidents_info: IncidentsInfo


class TestEnvironmentCompatibleCount(BaseModel):
FAIL: int
PASS: int
SKIP: int
class TestEnvironmentCompatibleCount(TestStatusCount):
pass


class TestEnvironmentMiscCount(BaseModel):
PASS: Optional[int] = None
FAIL: Optional[int] = None
ERROR: Optional[int] = None
NULL: Optional[int] = None
SKIP: Optional[int] = None
class TestEnvironmentMiscCount(TestStatusCount):
pass


class BuildsIssuesItem(BaseModel):
Expand All @@ -79,31 +64,37 @@ class BuildsIssuesItem(BaseModel):
incidents_info: IncidentsInfo


class TestSummary(BaseModel):
status: TestStatusCount
architectures: List[TestArchSummaryItem]
configs: Dict[str, TestStatusCount]
issues: List[TestIssuesItem]
unknown_issues: int
enviroment_compatible: Dict[str, TestEnvironmentCompatibleCount]
enviroment_misc: Dict[str, TestEnvironmentMiscCount]
fail_reasons: Dict[str, int]
failed_platforms: List[str]


class BuildSummary(BaseModel):
status: BuildStatusCount
architectures: Dict[str, BuildArchitectures]
configs: Dict[str, BuildConfigs]
issues: List[BuildsIssuesItem]
unknown_issues: int


class Summary(BaseModel):
builds: BuildSummary
boots: TestSummary
tests: TestSummary
hardware: Set[str]
tree_url: str
git_commit_tags: Optional[List[str]]


class SummaryResponse(BaseModel):
bootArchSummary: List
testArchSummary: List[TestArchSummaryItem]
buildsSummary: BuildsSummaryDetails
bootFailReasons: Dict
testFailReasons: Dict[str, int]
testPlatformsWithErrors: List[str]
bootPlatformsFailing: List
testConfigs: Dict[str, StatusCount]
bootConfigs: Dict
testStatusSummary: StatusCount
bootStatusSummary: Dict
bootIssues: List
testIssues: List[TestIssuesItem]
testEnvironmentCompatible: Dict[str, TestEnvironmentCompatibleCount]
bootEnvironmentCompatible: Dict
testEnvironmentMisc: Dict[str, TestEnvironmentMiscCount]
bootEnvironmentMisc: Dict
hardwareUsed: List[str]
failedTestsWithUnknownIssues: int
failedBootsWithUnknownIssues: int
buildsIssues: List[BuildsIssuesItem]
failedBuildsWithUnknownIssues: int
treeUrl: Optional[str]
git_commit_tags: Optional[List]
summary: Summary


class TestHistory(BaseModel):
Expand Down
58 changes: 34 additions & 24 deletions backend/kernelCI_app/views/treeDetailsSummaryView.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,30 +151,40 @@ def get(self, request, commit_hash: str | None):
self._sanitize_rows(rows)

response = {
"bootArchSummary": list(self.bootArchSummary.values()),
"testArchSummary": list(self.test_arch_summary.values()),
"buildsSummary": self.build_summary,
"bootFailReasons": self.bootFailReasons,
"testFailReasons": self.testFailReasons,
"testPlatformsWithErrors": list(self.testPlatformsWithErrors),
"bootPlatformsFailing": list(self.bootPlatformsFailing),
"testConfigs": self.test_configs,
"bootConfigs": self.bootConfigs,
"testStatusSummary": self.testStatusSummary,
"bootStatusSummary": self.bootStatusSummary,
"bootIssues": self.bootIssues,
"testIssues": self.testIssues,
"testEnvironmentCompatible": self.testEnvironmentCompatible,
"bootEnvironmentCompatible": self.bootEnvironmentCompatible,
"testEnvironmentMisc": self.testEnvironmentMisc,
"bootEnvironmentMisc": self.bootEnvironmentMisc,
"hardwareUsed": list(self.hardwareUsed),
"failedTestsWithUnknownIssues": self.failedTestsWithUnknownIssues,
"failedBootsWithUnknownIssues": self.failedBootsWithUnknownIssues,
"buildsIssues": self.build_issues,
"failedBuildsWithUnknownIssues": self.failed_builds_with_unknown_issues,
"treeUrl": self.tree_url,
"git_commit_tags": self.git_commit_tags,
"summary": {
"builds": {
"status": self.build_summary["builds"],
"architectures": self.build_summary["architectures"],
"configs": self.build_summary["configs"],
"issues": self.build_issues,
"unknown_issues": self.failed_builds_with_unknown_issues
},
"boots": {
"status": self.bootStatusSummary,
"architectures": list(self.bootArchSummary.values()),
"configs": self.bootConfigs,
"issues": self.bootIssues,
"unknown_issues": self.failedBootsWithUnknownIssues,
"enviroment_compatible": self.bootEnvironmentCompatible,
"enviroment_misc": self.bootEnvironmentMisc,
"fail_reasons": self.bootFailReasons,
"failed_platforms": list(self.bootPlatformsFailing),
},
"tests": {
"status": self.testStatusSummary,
"architectures": list(self.test_arch_summary.values()),
"configs": self.test_configs,
"issues": self.testIssues,
"unknown_issues": self.failedTestsWithUnknownIssues,
"enviroment_compatible": self.testEnvironmentCompatible,
"enviroment_misc": self.testEnvironmentMisc,
"fail_reasons": self.testFailReasons,
"failed_platforms": list(self.testPlatformsWithErrors),
},
"hardware": list(self.hardwareUsed),
"tree_url": self.tree_url,
"git_commit_tags": self.git_commit_tags,
}
}

try:
Expand Down
Loading

0 comments on commit 8d12fd6

Please sign in to comment.