Skip to content
Closed
Changes from 1 commit
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
7 changes: 3 additions & 4 deletions scripts/release/build/build_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can this work? Have we tested this? if is_evg is true, then its always patch already, no?

Copy link
Collaborator

@Julien-Ben Julien-Ben Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I wrote the infer method I matched our previous code for the usage of env variables. If is_patchis false but is_evg is true, then we are on master.
I'm confused by the above elif tho.
elif is_patch or is_evg seems incorrect

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we really need a way to test those things in the ci/e2e outside of requiring to merge to master

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Julien-Ben,
I was looking at the docs here https://docs.devprod.prod.corp.mongodb.com/evergreen/Reference/Comparison#whats-a-version-or-patch and here and it is not very clear that is_patch is going to be false if the build is run from the master merge. Do you have reference to a documentation that we can use to confirm that is_patch is false in case of builds to master merges.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to dig as much as I could in the documentation and commented everything in methods (they were moved to constants.py)

Do the following explanations help ? That's the best I could find

def triggered_by_git_tag() -> str | None:
    """
    "triggered_by_git_tag" is the name of the tag that triggered this version, if applicable. It will be None for
    all patches except when tagging a commit on GitHub
    :return: tag name if the build was triggered by a git tag, otherwise None.
    """
    return os.getenv("triggered_by_git_tag")


def is_evg_patch() -> bool:
    """
    A patch build is a version not triggered by a commit to a repository. "is_patch" is passed automatically by Evergreen.
    It either runs tasks on a base commit plus some diff if submitted by the CLI or on a git branch if created by
    a GitHub pull request.
    :return: "true" if the running task is in a patch build, otherwise "false".
    """
    return os.getenv("is_patch", "false").lower() == "true"


def is_running_in_evg() -> bool:
    """
    "RUNNING_IN_EVG" is set by us in evg-private-context
    :return: "true" if the script is running in Evergreen, otherwise "false".
    """
    return os.getenv("RUNNING_IN_EVG", "false").lower() == "true"


def get_version_id() -> str | None:
    """
    Get the version ID from the environment variable. This is typically used for patch builds in the Evergreen CI system.
    It is generated automatically for each task run. For example: `6899b7e35bfaee00077db986` for a manual/PR patch,
    or `mongodb_kubernetes_5c5a3accb47bb411682b8c67f225b61f7ad5a619` for a master merge
    :return: version_id (patch ID) or None if not set
    """
    return os.getenv("version_id")

scenario = BuildScenario.STAGING
logger.info(f"Build scenario: {scenario} (patch_id: {patch_id})")
else:
scenario = BuildScenario.DEVELOPMENT
logger.info(f"Build scenario: {scenario}")
Expand Down