-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: kimpaller <kimchesed.paller@analog.com>
- Loading branch information
Showing
9 changed files
with
302 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
from github import Github, Auth, InputFileContent | ||
|
||
|
||
class Gist: | ||
def __init__(self, url=None, token=None): | ||
try: | ||
if not token: | ||
token=os.environ['GH_TOKEN'] | ||
except KeyError as ex: | ||
raise Exception("Github token not defined") | ||
|
||
try: | ||
if not url: | ||
url=os.environ['GH_URL'] | ||
except KeyError as ex: | ||
raise Exception("Github Gist url not defined") | ||
|
||
self.gh = Github(auth = Auth.Token(token)) | ||
self.gh_auth_user = self.gh.get_user() | ||
self.gh_url = url | ||
|
||
def create_gist(self, markdown_file, desc=""): | ||
|
||
markdown_str = "" | ||
with open(markdown_file, 'r') as f: | ||
markdown_str = f.read() | ||
|
||
# Create a Gist | ||
gist = self.gh_auth_user.create_gist( | ||
public=False, | ||
files={markdown_file: InputFileContent(markdown_str)}, | ||
description=desc | ||
) | ||
|
||
return gist.id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import os | ||
import re | ||
import telemetry | ||
from string import Template | ||
|
||
class Markdown: | ||
def __init__(self, file): | ||
self.filename = os.path.basename(file) | ||
with open(file,'r') as f: | ||
self.template_str = f.read() | ||
self.template = Template(self.template_str) | ||
|
||
def get_identifiers(self): | ||
return re.findall('\$(\w+)\s',self.template_str) | ||
|
||
def substitute(self, fields): | ||
return self.template.substitute(fields) | ||
|
||
def generate(self, fields, custom_file_name=None): | ||
formatted = self.substitute(fields) | ||
output = self.filename.split('.')[0] + ".md" | ||
if custom_file_name: | ||
output = custom_file_name | ||
with open(f"{os.path.join(output)}",'w') as f: | ||
f.write(formatted) | ||
return output | ||
|
||
class ResultsMarkdown(Markdown): | ||
CRITICAL = ["UpdateBOOTFiles"] | ||
|
||
def __init__(self, data): | ||
self.param_dict = self.generate_param(data) | ||
dir = os.path.dirname(os.path.realpath(__file__)) | ||
template_path = os.path.join(dir, "templates", "results.template.md") | ||
super(ResultsMarkdown, self).__init__(template_path) | ||
|
||
def generate_param(self,data): | ||
param_dict = {} | ||
for bn, info in data.items(): | ||
test_build_status = None | ||
if str(info["last_failing_stage"]) in self.CRITICAL: | ||
test_build_status = "FAILURE" | ||
elif int(info["drivers_missing"])>0 or\ | ||
int(info["dmesg_errors_found"])>0 or\ | ||
int(info["pytest_errors"])>0 or\ | ||
int(info["pytest_failures"])>0: | ||
test_build_status = "UNSTABLE" | ||
elif str(info["last_failing_stage"]) == "NA": | ||
test_build_status = "PASSING" | ||
else: | ||
test_build_status = "INVALID" | ||
|
||
uboot_reached_status = "✔" if bool(info["uboot_reached"]) else "❌" | ||
linux_prompt_reached_status = "✔" if bool(info["linux_prompt_reached"]) else "❌" | ||
drivers_enumerated_status = "✔" if int(info["drivers_missing"]) == 0 and test_build_status != "FAILURE" else "❌" | ||
dmesg_status = "✔" if int(info["dmesg_errors_found"]) == 0 and test_build_status != "FAILURE" else "❌" | ||
pytest_tests_status = "✔" if int(info["pytest_failures"]) == 0 and test_build_status != "FAILURE" else "❌" | ||
|
||
if test_build_status == "FAILURE": | ||
iio_drivers_missing_details = "No Details" | ||
iio_drivers_found_details = "No Details" | ||
dmesg_errors_found_details = "No Details" | ||
pytest_failures_details = "No Details" | ||
else: | ||
iio_drivers_missing_details = "No missing drivers" if len(info["missing_devs"]) == 0 else ("<br>").join(info["missing_devs"]) | ||
iio_drivers_found_details = "No iio drivers found" if len(info["enumerated_devs"]) == 0 else ("<br>").join(info["enumerated_devs"]) | ||
dmesg_errors_found_details = "No errors" if len(info["dmesg_err"]) == 0 else ("<br>").join(info["dmesg_err"]) | ||
pytest_failures_details = "No failures" if len(info["pytest_failure"]) == 0 else ("<br>").join(info["pytest_failure"]) | ||
|
||
last_failing_stage = str(info["last_failing_stage"]) | ||
last_failing_stage_failure = str(info["last_failing_stage_failure"]) | ||
|
||
param_dict[bn] = { | ||
"board_name" : bn, | ||
"branch": info["info_txt"]["BRANCH"], | ||
"pr_id": info["info_txt"]["PR_ID"], | ||
"timestamp": info["info_txt"]["TIMESTAMP"], | ||
"direction": info["info_txt"]["DIRECTION"], | ||
"triggered_by": info["info_txt"]["Triggered by"], | ||
"commit_sha": info["info_txt"]["COMMIT SHA"], | ||
"commit_date": info["info_txt"]["COMMIT_DATE"], | ||
"test_job_name": info["jenkins_project_name"], | ||
"test_build_number": info["jenkins_build_number"], | ||
"test_build_status": test_build_status, | ||
"uboot_reached_status": uboot_reached_status, | ||
"linux_prompt_reached_status": linux_prompt_reached_status, | ||
"drivers_enumerated_status": drivers_enumerated_status, | ||
"dmesg_status": dmesg_status, | ||
"pytest_tests_status": pytest_tests_status, | ||
"drivers_enumerated": "", | ||
"drivers_missing": "", | ||
"dmesg_warnings_found": "", | ||
"dmesg_errors_found": "", | ||
"pytest_tests": "", | ||
"pytest_errors": "", | ||
"pytest_failures": "", | ||
"pytest_skipped": "", | ||
"last_failing_stage": last_failing_stage if last_failing_stage != "NA" else "No Details", | ||
"last_failing_stage_failure":last_failing_stage_failure if last_failing_stage_failure != "NA" else "No Details", | ||
"iio_drivers_missing_details": iio_drivers_missing_details, | ||
"iio_drivers_found_details": iio_drivers_found_details, | ||
"dmesg_errors_found_details": dmesg_errors_found_details, | ||
"pytest_failures_details": pytest_failures_details, | ||
"test_status": test_build_status, | ||
} | ||
return param_dict | ||
|
||
def generate_gist(self): | ||
for bn,param in self.param_dict.items(): | ||
outfile = self.generate(param, bn+".md") | ||
gist = telemetry.gist.Gist() | ||
gist_link = gist.create_gist(outfile, f'''Boardname: {param["board_name"]}\n | ||
Branch: {param["branch"]}\nPR ID: {param["pr_id"]}\n | ||
timestamp: {param["timestamp"]}''') | ||
print(f'Gist created: {gist.gh_url}/{gist_link} - {param["test_status"]}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# $board_name | ||
|
||
## Build information | ||
|
||
``` | ||
Boot partition created with arguments: | ||
- BRANCH: $branch | ||
- PR_ID: $pr_id | ||
- TIMESTAMP: $timestamp | ||
- DIRECTION: $direction | ||
Triggered by: $triggered_by | ||
- COMMIT SHA: $commit_sha | ||
- COMMIT_DATE: $commit_date | ||
Test info | ||
- JOB NAME: $test_job_name | ||
- BUILD NO: $test_build_number | ||
- STATUS: $test_build_status | ||
``` | ||
|
||
## HW Test Result Summary | ||
|
||
| Stage | Result | | ||
| ----------- | ----------- | | ||
| U-Boot reached? | $uboot_reached_status | | ||
| Linux prompt reached? | $linux_prompt_reached_status | | ||
| IIO Drivers | $drivers_enumerated_status | | ||
| DMESG | $dmesg_status | | ||
| PYADI-IIO Tests | $pytest_tests_status | | ||
|
||
## HW Test Result Details | ||
|
||
#### Last Failing Stage | ||
|
||
- $last_failing_stage | ||
|
||
#### Last Failing Stage Failure | ||
|
||
- $last_failing_stage_failure | ||
|
||
#### Missing IIO Drivers | ||
|
||
- $iio_drivers_missing_details | ||
|
||
#### Found IIO Drivers | ||
|
||
- $iio_drivers_found_details | ||
|
||
#### DMESG Errors | ||
|
||
- $dmesg_errors_found_details | ||
|
||
#### PYADI-IIO tests Failures | ||
|
||
- $pytest_failures_details | ||
|
||
## Finished: $test_status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters