From 72e30c30e7c22ef461a5e1e5071cd103e9fea40d Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Fri, 4 Nov 2022 14:59:40 +0100 Subject: [PATCH 1/2] Add a command for cloud-build So people can more easily test the builds as if there were in cloud, I've added a command that will run their `.build-script` using the same `build-container` that we used in CodeBuild. --- inc/composer/class-command.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/inc/composer/class-command.php b/inc/composer/class-command.php index 9d54bd4e..0df470d8 100644 --- a/inc/composer/class-command.php +++ b/inc/composer/class-command.php @@ -172,6 +172,8 @@ protected function execute( InputInterface $input, OutputInterface $output ) { return $this->shell( $input, $output ); } elseif ( $subcommand === 'import-uploads' ) { return $this->import_uploads( $input, $output ); + } elseif ( $subcommand === 'cloud-build' ) { + return $this->cloud_build( $input, $output ); } elseif ( $subcommand === null ) { // Default to start command. return $this->start( $input, $output ); @@ -733,6 +735,35 @@ protected function import_uploads() { ) ); } + /** + * Run the .build-script as it would be in Altis Cloud + * + * @param InputInterface $input + * @param OutputInterface $output + * @return void + */ + protected function cloud_build( InputInterface $input, OutputInterface $output ) { + $output->writeln( 'Buld will install production dependencies, so you may need to `composer install` when doing development again.' ); + + $columns = exec( 'tput cols' ); + $lines = exec( 'tput lines' ); + $base_command = sprintf( + 'docker run ' . + '--rm ' . + '-e BUILD_VERBOSE=1 ' . + '-e COLUMNS=%1$d -e LINES=%2$d ' . + '--volume=%3$s:/build/src:delegated ' . + '--volume=$(eval echo ~$USER)/.ssh:/build/ssh:delegated ' . + 'humanmade/altis-build-container:edge', + $columns, + $lines, + getcwd(), + $this->get_project_subdomain() + ); + passthru( $base_command, $return_var ); + return $return_var; + } + /** * Pass a command through to the minio client. * From d2f01e4c51529c8e654a28158348b962e3206f98 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Wed, 15 Feb 2023 19:44:39 +0200 Subject: [PATCH 2/2] Update inc/composer/class-command.php Co-authored-by: Ryan McCue --- inc/composer/class-command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/composer/class-command.php b/inc/composer/class-command.php index 0df470d8..f07d6608 100644 --- a/inc/composer/class-command.php +++ b/inc/composer/class-command.php @@ -743,7 +743,7 @@ protected function import_uploads() { * @return void */ protected function cloud_build( InputInterface $input, OutputInterface $output ) { - $output->writeln( 'Buld will install production dependencies, so you may need to `composer install` when doing development again.' ); + $output->writeln( 'Build will install production dependencies, so you may need to `composer install` when doing development again.' ); $columns = exec( 'tput cols' ); $lines = exec( 'tput lines' );