From 4149e828a4d115bce9435da381fef791e29ec933 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Mon, 30 Jul 2018 11:37:36 +0530 Subject: [PATCH 01/15] Update debugging for default_launch Signed-off-by: Riddhesh Sanghvi --- php/utils.php | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/php/utils.php b/php/utils.php index f490ac8dd..70822520f 100644 --- a/php/utils.php +++ b/php/utils.php @@ -1412,11 +1412,14 @@ function delem_log( $log_data ) { /** * Format and print debug messages for EE::launch * - * @param Object $launch EE::Launch command object + * @param Object $launch EE::Launch command object. + * @param bool $skip_command Skip logging command. */ -function default_debug( $launch ) { - EE::debug( '-----------------------' ); - EE::debug( "COMMAND: $launch->command" ); +function default_debug( $launch, $skip_command = false ) { + if ( ! $skip_command ) { + EE::debug( '-----------------------' ); + EE::debug( "COMMAND: $launch->command" ); + } if ( ! empty( $launch->stdout ) ) { EE::debug( "STDOUT: $launch->stdout" ); } @@ -1431,25 +1434,32 @@ function default_debug( $launch ) { * Default Launch command. * This takes care of executing the command as well as debugging it to terminal as well as file. * - * @param string $command The command to be executed via EE::launch(); - * @param array $env Environment variables to set when running the command. - * @param string $cwd Directory to execute the command in. + * @param string $command The command to be executed via EE::launch(); + * @param bool $echo_stdout Print stdout to terminal. Default false. + * @param bool $echo_stderr Print stderr to terminal. Default false. + * @param array $env Environment variables to set when running the command. + * @param string $cwd Directory to execute the command in. * * @return bool True if executed successfully. False if failed. */ function default_launch( $command, $echo_stdout = false, $echo_stderr = false, $env = null, $cwd = null ) { + + EE::debug( '-----------------------' ); + EE::debug( "COMMAND: $command" ); + $launch = EE::launch( $command, false, true, $env, $cwd ); - default_debug( $launch ); + default_debug( $launch, true ); - if( $echo_stdout ) { + if ( $echo_stdout ) { echo $launch->stdout; } - if( $echo_stderr ) { + if ( $echo_stderr ) { echo $launch->stderr; } if ( ! $launch->return_code ) { return true; } + return false; } From b42e782c14379edbd2585d21b93e0a384c145b30 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Mon, 30 Jul 2018 11:40:05 +0530 Subject: [PATCH 02/15] Switch to default_launch for updated debugging Signed-off-by: Riddhesh Sanghvi --- php/class-ee-docker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/php/class-ee-docker.php b/php/class-ee-docker.php index 1bc610cf4..a21a9d53b 100644 --- a/php/class-ee-docker.php +++ b/php/class-ee-docker.php @@ -35,7 +35,7 @@ public static function container_status( $container ) { if ( $ret ) { EE::error( 'Docker is not installed. Please install Docker to run EasyEngine.' ); } - $status = EE::launch( "docker inspect -f '{{.State.Running}}' $container", false, true ); + $status = default_launch( "docker inspect -f '{{.State.Running}}' $container" ); default_debug( $status ); if ( ! $status->return_code ) { if ( preg_match( '/true/', $status->stdout ) ) { @@ -91,7 +91,7 @@ public static function restart_container( $container ) { */ public static function create_container( $container, $command ) { - $launch = EE::launch( $command, false, true ); + $launch = default_launch( $command ); default_debug( $launch ); if ( ! $launch->return_code ) { return true; From 727f2a99511b39b451fe0fc518a46bb812f3664b Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Mon, 30 Jul 2018 18:13:04 +0530 Subject: [PATCH 03/15] Add public static function to execute commands and debug Signed-off-by: Riddhesh Sanghvi --- php/class-ee.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/php/class-ee.php b/php/class-ee.php index 8884976ed..a3aac0774 100644 --- a/php/class-ee.php +++ b/php/class-ee.php @@ -851,6 +851,47 @@ public static function launch( $command, $exit_on_error = true, $return_detailed return $results->return_code; } + /** + * Launch an arbitrary external process that takes over I/O. + * + * @access public + * @category Execution + * + * @param string $command External process to launch. + * @param bool $echo_stdout Print stdout to terminal. Default false. + * @param bool $echo_stderr Print stderr to terminal. Default false. + * + * @return bool True if executed successfully. False if failed. + */ + public static function exec( $command, $echo_stdout = false, $echo_stderr = false ) { + Utils\check_proc_available( 'exec' ); + + $proc = Process::create( $command, null, null ); + $results = $proc->run(); + + if ( - 1 == $results->return_code ) { + self::warning( "Spawned process returned exit code {$results->return_code}, which could be caused by a custom compiled version of PHP that uses the --enable-sigchild option." ); + } + + EE::debug( '-----------------------' ); + EE::debug( "COMMAND: $command" ); + + EE\Utils\default_debug( $results, true ); + + if ( $echo_stdout ) { + echo $results->stdout; + } + if ( $echo_stderr ) { + echo $results->stderr; + } + if ( ! $results->return_code ) { + return true; + } + + return false; + + } + /** * Run a EE command in a new process reusing the current runtime arguments. * From cd8b2735bba157377a044b4d391265ebda8ed59d Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Mon, 30 Jul 2018 18:28:14 +0530 Subject: [PATCH 04/15] Add exit on error option Signed-off-by: Riddhesh Sanghvi --- php/class-ee.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/php/class-ee.php b/php/class-ee.php index a3aac0774..4d6f1db5a 100644 --- a/php/class-ee.php +++ b/php/class-ee.php @@ -857,13 +857,14 @@ public static function launch( $command, $exit_on_error = true, $return_detailed * @access public * @category Execution * - * @param string $command External process to launch. - * @param bool $echo_stdout Print stdout to terminal. Default false. - * @param bool $echo_stderr Print stderr to terminal. Default false. + * @param string $command External process to launch. + * @param bool $echo_stdout Print stdout to terminal. Default false. + * @param bool $echo_stderr Print stderr to terminal. Default false. + * @param boolean $exit_on_error Exit if the command returns an elevated return code with stderr. * * @return bool True if executed successfully. False if failed. */ - public static function exec( $command, $echo_stdout = false, $echo_stderr = false ) { + public static function exec( $command, $echo_stdout = false, $echo_stderr = false, $exit_on_error = false ) { Utils\check_proc_available( 'exec' ); $proc = Process::create( $command, null, null ); @@ -881,13 +882,15 @@ public static function exec( $command, $echo_stdout = false, $echo_stderr = fals if ( $echo_stdout ) { echo $results->stdout; } - if ( $echo_stderr ) { + if ( $echo_stderr && ! $exit_on_error ) { echo $results->stderr; } if ( ! $results->return_code ) { return true; } - + if( $exit_on_error ) { + EE::error( $results->stderr ); + } return false; } From 3d5824daed8a62eafb26a12d29b8439a492051dc Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Mon, 30 Jul 2018 18:32:02 +0530 Subject: [PATCH 05/15] Update to new exec function Signed-off-by: Riddhesh Sanghvi --- php/class-ee-docker.php | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/php/class-ee-docker.php b/php/class-ee-docker.php index a21a9d53b..76de6daa0 100644 --- a/php/class-ee-docker.php +++ b/php/class-ee-docker.php @@ -1,8 +1,6 @@ return_code ) { if ( preg_match( '/true/', $status->stdout ) ) { @@ -56,7 +54,7 @@ public static function container_status( $container ) { * @return bool success. */ public static function start_container( $container ) { - return default_launch( "docker start $container" ); + return EE::exec( "docker start $container" ); } /** @@ -67,7 +65,7 @@ public static function start_container( $container ) { * @return bool success. */ public static function stop_container( $container ) { - return default_launch( "docker stop $container" ); + return EE::exec( "docker stop $container" ); } /** @@ -78,25 +76,19 @@ public static function stop_container( $container ) { * @return bool success. */ public static function restart_container( $container ) { - return default_launch( "docker restart $container" ); + return EE::exec( "docker restart $container" ); } /** * Function to create and start the container if it does not exist. * - * @param String $container Container to be created. * @param String $command Command to launch the container. * * @return bool success. */ - public static function create_container( $container, $command ) { + public static function create_container( $command ) { - $launch = default_launch( $command ); - default_debug( $launch ); - if ( ! $launch->return_code ) { - return true; - } - EE::error( $launch->stderr ); + return EE::exec( $command, true, true, true ); } /** @@ -107,7 +99,7 @@ public static function create_container( $container, $command ) { * @return bool success. */ public static function create_network( $name ) { - return default_launch( "docker network create $name" ); + return EE::exec( "docker network create $name" ); } /** @@ -119,7 +111,7 @@ public static function create_network( $name ) { * @return bool success. */ public static function connect_network( $name, $connect_to ) { - return default_launch( "docker network connect $name $connect_to" ); + return EE::exec( "docker network connect $name $connect_to" ); } /** @@ -130,7 +122,7 @@ public static function connect_network( $name, $connect_to ) { * @return bool success. */ public static function rm_network( $name ) { - return default_launch( "docker network rm $name" ); + return EE::exec( "docker network rm $name" ); } /** @@ -142,7 +134,7 @@ public static function rm_network( $name ) { * @return bool success. */ public static function disconnect_network( $name, $connected_to ) { - return default_launch( "docker network disconnect $name $connected_to" ); + return EE::exec( "docker network disconnect $name $connected_to" ); } @@ -183,11 +175,11 @@ public static function docker_compose_up( $dir, $services = [] ) { $chdir_return_code = chdir( $dir ); if ( $chdir_return_code ) { if ( empty( $services ) ) { - return default_launch( 'docker-compose up -d' ); + return EE::exec( 'docker-compose up -d' ); } else { $all_services = implode( ' ', $services ); - return default_launch( "docker-compose up -d $all_services" ); + return EE::exec( "docker-compose up -d $all_services" ); } } @@ -205,7 +197,7 @@ public static function docker_compose_down( $dir ) { $chdir_return_code = chdir( $dir ); if ( $chdir_return_code ) { - return default_launch( 'docker-compose down' ); + return EE::exec( 'docker-compose down' ); } return false; From c78894c11f089c4960b64346f1fef649d767c1e4 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Tue, 31 Jul 2018 11:48:52 +0530 Subject: [PATCH 06/15] Move debugging completely to core from utilis Signed-off-by: Riddhesh Sanghvi --- php/class-ee.php | 46 ++++++++++++++++++++++++++++++----------- php/utils.php | 54 ------------------------------------------------ 2 files changed, 34 insertions(+), 66 deletions(-) diff --git a/php/class-ee.php b/php/class-ee.php index 4d6f1db5a..968cf7ff9 100644 --- a/php/class-ee.php +++ b/php/class-ee.php @@ -830,12 +830,17 @@ public static function error_to_string( $errors ) { * * @return int|ProcessRun The command exit status, or a ProcessRun object for full details. */ - public static function launch( $command, $exit_on_error = true, $return_detailed = false, $env = null, $cwd = null ) { + public static function launch( $command, $exit_on_error = false, $return_detailed = true, $env = null, $cwd = null ) { Utils\check_proc_available( 'launch' ); + self::debug( '-----------------------' ); + self::debug( "COMMAND: $command" ); + $proc = Process::create( $command, $cwd, $env ); $results = $proc->run(); + self::debug_run_command( $results ); + if ( -1 == $results->return_code ) { self::warning( "Spawned process returned exit code {$results->return_code}, which could be caused by a custom compiled version of PHP that uses the --enable-sigchild option." ); } @@ -857,28 +862,28 @@ public static function launch( $command, $exit_on_error = true, $return_detailed * @access public * @category Execution * - * @param string $command External process to launch. - * @param bool $echo_stdout Print stdout to terminal. Default false. - * @param bool $echo_stderr Print stderr to terminal. Default false. - * @param boolean $exit_on_error Exit if the command returns an elevated return code with stderr. + * @param string $command External process to launch. + * @param bool $echo_stdout Print stdout to terminal. Default false. + * @param bool $echo_stderr Print stderr to terminal. Default false. + * @param boolean $exit_on_error Exit if the command returns an elevated return code with stderr. * * @return bool True if executed successfully. False if failed. */ public static function exec( $command, $echo_stdout = false, $echo_stderr = false, $exit_on_error = false ) { Utils\check_proc_available( 'exec' ); + self::debug( '-----------------------' ); + self::debug( "COMMAND: $command" ); + $proc = Process::create( $command, null, null ); $results = $proc->run(); + self::debug_run_command( $results ); + if ( - 1 == $results->return_code ) { self::warning( "Spawned process returned exit code {$results->return_code}, which could be caused by a custom compiled version of PHP that uses the --enable-sigchild option." ); } - EE::debug( '-----------------------' ); - EE::debug( "COMMAND: $command" ); - - EE\Utils\default_debug( $results, true ); - if ( $echo_stdout ) { echo $results->stdout; } @@ -888,9 +893,10 @@ public static function exec( $command, $echo_stdout = false, $echo_stderr = fals if ( ! $results->return_code ) { return true; } - if( $exit_on_error ) { - EE::error( $results->stderr ); + if ( $exit_on_error ) { + exit( $results->return_code ); } + return false; } @@ -950,6 +956,22 @@ public static function launch_self( $command, $args = array(), $assoc_args = arr return self::launch( $full_command, $exit_on_error, $return_detailed ); } + /** + * Format and print debug messages for external command launch. + * + * @param Object $launch external command object. + */ + private static function debug_run_command( $launch ) { + if ( ! empty( $launch->stdout ) ) { + self::debug( "STDOUT: $launch->stdout" ); + } + if ( ! empty( $launch->stderr ) ) { + self::debug( "STDERR: $launch->stderr" ); + } + self::debug( "RETURN CODE: $launch->return_code" ); + self::debug( '-----------------------' ); + } + /** * Get the path to the PHP binary used when executing EE. * diff --git a/php/utils.php b/php/utils.php index 70822520f..29ea5792a 100644 --- a/php/utils.php +++ b/php/utils.php @@ -1409,60 +1409,6 @@ function delem_log( $log_data ) { EE::get_file_logger()->info( "======================== $log_data ========================" ); } -/** - * Format and print debug messages for EE::launch - * - * @param Object $launch EE::Launch command object. - * @param bool $skip_command Skip logging command. - */ -function default_debug( $launch, $skip_command = false ) { - if ( ! $skip_command ) { - EE::debug( '-----------------------' ); - EE::debug( "COMMAND: $launch->command" ); - } - if ( ! empty( $launch->stdout ) ) { - EE::debug( "STDOUT: $launch->stdout" ); - } - if ( ! empty( $launch->stderr ) ) { - EE::debug( "STDERR: $launch->stderr" ); - } - EE::debug( "RETURN CODE: $launch->return_code" ); - EE::debug( '-----------------------' ); -} - -/** - * Default Launch command. - * This takes care of executing the command as well as debugging it to terminal as well as file. - * - * @param string $command The command to be executed via EE::launch(); - * @param bool $echo_stdout Print stdout to terminal. Default false. - * @param bool $echo_stderr Print stderr to terminal. Default false. - * @param array $env Environment variables to set when running the command. - * @param string $cwd Directory to execute the command in. - * - * @return bool True if executed successfully. False if failed. - */ -function default_launch( $command, $echo_stdout = false, $echo_stderr = false, $env = null, $cwd = null ) { - - EE::debug( '-----------------------' ); - EE::debug( "COMMAND: $command" ); - - $launch = EE::launch( $command, false, true, $env, $cwd ); - default_debug( $launch, true ); - - if ( $echo_stdout ) { - echo $launch->stdout; - } - if ( $echo_stderr ) { - echo $launch->stderr; - } - if ( ! $launch->return_code ) { - return true; - } - - return false; -} - /** * Function that takes care of executing the command as well as debugging it to terminal as well as file. * From ea9257be9cf620f73b3eaea6b07eddcafc410662 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Tue, 31 Jul 2018 11:53:43 +0530 Subject: [PATCH 07/15] Update function calls according to changes Signed-off-by: Riddhesh Sanghvi --- php/class-ee-docker.php | 3 --- php/commands/src/CLI_Command.php | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/php/class-ee-docker.php b/php/class-ee-docker.php index 76de6daa0..902edd434 100644 --- a/php/class-ee-docker.php +++ b/php/class-ee-docker.php @@ -1,7 +1,5 @@ return_code ) { if ( preg_match( '/true/', $status->stdout ) ) { return 'running'; diff --git a/php/commands/src/CLI_Command.php b/php/commands/src/CLI_Command.php index 238a7038f..e2d719bf1 100644 --- a/php/commands/src/CLI_Command.php +++ b/php/commands/src/CLI_Command.php @@ -502,9 +502,9 @@ public function self_uninstall( $args, $assoc_args ) { EE::confirm("Are you sure you want to remove EasyEngine and all its sites(along with their data)?\nThis is an irreversible action. No backup will be kept.", $assoc_args); - Utils\default_launch("docker rm -f $(docker ps -aqf label=org.label-schema.vendor=\"EasyEngine\")"); + EE::exec("docker rm -f $(docker ps -aqf label=org.label-schema.vendor=\"EasyEngine\")"); $home = Utils\get_home_dir(); - Utils\default_launch("rm -rf $home/.ee/"); + EE::exec("rm -rf $home/.ee/"); $records = EE::db()->select(['site_path']); @@ -514,8 +514,8 @@ public function self_uninstall( $args, $assoc_args ) { $fs->remove($sites_paths); } - Utils\default_launch("rm -df $home/ee-sites/"); - Utils\default_launch("rm -rf /opt/easyengine/"); + EE::exec("rm -df $home/ee-sites/"); + EE::exec("rm -rf /opt/easyengine/"); if ( Utils\inside_phar() ) { unlink( realpath( $_SERVER['argv'][0] ) ); From dfa80a6ae27f19f8adc84a8c3e407ba726476ca9 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Tue, 31 Jul 2018 21:59:39 +0530 Subject: [PATCH 08/15] Remove extra space Signed-off-by: Riddhesh Sanghvi --- php/class-ee.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/class-ee.php b/php/class-ee.php index 968cf7ff9..b05a80309 100644 --- a/php/class-ee.php +++ b/php/class-ee.php @@ -880,7 +880,7 @@ public static function exec( $command, $echo_stdout = false, $echo_stderr = fals self::debug_run_command( $results ); - if ( - 1 == $results->return_code ) { + if ( -1 == $results->return_code ) { self::warning( "Spawned process returned exit code {$results->return_code}, which could be caused by a custom compiled version of PHP that uses the --enable-sigchild option." ); } From a9297f155958310b913695d3aad6ad893d7e40fb Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Thu, 2 Aug 2018 13:48:34 +0530 Subject: [PATCH 09/15] Add loading of logger for EE::launch in test Signed-off-by: Riddhesh Sanghvi --- features/bootstrap/FeatureContext.php | 38 +++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php index 93dd27871..2fbedb28a 100644 --- a/features/bootstrap/FeatureContext.php +++ b/features/bootstrap/FeatureContext.php @@ -1,7 +1,41 @@ init_logger(); use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\AfterFeatureScope; From e7237431d0af382ada086ce26b131043d81fa908 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Thu, 2 Aug 2018 14:04:59 +0530 Subject: [PATCH 10/15] Update function calls in site utils and class Signed-off-by: Riddhesh Sanghvi --- php/class-ee-site.php | 2 +- php/site-utils.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/php/class-ee-site.php b/php/class-ee-site.php index 64472c206..9a594a0b6 100644 --- a/php/class-ee-site.php +++ b/php/class-ee-site.php @@ -140,7 +140,7 @@ protected function delete_site( $level, $site_name, $site_root ) { if ( EE::docker()::docker_compose_down( $site_root ) ) { EE::log( "[$site_name] Docker Containers removed." ); } else { - EE\Utils\default_launch( "docker rm -f $(docker ps -q -f=label=created_by=EasyEngine -f=label=site_name=$site_name)" ); + EE::exec( "docker rm -f $(docker ps -q -f=label=created_by=EasyEngine -f=label=site_name=$site_name)" ); if ( $level > 3 ) { EE::warning( 'Error in removing docker containers.' ); } diff --git a/php/site-utils.php b/php/site-utils.php index 3c5598c09..0ffccb682 100644 --- a/php/site-utils.php +++ b/php/site-utils.php @@ -207,7 +207,7 @@ function create_etc_hosts_entry( $site_name ) { $host_line = LOCALHOST_IP . "\t$site_name"; $etc_hosts = file_get_contents( '/etc/hosts' ); if ( ! preg_match( "/\s+$site_name\$/m", $etc_hosts ) ) { - if ( EE\Utils\default_launch( "/bin/bash -c 'echo \"$host_line\" >> /etc/hosts'" ) ) { + if ( EE::exec( "/bin/bash -c 'echo \"$host_line\" >> /etc/hosts'" ) ) { EE::success( 'Host entry successfully added.' ); } else { EE::warning( "Failed to add $site_name in host entry, Please do it manually!" ); @@ -281,7 +281,7 @@ function start_site_containers( $site_root ) { EE::log( 'Pulling latest images. This may take some time.' ); chdir( $site_root ); - \EE\Utils\default_launch( 'docker-compose pull' ); + \EE::exec( 'docker-compose pull' ); EE::log( 'Starting site\'s services.' ); if ( ! EE::docker()::docker_compose_up( $site_root ) ) { throw new \Exception( 'There was some error in docker-compose up.' ); @@ -303,5 +303,5 @@ function run_compose_command( $action, $container, $action_to_display = null, $s $display_service = $service_to_display ? $service_to_display : $container; \EE::log( ucfirst( $display_action ) . 'ing ' . $display_service ); - \EE\Utils\default_launch( "docker-compose $action $container", true, true ); + \EE::exec( "docker-compose $action $container", true, true ); } From 46cb35f55102773ec4781dea82ebd77b1d340292 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Thu, 2 Aug 2018 15:20:02 +0530 Subject: [PATCH 11/15] Update scope Signed-off-by: Riddhesh Sanghvi --- php/site-utils.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/php/site-utils.php b/php/site-utils.php index 0ffccb682..57871096c 100644 --- a/php/site-utils.php +++ b/php/site-utils.php @@ -281,7 +281,7 @@ function start_site_containers( $site_root ) { EE::log( 'Pulling latest images. This may take some time.' ); chdir( $site_root ); - \EE::exec( 'docker-compose pull' ); + EE::exec( 'docker-compose pull' ); EE::log( 'Starting site\'s services.' ); if ( ! EE::docker()::docker_compose_up( $site_root ) ) { throw new \Exception( 'There was some error in docker-compose up.' ); @@ -302,6 +302,6 @@ function run_compose_command( $action, $container, $action_to_display = null, $s $display_action = $action_to_display ? $action_to_display : $action; $display_service = $service_to_display ? $service_to_display : $container; - \EE::log( ucfirst( $display_action ) . 'ing ' . $display_service ); - \EE::exec( "docker-compose $action $container", true, true ); + EE::log( ucfirst( $display_action ) . 'ing ' . $display_service ); + EE::exec( "docker-compose $action $container", true, true ); } From 7c558bc072186eefdfc52945da1b172d5ef3a8a0 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Thu, 2 Aug 2018 16:01:30 +0530 Subject: [PATCH 12/15] Give sudo permission to create log file Signed-off-by: Riddhesh Sanghvi --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 85f688b3a..6df101e64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ install: before_script: - composer validate - - ./vendor/bin/behat + - sudo ./vendor/bin/behat - ./ci/prepare.sh jobs: From 7352e7a0f7656004ef3daa9d4ad78b03197438ed Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Thu, 2 Aug 2018 19:37:51 +0530 Subject: [PATCH 13/15] phpcbf run Signed-off-by: Riddhesh Sanghvi --- features/bootstrap/FeatureContext.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php index 2fbedb28a..c8d502199 100644 --- a/features/bootstrap/FeatureContext.php +++ b/features/bootstrap/FeatureContext.php @@ -1,12 +1,11 @@ Date: Thu, 2 Aug 2018 19:45:48 +0530 Subject: [PATCH 14/15] Remove extra wrapper Signed-off-by: Riddhesh Sanghvi --- php/class-ee-docker.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/php/class-ee-docker.php b/php/class-ee-docker.php index 902edd434..f2ae5b9bf 100644 --- a/php/class-ee-docker.php +++ b/php/class-ee-docker.php @@ -19,7 +19,7 @@ public static function boot_container( $container, $command = '' ) { return true; } } else { - return self::create_container( $command ); + return EE::exec( $command ); } } @@ -76,18 +76,6 @@ public static function restart_container( $container ) { return EE::exec( "docker restart $container" ); } - /** - * Function to create and start the container if it does not exist. - * - * @param String $command Command to launch the container. - * - * @return bool success. - */ - public static function create_container( $command ) { - - return EE::exec( $command, true, true, true ); - } - /** * Create docker network. * From 97a7cd63a1343f1c3be985fe663c0afb4d31c62b Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Thu, 2 Aug 2018 20:05:18 +0530 Subject: [PATCH 15/15] Update acc to review Signed-off-by: Riddhesh Sanghvi --- features/bootstrap/FeatureContext.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php index c8d502199..4238ab1fd 100644 --- a/features/bootstrap/FeatureContext.php +++ b/features/bootstrap/FeatureContext.php @@ -1,5 +1,11 @@ init_logger(); +/* End. Loading required files to enable EE::launch() in tests. */ use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\AfterFeatureScope;