Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a command for cloud-build #540

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions inc/composer/class-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: check-build?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just build?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the intention is to test that a build runs without errors, and doesn't actually produce a build that can be deployed to Altis, so build may be a bit misleading.

return $this->cloud_build( $input, $output );
} elseif ( $subcommand === null ) {
// Default to start command.
return $this->start( $input, $output );
Expand Down Expand Up @@ -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( '<info>Buld will install production dependencies, so you may need to `composer install` when doing development again.</info>' );
joehoyle marked this conversation as resolved.
Show resolved Hide resolved

$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.
*
Expand Down