-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust pup to pass specific ENV vars down to build and workflow steps (…
…#23) Some commands need environment variables to be set in order to function correctly (example: `NODE_AUTH_TOKEN` for use in installing private npm packages) This change sets a default set of env vars that can get passed down to commands (`NODE_AUTH_TOKEN`) and `.puprc` files can add additional `env` entries to expand the ENV vars that pup will handle. The _Files Changed_ on this PR looks intimidating, but most of those changes are the snapshots.
- Loading branch information
Showing
38 changed files
with
256 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace StellarWP\Pup\Utils; | ||
|
||
use StellarWP\Pup\App; | ||
|
||
class Env { | ||
/** | ||
* Prepend a command with the env vars. | ||
* | ||
* @param string $command Command to prepend. | ||
* | ||
* @return string | ||
*/ | ||
public static function set( string $command ): string { | ||
$config = App::getConfig(); | ||
$config_items = $config->get(); | ||
$env = []; | ||
|
||
if ( empty( $config_items->env ) ) { | ||
return $command; | ||
} | ||
|
||
foreach ( (array) $config_items->env as $env_item ) { | ||
$env[ $env_item ] = "{$env_item}=" . getenv( $env_item ); | ||
} | ||
|
||
return implode( ' ', $env ) . ' ' . $command; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ public function it_should_clone_the_default_branch_of_a_git_repo( CliTester $I ) | |
|
||
system( 'cd ' . $project_path . ' && git init --quiet' ); | ||
system( 'cd ' . $project_path . ' && git add .' ); | ||
system( 'cd ' . $project_path . ' && git config user.email "[email protected]"' ); | ||
system( 'cd ' . $project_path . ' && git config user.name "Fake Fake"' ); | ||
system( 'cd ' . $project_path . ' && git commit -m "Initial commit" --quiet' ); | ||
|
||
$puprc = $this->get_puprc(); | ||
|
@@ -52,6 +54,8 @@ public function it_should_clone_a_specific_branch_of_a_git_repo( CliTester $I ) | |
|
||
system( 'cd ' . $project_path . ' && git init --quiet' ); | ||
system( 'cd ' . $project_path . ' && git add .' ); | ||
system( 'cd ' . $project_path . ' && git config user.email "[email protected]"' ); | ||
system( 'cd ' . $project_path . ' && git config user.name "Fake Fake"' ); | ||
system( 'cd ' . $project_path . ' && git commit -m "Initial commit" --quiet' ); | ||
system( 'cd ' . $project_path . ' && git checkout -b other-branch --quiet' ); | ||
system( 'cd ' . $project_path . ' && touch new-file.txt' ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ public function it_should_zip_with_repo_using_path( CliTester $I ) { | |
|
||
system( 'cd ' . $project_path . ' && git init --quiet' ); | ||
system( 'cd ' . $project_path . ' && git add .' ); | ||
system( 'cd ' . $project_path . ' && git config user.email "[email protected]"' ); | ||
system( 'cd ' . $project_path . ' && git config user.name "Fake Fake"' ); | ||
system( 'cd ' . $project_path . ' && git commit -m "Initial commit" --quiet' ); | ||
|
||
$puprc = $this->get_puprc(); | ||
|
@@ -53,6 +55,8 @@ public function it_should_zip_with_repo_using_file_colon_slash_slash( CliTester | |
|
||
system( 'cd ' . $project_path . ' && git init --quiet' ); | ||
system( 'cd ' . $project_path . ' && git add .' ); | ||
system( 'cd ' . $project_path . ' && git config user.email "[email protected]"' ); | ||
system( 'cd ' . $project_path . ' && git config user.name "Fake Fake"' ); | ||
system( 'cd ' . $project_path . ' && git commit -m "Initial commit" --quiet' ); | ||
|
||
$puprc = $this->get_puprc(); | ||
|
24 changes: 24 additions & 0 deletions
24
...ommands/__snapshots__/BuildCest__it_should_run_build_with_custom_env_vars__0.snapshot.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Running build steps... | ||
|
||
> ls -a | ||
------- | ||
|
||
. | ||
.. | ||
.puprc | ||
bootstrap.php | ||
other-file.php | ||
package.json | ||
src | ||
|
||
> echo "NODE_AUTH_TOKEN=$NODE_AUTH_TOKEN" | ||
----------------------------------------- | ||
|
||
NODE_AUTH_TOKEN=123 | ||
|
||
> echo "BORK=$BORK" | ||
------------------- | ||
|
||
BORK=abc | ||
|
||
✓ Build complete. |
19 changes: 19 additions & 0 deletions
19
...mmands/__snapshots__/BuildCest__it_should_run_build_with_default_env_vars__0.snapshot.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Running build steps... | ||
|
||
> ls -a | ||
------- | ||
|
||
. | ||
.. | ||
.puprc | ||
bootstrap.php | ||
other-file.php | ||
package.json | ||
src | ||
|
||
> echo "NODE_AUTH_TOKEN=$NODE_AUTH_TOKEN" | ||
----------------------------------------- | ||
|
||
NODE_AUTH_TOKEN=123 | ||
|
||
✓ Build complete. |
2 changes: 1 addition & 1 deletion
2
.../__snapshots__/CloneCest__it_should_clone_a_specific_branch_of_a_git_repo__0.snapshot.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Cloning the /home/matt/git/pup/tests/_data/fake-project-git-repo repo into .pup-build... | ||
Cloning the /var/www/html/wp-content/plugins/pup/tests/_data/fake-project-git-repo repo into .pup-build... | ||
✓ Clone complete. |
2 changes: 1 addition & 1 deletion
2
...__snapshots__/CloneCest__it_should_clone_the_default_branch_of_a_git_repo__0.snapshot.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Cloning the /home/matt/git/pup/tests/_data/fake-project-git-repo repo into .pup-build... | ||
Cloning the /var/www/html/wp-content/plugins/pup/tests/_data/fake-project-git-repo repo into .pup-build... | ||
✓ Clone complete. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.