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

DQA-10278: Drupal config to use config instead of env vars #787

Merged
merged 1 commit into from
Oct 18, 2024
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
11 changes: 6 additions & 5 deletions config/runner/drupal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ drupal:
# Drupal database settings.
database:
scheme: 'mysql'
host: 'mysql'
port: '3306'
name: ''
user: ''
password: ''
host: '${env.DRUPAL_DATABASE_HOST}'
port: '${env.DRUPAL_DATABASE_PORT}'
name: '${env.DRUPAL_DATABASE_NAME}'
user: '${env.DRUPAL_DATABASE_USERNAME}'
password: '${env.DRUPAL_DATABASE_PASSWORD}'
prefix: '${env.DRUPAL_DATABASE_PREFIX}'
# Following lines will be converted in PHP and appended to default.settings.php.
settings: [ ]
drush:
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<env name="DRUPAL_DATABASE_NAME" value="drupal"/>
<env name="DRUPAL_DATABASE_USERNAME" value="root"/>
<env name="DRUPAL_DATABASE_HOST" value="mysql"/>
<env name="DRUPAL_DATABASE_PORT" value="3306"/>
</php>
<testsuites>
<testsuite name="Unit GitHooks">
Expand Down
15 changes: 8 additions & 7 deletions src/TaskRunner/Commands/DumpCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,16 +595,17 @@ private function getAsdaDate(string $filename): string
* The path to the dump file.
*
* @return \Robo\Task\Base\ExecStack
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
private function taskImportDatabase(string $dump)
{
$mysql = sprintf(
'mysql -u%s%s -h%s %s',
getenv('DRUPAL_DATABASE_USERNAME'),
getenv('DRUPAL_DATABASE_PASSWORD') ? ' -p' . getenv('DRUPAL_DATABASE_PASSWORD') : '',
getenv('DRUPAL_DATABASE_HOST'),
getenv('DRUPAL_DATABASE_NAME'),
);
$config = $this->getConfig()->get('drupal.database');
$user = !empty($config['user']) && $config['user'] !== '${env.DRUPAL_DATABASE_USERNAME}' ? $config['user'] : '';
$pass = !empty($config['password']) && $config['password'] !== '${env.DRUPAL_DATABASE_PASSWORD}' ? $config['password'] : '';
$host = !empty($config['host']) && $config['host'] !== '${env.DRUPAL_DATABASE_HOST}' ? $config['host'] : '';
$name = !empty($config['name']) && $config['name'] !== '${env.DRUPAL_DATABASE_NAME}' ? $config['name'] : '';
$mysql = sprintf('mysql -u%s%s -h%s %s', $user, $pass ? ' -p' . $pass : '', $host, $name);
if (str_ends_with($dump, '.gz')) {
$command = "gunzip < $dump | $mysql";
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/TaskRunner/Commands/ReleaseCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,12 @@ private function prepareChangelogRow(array $data, array $options)
// Extract PR from the message.
$pr = '';
if (preg_match('#(.+) (\(\#[0-9]+\))$#', $message, $matches)) {
$message = $matches[1] ?? '';
$pr = isset($matches[2]) ? trim($matches[2], '(#)') : '';
$message = $matches[1];
$pr = trim($matches[2], '(#)');
}
// Try to get username from email.
if (preg_match('#^[0-9]+\+(.+)@users.noreply.github.com$#', $email, $matches)) {
$name = '@' . ($matches[1] ?? '');
$name = '@' . $matches[1];
}

$log = ' - ' . trim($message, '.') . '.';
Expand Down
2 changes: 1 addition & 1 deletion src/TaskRunner/Commands/ToolCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function getCommitTokens()
$commitMsg = getenv('DRONE_COMMIT_MESSAGE') !== false ? getenv('DRONE_COMMIT_MESSAGE') : '';
$commitMsg = getenv('CI_COMMIT_MESSAGE') !== false ? getenv('CI_COMMIT_MESSAGE') : $commitMsg;
preg_match_all('/\[([^\]]*)\]/', $commitMsg, $findTokens);
if (isset($findTokens[1])) {
if (!empty($findTokens[1])) {
foreach ($findTokens[1] as $token) {
$transformedToken = strtolower(str_replace('-', '_', $token));
if ($transformedToken == 'skip_outdated') {
Expand Down