diff --git a/check_nightly_success/check-nightly-success/action.yaml b/check_nightly_success/check-nightly-success/action.yaml index 4c149b7a..a0315aff 100644 --- a/check_nightly_success/check-nightly-success/action.yaml +++ b/check_nightly_success/check-nightly-success/action.yaml @@ -22,6 +22,11 @@ inputs: description: "The number of consecutive days that may go by without a successful CI run" required: true type: integer + temp-extension-expires: + description: "Last day after which a temporary extension expires (YYYY-MM-DD)." + required: false + default: "" + type: string runs: using: composite @@ -33,7 +38,12 @@ runs: TARGET_BRANCH: ${{ inputs.target-branch }} WORKFLOW_ID: ${{ inputs.workflow-id }} MAX_DAYS_WITHOUT_SUCCESS: ${{ inputs.max-days-without-success }} + TEMP_EXTENSION_EXPIRES: ${{ inputs.temp-extension-expires }} run: | + temp_extension_args=() + if [[ -n "${TEMP_EXTENSION_EXPIRES}" ]]; then + temp_extension_args=(--temp-extension-expires "${TEMP_EXTENSION_EXPIRES}") + fi python -m pip install \ --prefer-binary \ 'requests>=2.32.4' @@ -41,4 +51,5 @@ runs: --repo ${REPO} \ --branch ${TARGET_BRANCH} \ --workflow-id ${WORKFLOW_ID} \ - --max-days-without-success ${MAX_DAYS_WITHOUT_SUCCESS} + --max-days-without-success ${MAX_DAYS_WITHOUT_SUCCESS} \ + "${temp_extension_args[@]}" diff --git a/check_nightly_success/check-nightly-success/check.py b/check_nightly_success/check-nightly-success/check.py index 41fd570d..819e21c5 100644 --- a/check_nightly_success/check-nightly-success/check.py +++ b/check_nightly_success/check-nightly-success/check.py @@ -1,4 +1,4 @@ -# Copyright (c) 2024-2026, NVIDIA CORPORATION. +# Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. """Check whether a GHA workflow has run successfully in the last N days.""" @@ -6,7 +6,7 @@ import os import sys from dataclasses import dataclass -from datetime import datetime, timedelta, timezone +from datetime import date, datetime, timedelta, timezone import requests from requests.adapters import HTTPAdapter @@ -155,6 +155,7 @@ def main( request_page_size: int, request_timeout_seconds: float, retry_backoff_seconds: float, + temp_extension_expires: date | None, ) -> int: """Check whether a GHA workflow has run successfully in the last N days. @@ -171,7 +172,14 @@ def main( # Dealing with day-precision date-times makes filtering in the GitHub API simpler, see # https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#query-for-dates # - oldest_date_to_pull = datetime.now(timezone.utc) - timedelta(days=max_days_without_success) + now = datetime.now(timezone.utc) + if temp_extension_expires is not None: + if now.date() <= temp_extension_expires: + print(f"There is a temporary extension until the end of {temp_extension_expires}.") + return ExitCode.SUCCESS + print(f"A temporary extension expired on {temp_extension_expires}.") + + oldest_date_to_pull = now - timedelta(days=max_days_without_success) # get all the matching runs client = GitHubClient( @@ -303,6 +311,13 @@ def main( required=False, help="Number of responses per page of data. Decrease this to reduce memory usage.", ) + parser.add_argument( + "--temp-extension-expires", + type=date.fromisoformat, + default=None, + required=False, + help="Last day after which a temporary extension expires (YYYY-MM-DD).", + ) args = parser.parse_args() sys.exit( @@ -315,5 +330,6 @@ def main( request_page_size=args.request_page_size, request_timeout_seconds=10, retry_backoff_seconds=0.5, + temp_extension_expires=args.temp_extension_expires, ), ) diff --git a/check_nightly_success/dispatch/action.yml b/check_nightly_success/dispatch/action.yml index 852c0c5d..61d24d05 100644 --- a/check_nightly_success/dispatch/action.yml +++ b/check_nightly_success/dispatch/action.yml @@ -21,6 +21,11 @@ inputs: required: false default: 7 type: integer + temp-extension-expires: + description: "Last day after which a temporary extension expires (YYYY-MM-DD)." + required: false + default: "" + type: string runs: using: 'composite' @@ -39,3 +44,4 @@ runs: target-branch: ${{ inputs.target-branch }} workflow-id: ${{ inputs.workflow-id }} max-days-without-success: ${{ inputs.max-days-without-success }} + temp-extension-expires: ${{ inputs.temp-extension-expires }}