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/07/21 17:23:34 UTC

[airflow] 05/12: Retrieve airflow branch/constraints from env variables (#25053)

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 218711e601b840838a25df0b938cb05c62871292
Author: Jarek Potiuk <ja...@polidea.com>
AuthorDate: Tue Jul 19 14:38:02 2022 +0200

    Retrieve airflow branch/constraints from env variables (#25053)
    
    We are using the "main" breeze to build even v2-3 images and
    it has to retrieve the branch and constraints not from the
    Python constants but from environment variables that are
    set by build-image.yaml. Otherwise "main" is used to push/pull
    image and constraints.
    
    This pr changes the retrieval in build image to retrieve
    branch, constraints branch (and debian version) from env
    variables if they are set.
    
    (cherry picked from commit f36f81efc48fb5af3e86597068c7bf9b4a419251)
---
 dev/breeze/src/airflow_breeze/commands/ci_commands.py       | 7 +++++++
 dev/breeze/src/airflow_breeze/params/build_ci_params.py     | 7 +++++--
 dev/breeze/src/airflow_breeze/params/build_prod_params.py   | 5 ++++-
 dev/breeze/src/airflow_breeze/params/common_build_params.py | 4 ++--
 images/breeze/output-commands-hash.txt                      | 2 +-
 5 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/dev/breeze/src/airflow_breeze/commands/ci_commands.py b/dev/breeze/src/airflow_breeze/commands/ci_commands.py
index cd9d05fa49..9d4dda4297 100644
--- a/dev/breeze/src/airflow_breeze/commands/ci_commands.py
+++ b/dev/breeze/src/airflow_breeze/commands/ci_commands.py
@@ -263,6 +263,13 @@ def get_changed_files(commit_ref: Optional[str], dry_run: bool, verbose: bool) -
     envvar="DEFAULT_CONSTRAINTS_BRANCH",
     show_default=True,
 )
+@click.option(
+    '--default-constraints-branch',
+    help="Constraints Branch against which the PR should be run",
+    default="constraints-main",
+    envvar="DEFAULT_CONSTRAINTS_BRANCH",
+    show_default=True,
+)
 @click.option(
     '--github-event-name',
     type=BetterChoice(github_events()),
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 52c242b65a..ee63033ef6 100644
--- a/dev/breeze/src/airflow_breeze/params/build_ci_params.py
+++ b/dev/breeze/src/airflow_breeze/params/build_ci_params.py
@@ -14,6 +14,7 @@
 # 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
@@ -31,8 +32,10 @@ class BuildCiParams(CommonBuildParams):
     """
 
     airflow_constraints_mode: str = "constraints-source-providers"
-    default_constraints_branch: str = DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
-    airflow_constraints_reference: str = DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
+    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
     force_build: bool = False
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 65e92400c4..86a25b6999 100644
--- a/dev/breeze/src/airflow_breeze/params/build_prod_params.py
+++ b/dev/breeze/src/airflow_breeze/params/build_prod_params.py
@@ -16,6 +16,7 @@
 # under the License.
 
 import json
+import os
 import re
 import sys
 from dataclasses import dataclass
@@ -41,7 +42,9 @@ class BuildProdParams(CommonBuildParams):
     """
 
     airflow_constraints_mode: str = "constraints"
-    default_constraints_branch: str = DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
+    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 e6c2c70029..b4fc12e273 100644
--- a/dev/breeze/src/airflow_breeze/params/common_build_params.py
+++ b/dev/breeze/src/airflow_breeze/params/common_build_params.py
@@ -41,13 +41,13 @@ class CommonBuildParams:
     additional_runtime_apt_command: str = ""
     additional_runtime_apt_deps: str = ""
     additional_runtime_apt_env: str = ""
-    airflow_branch: str = AIRFLOW_BRANCH
+    airflow_branch: str = os.environ.get('DEFAULT_BRANCH', AIRFLOW_BRANCH)
     airflow_constraints_location: str = ""
     answer: Optional[str] = None
     build_id: int = 0
     builder: str = "default"
     constraints_github_repository: str = "apache/airflow"
-    debian_version: str = "bullseye"
+    debian_version: str = os.environ.get('DEBIAN_VERSION', "bullseye")
     dev_apt_command: str = ""
     dev_apt_deps: str = ""
     docker_cache: str = "registry"
diff --git a/images/breeze/output-commands-hash.txt b/images/breeze/output-commands-hash.txt
index 774cb26c3f..df2aa32c0a 100644
--- a/images/breeze/output-commands-hash.txt
+++ b/images/breeze/output-commands-hash.txt
@@ -23,7 +23,7 @@ pull-prod-image:6e8467a2b8c833a392c8bdd65189363e
 regenerate-command-images:4fd2e7ecbfd6eebb18b854f3eb0f29c8
 release-prod-images:8858fe5a13989c7c65a79dc97a880928
 resource-check:0fb929ac3496dbbe97acfe99e35accd7
-selective-check:4be1ea17278fba654761531be0e3811a
+selective-check:46db58b67a3441d39a62ae23c1082f09
 self-upgrade:b5437c0a1a91533a11ee9d0a9692369c
 setup-autocomplete:355b72dee171c2fcba46fc90ac7c97b0
 shell:ab7955da71048b3a695485c152d06786