Skip to content
Merged
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
5 changes: 5 additions & 0 deletions dev/breeze/src/airflow_breeze/commands/workflow_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ def workflow_run_publish(
airflow_base_version: str | None = None,
apply_commits: str | None = None,
):
if len(doc_packages) == 0:
get_console().print(
"[red]Error: No doc packages provided. Please provide at least one doc package.[/red]",
)
sys.exit(1)
if os.environ.get("GITHUB_TOKEN", ""):
get_console().print("\n[warning]Your authentication will use GITHUB_TOKEN environment variable.")
get_console().print(
Expand Down
1 change: 1 addition & 0 deletions dev/breeze/src/airflow_breeze/global_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ def generate_provider_dependencies_if_needed():

MIN_DOCKER_VERSION = "24.0.0"
MIN_DOCKER_COMPOSE_VERSION = "2.20.2"
MIN_GH_VERSION = "2.70.0"

AIRFLOW_SOURCES_FROM = "."
AIRFLOW_SOURCES_TO = "/opt/airflow"
Expand Down
21 changes: 21 additions & 0 deletions dev/breeze/src/airflow_breeze/utils/gh_workflow_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
from __future__ import annotations

import json
import re
import subprocess
import sys
import time
from shutil import which

from airflow_breeze.global_constants import MIN_GH_VERSION
from airflow_breeze.utils.console import get_console
from airflow_breeze.utils.run_utils import run_command

Expand Down Expand Up @@ -63,6 +66,23 @@ def make_sure_gh_is_installed():
"run `gh auth login` to connect your repo to GitHub."
)
sys.exit(1)
version_string = subprocess.check_output(["gh", "version"]).decode("utf-8")
match = re.search(r"gh version (\d+\.\d+\.\d+)", version_string)
if match:
version = match.group(1)
from packaging.version import Version

if Version(version) < Version(MIN_GH_VERSION):
get_console().print(
f"[red]Error! The `gh` tool version is too old. "
f"Please upgrade to at least version {MIN_GH_VERSION}[/]"
)
sys.exit(1)
else:
get_console().print(
"[red]Error! Could not determine the version of the `gh` tool. Please ensure it is installed correctly.[/]"
)
sys.exit(1)


def get_workflow_run_id(workflow_name: str, repo: str) -> int:
Expand Down Expand Up @@ -178,6 +198,7 @@ def monitor_workflow_run(run_id: str, repo: str):
def trigger_workflow_and_monitor(
workflow_name: str, repo: str, branch: str = "main", monitor=True, **workflow_fields
):
make_sure_gh_is_installed()
tigger_workflow(
workflow_name=workflow_name,
repo=repo,
Expand Down
Loading