Skip to content

Commit

Permalink
Merge pull request #179 from adobes1/latest-nightly-status
Browse files Browse the repository at this point in the history
ART-6684 Get latest nightly status
  • Loading branch information
Ximinhan authored Apr 29, 2024
2 parents f1f4460 + 1b30c6e commit df5d9eb
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions artbotlib/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def show_help(so):
_*ART release/Brew monitoring:*_
* Watch `release_url|brew_url|prow_job_url|github_pr_url`
* Alert (if|when|on) `release_url` (stops being blue|fails|is rejected|is red|is accepted|is green)
* Watch latest `major.minor`
* Alert (if|when|on) prow job `Prow job URL` completes
* Alert (if|when|on) build `Brew build URL|Brew build ID` completes
* Alert (if|when|on) task `Brew task URL|Brew task ID` completes
Expand Down
34 changes: 34 additions & 0 deletions artbotlib/nightly_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,40 @@ def get_failed_jobs(release_url, release_browser) -> str:
return payload


def get_latest_nightly_name(release_stream) -> Union[str, None]:
url = f"https://amd64.ocp.releases.ci.openshift.org/api/v1/releasestream/{release_stream}/tags"
logger.info('Fetching URL %s', url)

response = requests.get(url) # query API to get list of nightly tags
if response.status_code != 200:
logger.error('Server responded with status code %s', response.status_code)
return None

return response.json()['tags'][0]['name']


def latest_nightly_color_status(so, user_id, version) -> None:
"""
Driver function to provide slack update if color of the latest nightly changes from blue to green/red
:param so: Slack object
:param user_id: User ID of the person who invoked ART-Bot
:param version: OCP version eg: 4.15/4.16
:return: None
"""

release_stream = f"{version}.0-0.nightly"

latest_nightly_name = get_latest_nightly_name(release_stream)
if latest_nightly_name is None:
so.say(f"<@{user_id}> I could not retrieve latest nightlies from https://amd64.ocp.releases.ci.openshift.org/api/v1/releasestream/{release_stream}/tags")
return

latest_release_url = f"/releasestream/{release_stream}/release/{latest_nightly_name}"

nightly_color_status(so, user_id, latest_release_url, "amd64")


def nightly_color_status(so, user_id, release_url, release_browser) -> None:
"""
Driver function to provide slack update if color of nightly changes from blue to green/red
Expand Down
9 changes: 8 additions & 1 deletion artbotlib/regex_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from artbotlib.constants import PROW_BASE_URL
from artbotlib.help import greet_user, show_help
from artbotlib.kernel_info import kernel_info
from artbotlib.nightly_color import nightly_color_status
from artbotlib.nightly_color import nightly_color_status, latest_nightly_color_status
from artbotlib.pipeline_image_names import pipeline_from_github, pipeline_from_distgit, pipeline_from_brew, \
pipeline_from_cdn, pipeline_from_delivery
from artbotlib.pr_in_build import pr_info
Expand Down Expand Up @@ -307,6 +307,13 @@ def map_command_to_regex(so, plain_text, user_id):
"user_id": True,
"example": "Watch https://amd64.ocp.releases.ci.openshift.org/releasestream/4.13.0-0.ci/release/4.13.0-0.ci-2022-12-19-111818"
},
{
"regex": r"^Watch latest (?P<version>\d+\.\d+)$",
"flag": re.I,
"function": latest_nightly_color_status,
"user_id": True,
"example": "Watch latest 4.16"
},
{
"regex": rf"^Alert ?(if|when|on)? prow job {PROW_BASE_URL}/view/gs/(?P<job_path>\S*) completes$",
"flag": re.I,
Expand Down

0 comments on commit df5d9eb

Please sign in to comment.