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

Fixes #4397 to place ci.blt.yml by default. #4489

Merged
merged 5 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 3 additions & 6 deletions scripts/blt/ci/internal/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
modules.ci.enable: [ views_ui ]
# We cannot use 127.0.0.1:8888 for vm hostname due to vagrant restrictions.
vm.vagrant.hostname: local.${project.machine_name}.com
drush.debug: false
drush.verbose: true
tests.run-server: true
tests.drupal.sudo-run-tests: false
project.local.hostname: 127.0.0.1:8080
# The local.hostname must be set to 127.0.0.1:8888 because we are using drush runserver to test the site.
project.local.hostname: 127.0.0.1:8888
drush.debug: false
20 changes: 20 additions & 0 deletions src/Robo/Commands/Blt/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ public function initialize() {
* @throws \Acquia\Blt\Robo\Exceptions\BltException
*/
public function addToProject() {
// Initializes the project template / scaffold.
$this->initializeBlt();
// Creates the blt/blt.yml file.
$this->setProjectName();
// Places the blt/ci.blt.yml file.
$this->createCiConfig();
// Adds default BLT values into the project .gitignore file.
$this->initGitignore();
// Invoke command instead of calling method to ensure hooks run.
$this->invokeCommand('internal:create-project:init-repo');
Expand Down Expand Up @@ -233,4 +238,19 @@ protected function setProjectName() {
$yamlWriter->write($project_config);
}

/**
* Sets project.name using the directory name of repo.root.
*/
protected function createCiConfig() {
$result = $this->taskFilesystemStack()
->copy($this->getConfigValue('blt.root') . '/scripts/blt/ci/internal/ci.yml', $this->getConfigValue('repo.root') . '/blt/ci.blt.yml', TRUE)
->stopOnFail()
->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
->run();

if (!$result->wasSuccessful()) {
throw new BltException("Could not initialize the CI specific BLT file.");
}
}

}
9 changes: 3 additions & 6 deletions tests/phpunit/src/DrupalSettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Acquia\Blt\Tests;

use Acquia\Blt\Robo\Common\YamlMunge;

/**
* Tests Drupal settings.
*/
Expand All @@ -20,6 +18,7 @@ public function testSetupDefaultLocalSettings() {
$this->assertFileExists("$this->sandboxInstance/docroot/sites/$site/settings/default.local.settings.php");
$this->assertFileExists("$this->sandboxInstance/docroot/sites/$site/default.settings.php");
$this->assertFileExists("$this->sandboxInstance/docroot/sites/$site/settings/local.settings.php");
$this->assertFileExists("$this->sandboxInstance/docroot/sites/$site/settings/local.settings.php");

$this->assertStringContainsString('${drupal.db.database}', file_get_contents("$this->sandboxInstance/docroot/sites/$site/settings/default.local.settings.php"));
$this->assertStringContainsString($this->config->get("drupal.db.database"), file_get_contents("$this->sandboxInstance/docroot/sites/$site/settings/local.settings.php"));
Expand All @@ -35,10 +34,8 @@ public function testSetupDefaultLocalSettings() {
$this->assertFileExists("$this->sandboxInstance/docroot/sites/$site/local.drush.yml");
$this->assertFileExists("$this->sandboxInstance/docroot/sites/$site/default.local.drush.yml");

$output_array = $this->drushJson(['status']);
$this->assertEquals($output_array['uri'], $this->config->get('project.local.uri'));
$drush_local_site_yml = YamlMunge::parseFile("$this->sandboxInstance/docroot/sites/$site/local.drush.yml");
$this->assertEquals($output_array['uri'], $drush_local_site_yml['options']['uri']);
$this->assertFileExists("$this->sandboxInstance/blt/blt.yml");
$this->assertFileExists("$this->sandboxInstance/blt/ci.blt.yml");
}
}

Expand Down
26 changes: 26 additions & 0 deletions tests/phpunit/src/SecurityTestsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Acquia\Blt\Tests;

/**
* Test security test commands.
*/
class SecurityTestsTest extends BltProjectTestBase {

/**
* Test that executes the blt drupal security test.
*/
public function testDrupalSecurity() {
list($response) = $this->blt('tests:security-drupal');
$this->assertStringContainsString("0", $response);
}

/**
* Test that executes the blt composer security test.
*/
public function testComposerSecurity() {
list($response) = $this->blt('tests:security-composer');
$this->assertStringContainsString("0", $response);
}

}