aboutsummaryrefslogtreecommitdiffstats
path: root/csit.infra.dash/app
diff options
context:
space:
mode:
Diffstat (limited to 'csit.infra.dash/app')
-rw-r--r--csit.infra.dash/app/cdash/stats/layout.py14
-rw-r--r--csit.infra.dash/app/cdash/utils/utils.py46
2 files changed, 50 insertions, 10 deletions
diff --git a/csit.infra.dash/app/cdash/stats/layout.py b/csit.infra.dash/app/cdash/stats/layout.py
index 6f7031aedc..823e32659a 100644
--- a/csit.infra.dash/app/cdash/stats/layout.py
+++ b/csit.infra.dash/app/cdash/stats/layout.py
@@ -29,7 +29,8 @@ from yaml import load, FullLoader, YAMLError
from ..utils.constants import Constants as C
from ..utils.control_panel import ControlPanel
from ..utils.utils import show_tooltip, gen_new_url, get_ttypes, get_cadences, \
- get_test_beds, get_job, generate_options, set_job_params, navbar_trending
+ get_test_beds, get_job, generate_options, set_job_params, navbar_trending, \
+ get_url_job, get_url_logs
from ..utils.url_processing import url_decode
from .graphs import graph_statistics, select_data
@@ -197,7 +198,7 @@ class Layout:
"dd-tbeds-value": self._default["tbed"],
"al-job-children": html.A(
self._default["job"],
- href=f"{C.URL_CICD}{self._default['job']}",
+ href=get_url_job(self._default["job"]),
target="_blank"
)
}
@@ -631,10 +632,7 @@ class Layout:
"dd-tbeds-value": job_params["tbed"],
"al-job-children": html.A(
self._default["job"],
- href=(
- f"{C.URL_CICD}"
- f"{self._default['job']}"
- ),
+ href=get_url_job(self._default["job"]),
target="_blank"
)
},
@@ -655,7 +653,7 @@ class Layout:
{
"al-job-children": html.A(
job,
- href=f"{C.URL_CICD}{job}",
+ href=get_url_job(job),
target="_blank"
)
}
@@ -785,7 +783,7 @@ class Layout:
dbc.Badge(lst_itm[0]),
html.A(
lst_itm[1],
- href=f"{C.URL_LOGS}{lst_itm[1]}",
+ href=get_url_logs(lst_itm[1]),
target="_blank"
)
])
diff --git a/csit.infra.dash/app/cdash/utils/utils.py b/csit.infra.dash/app/cdash/utils/utils.py
index 27ecd1f763..62d4770937 100644
--- a/csit.infra.dash/app/cdash/utils/utils.py
+++ b/csit.infra.dash/app/cdash/utils/utils.py
@@ -721,7 +721,7 @@ def show_trending_graph_data(
dbc.Badge(lst_itm[0]),
html.A(
lst_itm[1],
- href=f"{C.URL_LOGS}{lst_itm[1]}",
+ href=get_url_logs(lst_itm[1]),
target="_blank"
)
])
@@ -853,7 +853,7 @@ def show_iterative_graph_data(
continue
list_group_item = dbc.ListGroupItem([
dbc.Badge(k),
- html.A(v, href=f"{C.URL_LOGS}{v}", target="_blank")
+ html.A(v, href=get_url_logs(v), target="_blank")
])
else:
list_group_item = dbc.ListGroupItem([dbc.Badge(k), v])
@@ -904,3 +904,45 @@ def show_iterative_graph_data(
]
return metadata, graph, True
+
+
+def get_url_job(job: str) -> str:
+ """Generates a URL to CI/CD job.
+
+ :param job: The name of job.
+ :type job: str
+ :raises KeyError: If the job name is not a valid job name.
+ :returns: The URL to CI/CD job.
+ """
+
+ if C.CICD_TYPE == "jenkins":
+ return f"{C.URL_CICD}{job}"
+ elif C.CICD_TYPE == "github":
+ l_j = job.split("-")
+ try:
+ return f"{C.URL_CICD}{l_j[0]}-{l_j[1]}-{l_j[2]}-{l_j[4]}.yml"
+ except KeyError:
+ return str()
+ else:
+ return str()
+
+
+def get_url_logs(job_build: str) -> str:
+ """Generates a URL to CI/CD job and its build.
+
+ :param job_build: The name of job and number of build. Its structure is:
+ "<job name>/<build number>".
+ :type job: str
+ :raises KeyError: If the job name is not a valid job name.
+ :returns: The URL to CI/CD build.
+ """
+
+ if C.CICD_TYPE == "jenkins":
+ return f"{C.URL_LOGS}{job_build}"
+ elif C.CICD_TYPE == "github":
+ try:
+ return f"{C.URL_LOGS}{job_build.split('/')[1]}"
+ except KeyError:
+ return str()
+ else:
+ return str()