Skip to content

Commit 75969ec

Browse files
ADD: outstanding issues report (#68)
* add coverity installation script * add Outstanding issues report * add Outstanding issues report * run ruff formatter * remove unnecessary files * Update .github/coverity/api/api.py Co-authored-by: Mateusz Grabuszyński <[email protected]> * Update .github/coverity/api/api.py Co-authored-by: Mateusz Grabuszyński <[email protected]> * Update .github/coverity/api/api.py Co-authored-by: Mateusz Grabuszyński <[email protected]> * Update .github/workflows/coverity_reports.yml Co-authored-by: Mateusz Grabuszyński <[email protected]> --------- Co-authored-by: Mateusz Grabuszyński <[email protected]>
1 parent 51a582e commit 75969ec

File tree

4 files changed

+52
-7
lines changed

4 files changed

+52
-7
lines changed

.github/coverity/api/api.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,20 @@ def prepare_query() -> dict:
3232
TOKEN = os.getenv("COVERITY_TOKEN", default=None)
3333
PROJECT_NAME = os.getenv("COVERITY_PROJECT_NAME", default=None)
3434
USER = os.getenv("COVERITY_USER", default=None)
35+
OUTSTANDING_VIEW_ID = os.getenv("COVERITY_OUTSTANDING_VIEW_ID", default=None)
36+
PROJECT_ID = os.getenv("COVERITY_PROJECT_ID", default=None)
3537

36-
if None in [BASE_URL, TOKEN, PROJECT_NAME, USER]:
38+
if None in [BASE_URL, TOKEN, PROJECT_NAME, USER, OUTSTANDING_VIEW_ID, PROJECT_ID]:
3739
log.error("Environment variables not set")
3840
log.error(
39-
"Please set the following environment variables: COVERITY_BASE_URL, COVERITY_TOKEN, COVERITY_PROJECT_NAME, COVERITY_USER"
41+
"Please set the following environment variables: COVERITY_BASE_URL, COVERITY_TOKEN, COVERITY_PROJECT_NAME, COVERITY_USER, OUTSTANDING_VIEW_ID, COVERITY_PROJECT_ID"
4042
)
4143
return {}
4244
return {
4345
"base_url": BASE_URL,
4446
"project_name": PROJECT_NAME,
47+
"project_id": PROJECT_ID,
48+
"outstanding_view_id": OUTSTANDING_VIEW_ID,
4549
"password": TOKEN,
4650
"user": USER,
4751
"stream": PROJECT_NAME,
@@ -59,6 +63,38 @@ def prepare_query() -> dict:
5963
}
6064

6165

66+
def fetch_outstanding_view_issues(config: dict) -> dict:
67+
"""
68+
Fetch issues from a specific view based on the provided view ID.
69+
70+
Args:
71+
config (dict): Configuration dictionary containing 'base_url', 'view_id, 'user', and 'password'.
72+
view_id (int): The ID of the view to fetch issues from.
73+
74+
Returns:
75+
dict: A dictionary containing the list of issues for the view.
76+
"""
77+
endpoint = (
78+
f"{config['base_url']}/api/v2/views/viewContents/{config['outstanding_view_id']}"
79+
)
80+
issues = {}
81+
try:
82+
response = requests.get(
83+
endpoint,
84+
params={"projectId": config["project_id"]},
85+
auth=HTTPBasicAuth(config["user"], config["password"]),
86+
)
87+
response.raise_for_status()
88+
issues = response.json()
89+
90+
except requests.exceptions.HTTPError as http_err:
91+
logging.error(f"HTTP error occurred: {http_err}")
92+
except Exception as err:
93+
logging.error(f"An error occurred: {err}")
94+
finally:
95+
return issues
96+
97+
6298
def get_snapshot(config: dict, description: str, version: str) -> int:
6399
"""
64100
Retrieve a snapshot ID based on the provided description and version.
@@ -75,7 +111,7 @@ def get_snapshot(config: dict, description: str, version: str) -> int:
75111
raw = get_snapshots_list(config)
76112
ids = list(map(lambda s: s["id"], raw["snapshotsForStream"]))
77113
snapshot_id = 0
78-
#TODO: replace with threads
114+
# TODO: replace with threads
79115
for id in ids:
80116
res = requests.get(
81117
f"{search_query_url}/{id}",

.github/coverity/api/parser.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ def issues_to_pandas(raw_response_data: dict) -> pd.DataFrame:
1818
converted_dict = {item["key"]: item["value"] for item in row}
1919
converted_response.append(converted_dict)
2020
df = pd.DataFrame(converted_response)
21-
22-
impact_order = ["High", "Medium", "Low"]
23-
df["displayImpact"] = pd.Categorical(df["displayImpact"], categories=impact_order)
24-
df = df.sort_values(by="displayImpact")
21+
if "displayImpact" in df.columns:
22+
impact_order = ["High", "Medium", "Low"]
23+
df["displayImpact"] = pd.Categorical(
24+
df["displayImpact"], categories=impact_order
25+
)
26+
df = df.sort_values(by="displayImpact")
2527
# remove abs path from displayFile
2628
df["displayFile"] = df["displayFile"].str.replace(r".*/_work/", "", regex=True)
2729
return df

.github/coverity/report.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ def main():
3939
df_launcher = api.filter_launcher_issues(df)
4040
df_grpc.to_csv("grpc_report.csv", index=False)
4141
df_launcher.to_csv("launcher_report.csv", index=False)
42+
43+
log.info("fetching outstanding view issues")
44+
outstanding_issues = api.fetch_outstanding_view_issues(query)
45+
df_outstanding = api.issues_to_pandas(outstanding_issues)
46+
df_outstanding.to_csv("outstanding_issues.csv", index=False)
4247
log.info("Reports generated")
4348

4449

.github/workflows/coverity_reports.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
COVERITY_TOKEN: ${{ secrets.COVERITY_REPORTS_TOKEN }}
3232
COVERITY_PROJECT_NAME: 'Intel-Tiber-Broadcast-Suite'
3333
COVERITY_USER: ${{ secrets.COVERITY_REPORTS_USER }}
34+
COVERITY_OUTSTANDING_VIEW_ID: ${{ secrets.COVERITY_OUTSTANDING_VIEW_ID }}
35+
COVERITY_PROJECT_ID: ${{ secrets.COVERITY_PROJECT_ID }}
3436

3537
- name: prepare artifacts
3638
if: success()

0 commit comments

Comments
 (0)