Skip to content

Commit

Permalink
Add a job_name property (#18)
Browse files Browse the repository at this point in the history
Store the original pipeline run name and add another property that gets
the job name from the property name.

* Add missing type hint
* Update default check mode labels
  Make the command to show in check mode by default rather than testing
  the skip tests code path.
  • Loading branch information
samdoran authored Nov 15, 2024
1 parent b2f448f commit bbe5db6
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions files/bin/deploy-iqe-cji.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ def __init__(
self.iqe_requirements = os.environ.get("IQE_REQUIREMENTS", "")
self.iqe_requirements_priority = os.environ.get("IQE_REQUIREMENTS_PRIORITY", "")
self.iqe_test_importance = os.environ.get("IQE_TEST_IMPORTANCE", "")
self.pipeline_run_name = os.environ.get("PIPELINE_RUN_NAME") or ""
self.selenium = os.environ.get("IQE_SELENIUM", "")

@cached_property
def pipeline_run_name(self) -> str:
"""Get the pipeline name from the pipeline run name
@property
def job_name(self) -> str:
"""Get the job name from the pipeline run name
Example:
koku-ci-5rxkp --> koku-ci
"""

return (os.environ.get("PIPELINE_RUN_NAME") or "").rsplit("-", 1)[0]
return self.pipeline_run_name.rsplit("-", 1)[0]

@cached_property
def build_number(self) -> str:
Expand All @@ -76,8 +76,7 @@ def build_url(self) -> str:
"""Create a build URL for the pipeline run"""

application = os.environ.get("APPLICATION")
pipeline_run_name = os.environ.get("PIPELINE_RUN_NAME")
return f"https://console.redhat.com/application-pipeline/workspaces/cost-mgmt-dev/applications/{application}/pipelineruns/{pipeline_run_name}"
return f"https://console.redhat.com/application-pipeline/workspaces/cost-mgmt-dev/applications/{application}/pipelineruns/{self.pipeline_run_name}"

@cached_property
def selenium_arg(self) -> list[str]:
Expand All @@ -89,7 +88,7 @@ def env(self) -> dict[str, str]:

@cached_property
def iqe_env_vars_arg(self) -> t.Iterable[str]:
job_name = f"JOB_NAME={self.pipeline_run_name}"
job_name = f"JOB_NAME={self.job_name}"
build_number = f"BUILD_NUMBER={self.build_number}"
build_url = f"BUILD_URL={self.build_url}"
env_var_params = [job_name, build_number, build_url]
Expand Down Expand Up @@ -143,7 +142,7 @@ def iqe_cji_timeout(self) -> int:
@cached_property
def pr_labels(self) -> set[str]:
if self.check:
return set(os.environ.get("PR_LABELS", "").split()) or {"hot-fix-smoke-tests", "bug"}
return set(os.environ.get("PR_LABELS", "").split()) or {"run-konflux-tests", "hot-fix-smoke-tests", "bug"}

return get_pr_labels(self.pr_number)

Expand Down Expand Up @@ -184,7 +183,7 @@ def run_pod(self) -> str:

return self.pod

def follow_logs(self):
def follow_logs(self) -> None:
oc.logs(self.pod, namespace=self.namespace, container=self.container, follow=True,
_out=sys.stdout,
_err=sys.stderr,
Expand Down

0 comments on commit bbe5db6

Please sign in to comment.