You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2022/08/05 15:05:26 UTC

[airflow] 01/04: Coorect branch used for non-main builds (#25545)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v2-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 37186bbb9074f0f68d8bba3be7cdcea64bd66ff5
Author: Jarek Potiuk <ja...@polidea.com>
AuthorDate: Fri Aug 5 00:17:16 2022 +0200

    Coorect branch used for non-main builds (#25545)
    
    Shell parameters should determine the branch based on environment
    variables so that main version of Breeze can properly build images
    in build-images.yml workflow.
    
    While CI/PROD params were ok, Shell Param was always using main
    and this failed PRs to v2-3-stable/test.
    
    This PR unifies branch selection to use env variables (which are
    properly set in CI).
    
    (cherry picked from commit 85e3b3534e7af21ab4b53c2e5f9ee546eb34dfef)
---
 dev/breeze/src/airflow_breeze/params/build_ci_params.py     | 5 -----
 dev/breeze/src/airflow_breeze/params/build_prod_params.py   | 6 +-----
 dev/breeze/src/airflow_breeze/params/common_build_params.py | 5 ++++-
 dev/breeze/src/airflow_breeze/params/shell_params.py        | 6 ++++--
 4 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/dev/breeze/src/airflow_breeze/params/build_ci_params.py b/dev/breeze/src/airflow_breeze/params/build_ci_params.py
index b6571c4c9a..c5c9382811 100644
--- a/dev/breeze/src/airflow_breeze/params/build_ci_params.py
+++ b/dev/breeze/src/airflow_breeze/params/build_ci_params.py
@@ -14,12 +14,10 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-import os
 from dataclasses import dataclass
 from pathlib import Path
 from typing import List
 
-from airflow_breeze.branch_defaults import DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
 from airflow_breeze.global_constants import get_airflow_version
 from airflow_breeze.params.common_build_params import CommonBuildParams
 from airflow_breeze.utils.path_utils import BUILD_CACHE_DIR
@@ -32,9 +30,6 @@ class BuildCiParams(CommonBuildParams):
     """
 
     airflow_constraints_mode: str = "constraints-source-providers"
-    default_constraints_branch: str = os.environ.get(
-        'DEFAULT_CONSTRAINTS_BRANCH', DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
-    )
     airflow_constraints_reference: str = ""
     airflow_extras: str = "devel_ci"
     airflow_pre_cached_pip_packages: bool = True
diff --git a/dev/breeze/src/airflow_breeze/params/build_prod_params.py b/dev/breeze/src/airflow_breeze/params/build_prod_params.py
index a8a3d04821..fd33396c51 100644
--- a/dev/breeze/src/airflow_breeze/params/build_prod_params.py
+++ b/dev/breeze/src/airflow_breeze/params/build_prod_params.py
@@ -16,13 +16,12 @@
 # under the License.
 
 import json
-import os
 import re
 import sys
 from dataclasses import dataclass
 from typing import List
 
-from airflow_breeze.branch_defaults import AIRFLOW_BRANCH, DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
+from airflow_breeze.branch_defaults import AIRFLOW_BRANCH
 from airflow_breeze.global_constants import (
     AIRFLOW_SOURCES_FROM,
     AIRFLOW_SOURCES_TO,
@@ -40,9 +39,6 @@ class BuildProdParams(CommonBuildParams):
     """
 
     airflow_constraints_mode: str = "constraints"
-    default_constraints_branch: str = os.environ.get(
-        'DEFAULT_CONSTRAINTS_BRANCH', DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
-    )
     airflow_constraints_reference: str = ""
     cleanup_context: bool = False
     disable_airflow_repo_cache: bool = False
diff --git a/dev/breeze/src/airflow_breeze/params/common_build_params.py b/dev/breeze/src/airflow_breeze/params/common_build_params.py
index 320c9289c4..9453dd27b8 100644
--- a/dev/breeze/src/airflow_breeze/params/common_build_params.py
+++ b/dev/breeze/src/airflow_breeze/params/common_build_params.py
@@ -21,7 +21,7 @@ from dataclasses import dataclass
 from datetime import datetime
 from typing import List, Optional
 
-from airflow_breeze.branch_defaults import AIRFLOW_BRANCH
+from airflow_breeze.branch_defaults import AIRFLOW_BRANCH, DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
 from airflow_breeze.global_constants import DOCKER_DEFAULT_PLATFORM
 from airflow_breeze.utils.console import get_console
 from airflow_breeze.utils.platforms import get_real_platform
@@ -43,6 +43,9 @@ class CommonBuildParams:
     additional_runtime_apt_env: str = ""
     additional_pip_install_flags: str = ""
     airflow_branch: str = os.environ.get('DEFAULT_BRANCH', AIRFLOW_BRANCH)
+    default_constraints_branch: str = os.environ.get(
+        'DEFAULT_CONSTRAINTS_BRANCH', DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
+    )
     airflow_constraints_location: str = ""
     answer: Optional[str] = None
     build_id: int = 0
diff --git a/dev/breeze/src/airflow_breeze/params/shell_params.py b/dev/breeze/src/airflow_breeze/params/shell_params.py
index b4c1e73f5a..bd7e6d356d 100644
--- a/dev/breeze/src/airflow_breeze/params/shell_params.py
+++ b/dev/breeze/src/airflow_breeze/params/shell_params.py
@@ -49,8 +49,10 @@ class ShellParams:
     Shell parameters. Those parameters are used to determine command issued to run shell command.
     """
 
-    airflow_branch: str = AIRFLOW_BRANCH
-    default_constraints_branch: str = DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
+    airflow_branch: str = os.environ.get('DEFAULT_BRANCH', AIRFLOW_BRANCH)
+    default_constraints_branch: str = os.environ.get(
+        'DEFAULT_CONSTRAINTS_BRANCH', DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
+    )
     airflow_constraints_reference: str = DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
     airflow_extras: str = ""
     answer: Optional[str] = None