Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion check_nightly_success/check-nightly-success/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,12 +38,18 @@ 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'
python shared-actions/check_nightly_success/check-nightly-success/check.py \
--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[@]}"
22 changes: 19 additions & 3 deletions check_nightly_success/check-nightly-success/check.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# 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."""

import argparse
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
Expand Down Expand Up @@ -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.

Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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,
),
)
6 changes: 6 additions & 0 deletions check_nightly_success/dispatch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 }}
Loading