def build_image_checks(verbose: bool, shell_params: ShellBuilder): fix_group_permissions() build_ci_image_check_cache = Path(BUILD_CACHE_DIR, shell_params.airflow_branch, f".built_{shell_params.python_version}") if build_ci_image_check_cache.exists(): console.print( f'{shell_params.the_image_type} image already built locally.') else: console.print(f'{shell_params.the_image_type} image not built locally') if not shell_params.force_build: build_image_if_needed_steps(verbose, shell_params) else: build_image( verbose, python_version=shell_params.python_version, upgrade_to_newer_dependencies="false", ) instruct_for_setup() check_docker_resources(verbose, str(shell_params.airflow_sources), shell_params.airflow_ci_image_name) cmd = ['docker-compose', 'run', '--service-ports', '--rm', 'airflow'] cmd_added = shell_params.command_passed env_variables = construct_env_variables_docker_compose_command( shell_params) if cmd_added is not None: cmd.extend(['-c', cmd_added]) if verbose: shell_params.print_badge_info() output = run_command(cmd, verbose=verbose, env=env_variables, text=True) if verbose: console.print(f"[blue]{output}[/]")
def build_docs(verbose: bool, dry_run: bool, docs_only: bool, spellcheck_only: bool, package_filter: Tuple[str]): """ Builds documentation in the container. * figures out CI image name * checks if there are enough resources * converts parameters into a DocParams class """ params = BuildCiParams() ci_image_name = params.airflow_image_name check_docker_resources(verbose, ci_image_name) doc_builder = DocParams( package_filter=package_filter, docs_only=docs_only, spellcheck_only=spellcheck_only, ) extra_docker_flags = get_extra_docker_flags(MOUNT_SELECTED) cmd = [] cmd.extend(["docker", "run"]) cmd.extend(extra_docker_flags) cmd.extend(["-t", "-e", "GITHUB_ACTIONS="]) cmd.extend(["--entrypoint", "/usr/local/bin/dumb-init", "--pull", "never"]) cmd.extend([ ci_image_name, "--", "/opt/airflow/scripts/in_container/run_docs_build.sh" ]) cmd.extend(doc_builder.args_doc_builder) run_command(cmd, verbose=verbose, dry_run=dry_run, text=True)
def run_shell_with_build_image_checks(verbose: bool, dry_run: bool, shell_params: ShellParams): """ Executes shell command built from params passed, checking if build is not needed. * checks if there are enough resources to run shell * checks if image was built at least once (if not - forces the build) * if not forces, checks if build is needed and asks the user if so * builds the image if needed * prints information about the build * constructs docker compose command to enter shell * executes it :param verbose: print commands when running :param dry_run: do not execute "write" commands - just print what would happen :param shell_params: parameters of the execution """ check_docker_resources(verbose, shell_params.airflow_image_name) build_ci_image_check_cache = Path(BUILD_CACHE_DIR, shell_params.airflow_branch, f".built_{shell_params.python}") if build_ci_image_check_cache.exists(): console.print( f'[bright_blue]{shell_params.the_image_type} image already built locally.[/]' ) else: console.print( f'[bright_yellow]{shell_params.the_image_type} image not built locally. ' f'Forcing build.[/]') shell_params.force_build = True if not shell_params.force_build: build_image_if_needed_steps(verbose, dry_run, shell_params) else: build_image( verbose, dry_run=dry_run, python=shell_params.python, upgrade_to_newer_dependencies="false", ) shell_params.print_badge_info() cmd = [ 'docker-compose', 'run', '--service-ports', "-e", "BREEZE", '--rm', 'airflow' ] cmd_added = shell_params.command_passed env_variables = construct_env_variables_docker_compose_command( shell_params) if cmd_added is not None: cmd.extend(['-c', cmd_added]) run_command(cmd, verbose=verbose, dry_run=dry_run, env=env_variables, text=True)
def build_docs(verbose: bool, docs_only: bool, spellcheck_only: bool, package_filter: Tuple[str]): """ Builds documentation in the container """ params = BuildParams() airflow_sources = str(get_airflow_sources_root()) ci_image_name = params.airflow_ci_image_name check_docker_resources(verbose, airflow_sources, ci_image_name) doc_builder = DocBuilder( package_filter=package_filter, docs_only=docs_only, spellcheck_only=spellcheck_only ) build_documentation.build(verbose, airflow_sources, ci_image_name, doc_builder)
def resource_check(verbose: bool, dry_run: bool): shell_params = ShellParams(verbose=verbose, python=DEFAULT_PYTHON_MAJOR_MINOR_VERSION) check_docker_resources(verbose, shell_params.airflow_image_name, dry_run=dry_run)