def main()

in src/start_testbuilds.py [0:0]


def main():
    build_context = os.getenv("BUILD_CONTEXT")
    if build_context != "PR":
        LOGGER.info(f"Not triggering test jobs from boto3, as BUILD_CONTEXT is {build_context}")
        return

    if config.is_deep_canary_mode_enabled():
        run_deep_canary_pr_testbuilds()
        # Skip all other tests on this PR if deep_canary_mode is true
        # If deep_canary_mode is true, then all tests are skipped on build jobs incompatible with
        # Deep Canaries, as detailed in the docstring for run_deep_canary_pr_testbuilds().
        return

    # load the images for all test_types to pass on to code build jobs
    with open(constants.TEST_TYPE_IMAGES_PATH) as json_file:
        test_images = json.load(json_file)

    # Run necessary PR test jobs
    commit = os.getenv("CODEBUILD_RESOLVED_SOURCE_VERSION")

    for test_type, images in test_images.items():
        # only run the code build test jobs when the images are present
        LOGGER.debug(f"test_type : {test_type}")
        LOGGER.debug(f"images: {images}")
        if images:
            pr_test_job = f"dlc-pr-{test_type}-test"
            images_str = " ".join(images)

            # Maintaining separate codebuild projects for graviton/arm64 sanity and security tests
            if test_type == constants.SANITY_TESTS or test_type == constants.SECURITY_TESTS:
                if "graviton" in images_str:
                    pr_test_job += "-graviton"
                elif "arm64" in images_str:
                    pr_test_job += "-arm64"

            if is_test_job_enabled(test_type) and is_test_job_implemented_for_framework(
                images_str, test_type
            ):
                run_test_job(commit, pr_test_job, images_str)

            if test_type == "autopr" and config.is_autopatch_build_enabled(
                buildspec_path=config.get_buildspec_override()
                or os.getenv("FRAMEWORK_BUILDSPEC_FILE"),
            ):
                run_test_job(commit, f"dlc-pr-{test_type}", images_str)

            # Trigger sagemaker local test jobs when there are changes in sagemaker_tests
            if test_type == "sagemaker" and config.is_sm_local_test_enabled():
                test_job = f"dlc-pr-{test_type}-local-test"
                run_test_job(commit, test_job, images_str)