From 09cf4c77240809458e48920727d5f796de987519 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Fri, 22 Aug 2025 11:10:41 +0200 Subject: [PATCH 1/3] Enabled `staging` build scenario --- scripts/release/build/build_scenario.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/release/build/build_scenario.py b/scripts/release/build/build_scenario.py index 2fb27e173..97fc8e507 100644 --- a/scripts/release/build/build_scenario.py +++ b/scripts/release/build/build_scenario.py @@ -31,10 +31,9 @@ def infer_scenario_from_environment(cls) -> "BuildScenario": elif is_patch or is_evg: scenario = BuildScenario.PATCH logger.info(f"Build scenario: {scenario} (patch_id: {patch_id})") - # TODO: Uncomment the following lines when starting to work on staging builds - # elif is_evg: - # scenario = BuildScenario.STAGING - # logger.info(f"Build scenario: {scenario} (patch_id: {patch_id})") + elif is_evg: + scenario = BuildScenario.STAGING + logger.info(f"Build scenario: {scenario} (patch_id: {patch_id})") else: scenario = BuildScenario.DEVELOPMENT logger.info(f"Build scenario: {scenario}") From dfbc3c10094a89dcd122ec87592da4d6337ed693 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Fri, 22 Aug 2025 16:35:42 +0200 Subject: [PATCH 2/3] Use correct way to figure out if we are in staging workflow --- scripts/release/build/build_scenario.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/release/build/build_scenario.py b/scripts/release/build/build_scenario.py index 97fc8e507..8fa8f010c 100644 --- a/scripts/release/build/build_scenario.py +++ b/scripts/release/build/build_scenario.py @@ -3,7 +3,8 @@ from git import Repo from lib.base_logger import logger -from scripts.release.constants import triggered_by_git_tag, is_evg_patch, is_running_in_evg, get_version_id +from scripts.release.constants import triggered_by_git_tag, is_evg_patch, is_running_in_evg, get_version_id, \ + DEFAULT_REPOSITORY_PATH from scripts.release.version import calculate_next_version COMMIT_SHA_LENGTH = 8 @@ -17,7 +18,7 @@ class BuildScenario(StrEnum): DEVELOPMENT = "development" # Local build on a developer machine @classmethod - def infer_scenario_from_environment(cls) -> "BuildScenario": + def infer_scenario_from_environment(cls, repository_path: str = DEFAULT_REPOSITORY_PATH) -> "BuildScenario": """Infer the build scenario from environment variables.""" git_tag = triggered_by_git_tag() is_patch = is_evg_patch() @@ -31,9 +32,9 @@ def infer_scenario_from_environment(cls) -> "BuildScenario": elif is_patch or is_evg: scenario = BuildScenario.PATCH logger.info(f"Build scenario: {scenario} (patch_id: {patch_id})") - elif is_evg: + elif is_evg and not is_patch: scenario = BuildScenario.STAGING - logger.info(f"Build scenario: {scenario} (patch_id: {patch_id})") + logger.info(f"Build scenario: {scenario} (version_id: {get_staging_version_id(repository_path)}") else: scenario = BuildScenario.DEVELOPMENT logger.info(f"Build scenario: {scenario}") @@ -55,7 +56,7 @@ def get_version(self, repository_path: str, changelog_sub_path: str, initial_com raise ValueError(f"version_id environment variable is not set for `{self}` build scenario") return patch_id case BuildScenario.STAGING: - return repo.head.object.hexsha[:COMMIT_SHA_LENGTH] + return get_staging_version_id(repository_path) case BuildScenario.RELEASE: return calculate_next_version(repo, changelog_sub_path, initial_commit_sha, initial_version) case BuildScenario.MANUAL_RELEASE: @@ -64,3 +65,8 @@ def get_version(self, repository_path: str, changelog_sub_path: str, initial_com return None raise ValueError(f"Unknown build scenario: {self}") + + +def get_staging_version_id(repository_path: str): + repo = Repo(repository_path) + return repo.head.object.hexsha[:COMMIT_SHA_LENGTH] From 8a7f53fa6f7699a6f33fd06b4392674c7748b2d4 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Fri, 22 Aug 2025 16:39:36 +0200 Subject: [PATCH 3/3] Correct conditionals --- scripts/release/build/build_scenario.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/release/build/build_scenario.py b/scripts/release/build/build_scenario.py index 8fa8f010c..5997e2cbe 100644 --- a/scripts/release/build/build_scenario.py +++ b/scripts/release/build/build_scenario.py @@ -29,12 +29,12 @@ def infer_scenario_from_environment(cls, repository_path: str = DEFAULT_REPOSITO # Release scenario and the git tag will be used for promotion process only scenario = BuildScenario.RELEASE logger.info(f"Build scenario: {scenario} (git_tag: {git_tag})") - elif is_patch or is_evg: - scenario = BuildScenario.PATCH - logger.info(f"Build scenario: {scenario} (patch_id: {patch_id})") elif is_evg and not is_patch: scenario = BuildScenario.STAGING logger.info(f"Build scenario: {scenario} (version_id: {get_staging_version_id(repository_path)}") + elif is_patch or is_evg: + scenario = BuildScenario.PATCH + logger.info(f"Build scenario: {scenario} (patch_id: {patch_id})") else: scenario = BuildScenario.DEVELOPMENT logger.info(f"Build scenario: {scenario}")