forked from lowRISC/opentitan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[utils] Create a python scrip to digest the tesplan and output a csv
Signed-off-by: Douglas Reis <[email protected]>
- Loading branch information
Showing
3 changed files
with
709 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"repository" :"lowrisc/opentitan", | ||
"title": "[chip-test, ${ip_block}] ${test_name}", | ||
"body": ''' | ||
<%text> | ||
### Test point name | ||
</%text> | ||
${test_name} | ||
|
||
<%text> | ||
### Host side component | ||
Rust? | ||
|
||
### Opentitantool infrastructure implemented | ||
Yes | ||
|
||
### Silicon Validation (SiVal) | ||
|
||
Yes | ||
|
||
### Emulation targets | ||
- [ ] None | ||
- [ ] CW310 | ||
- [ ] Hyperdebug + CW310 | ||
|
||
### Contact person | ||
|
||
|
||
### Checklist | ||
Please fill out this checklist as items are completed. Link to PRs and issues as appropriate. | ||
- [ ] Check if existing test covers most or all of this testpoint (if so, either extend said test to cover all points, or skip the next 3 checkboxes) | ||
- [ ] Device-side (C) component developed | ||
- [ ] Bazel build rules developed | ||
- [ ] Host-side component developed | ||
- [ ] Test added to dvsim nightly regression (and passing at time of checking) | ||
- [ ] For SiVal test cases, test is running relevant FPGA or silicon regression | ||
</%text> | ||
''', | ||
"labels": ["SiVal:Autogen", "Component:ChipLevelTest", "IP:${ip_block}", "Priority:${priority}"], | ||
"milestone": "Earlgrey ES ${stage}", | ||
"assignee": "", | ||
} |
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,118 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright lowRISC contributors. | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
""" | ||
This script manages github issues. | ||
usage with a single file: | ||
./util/py/scripts/ | ||
""" | ||
|
||
import argparse | ||
import glob | ||
import json | ||
import logging | ||
import os | ||
import sys | ||
from enum import Enum | ||
|
||
import hjson | ||
from github import Auth, Github | ||
from github.GithubObject import NotSet, Opt | ||
from github.Label import Label | ||
from github.NamedUser import NamedUser | ||
from github.Repository import Repository | ||
from mako.template import Template | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--logging", | ||
default="info", | ||
choices=["debug", "info", "warning", "error", "critical"], | ||
help="Logging level", | ||
) | ||
parser.add_argument( | ||
"--token", | ||
required=True, | ||
help="""Token""", | ||
) | ||
parser.add_argument( | ||
"--template", | ||
required=True, | ||
help="""Template""", | ||
) | ||
|
||
|
||
def main(args): | ||
|
||
repo = hjson.load(open(args.template, "r"))["repository"] | ||
repo = GithubWrapper(args.token, repo) | ||
|
||
issue_template = Template(filename=args.template) | ||
new_issue = hjson.loads( | ||
issue_template.render(ip_block="aes", | ||
test_name="chip_kmac_smoketest", | ||
check_list=["PROD", "DEV", "PROD_END"], | ||
stage="SV1")) | ||
|
||
repo.load_issues(labels=new_issue["labels"]) | ||
|
||
if repo.issue_exist(new_issue["title"]): | ||
print(f"Issue already exists") | ||
repo_issue = repo.issues_by_title(new_issue["title"])[0] | ||
if repo_issue.body != new_issue["body"]: | ||
print("Updating the issue") | ||
repo_issue.edit(body=new_issue["body"], | ||
labels=new_issue["labels"], | ||
milestone=new_issue["milestone"]) | ||
else: | ||
print(f'Create issue{new_issue["title"]}') | ||
repo.create_issue(title=new_issue["title"], body=new_issue["body"],\ | ||
labels=new_issue["labels"], milestone=new_issue["milestone"]) | ||
|
||
|
||
class GithubWrapper(): | ||
|
||
def __init__(self, token, repo): | ||
auth = Auth.Token(token) | ||
self.gh = Github(auth=auth) | ||
self.repo = self.gh.get_repo(repo) | ||
self.milestones = self.repo.get_milestones() | ||
|
||
def load_issues(self, labels=NotSet, milestone=NotSet): | ||
self.issues = self.repo.get_issues(labels=labels, milestone=milestone) | ||
|
||
def issues_by_title(self, title): | ||
return list(filter(lambda ms: ms.title == title, self.issues)) | ||
|
||
def search_issues(self, text): | ||
return list(filter(lambda ms: text in (str(ms.title) + str(ms.body)), self.issues)) | ||
|
||
def issue_exist(self, title): | ||
return len(self.issues_by_title(title)) > 0 | ||
|
||
def get_milestone(self, name): | ||
res = list(filter(lambda ms: ms.title == name, self.milestones)) | ||
return res[0] if len(res) > 0 else NotSet | ||
|
||
def create_issue( | ||
self, | ||
title, | ||
body=NotSet, | ||
assignee=NotSet, | ||
milestone=NotSet, | ||
labels=NotSet, | ||
assignees=NotSet, | ||
): | ||
if milestone != NotSet: | ||
milestone = self.get_milestone(milestone) | ||
return self.repo.create_issue(title, body, assignee, milestone, labels, | ||
assignees) | ||
|
||
|
||
if __name__ == "__main__": | ||
args = parser.parse_args() | ||
logging.basicConfig(level=args.logging.upper()) | ||
sys.exit(main(args)) |
Oops, something went wrong.