Skip to content

Commit

Permalink
When trying to use this tool on anything other than Travis it is hard…
Browse files Browse the repository at this point in the history
…er to make ci script look lean because so many options have to be crammed in the install command line.

It would be most useful to have more install options mapped to ENV variables.

Fixes #217
  • Loading branch information
kiklop74 committed Mar 22, 2023
1 parent a81b760 commit 414c4b5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ protected function configure(): void
$plugin = getenv('CI_BUILD_DIR') !== false ? getenv('CI_BUILD_DIR') : null;
}

// Add more options mapped to environment variables.
$db_user = getenv('DB_USER') !== false ? getenv('DB_USER') : null;
$db_pass = getenv('DB_PASS') !== false ? getenv('DB_PASS') : '';
$db_name = getenv('DB_NAME') !== false ? getenv('DB_NAME') : 'moodle';
$db_host = getenv('DB_HOST') !== false ? getenv('DB_HOST') : 'localhost';
$db_port = getenv('DB_PORT') !== false ? getenv('DB_PORT') : '';

$this->setName('install')
->setDescription('Install everything required for CI testing')
->addOption('moodle', null, InputOption::VALUE_REQUIRED, 'Clone Moodle to this directory', 'moodle')
Expand All @@ -75,11 +82,11 @@ protected function configure(): void
->addOption('branch', null, InputOption::VALUE_REQUIRED, 'Moodle git branch to clone, EG: MOODLE_29_STABLE', $branch)
->addOption('plugin', null, InputOption::VALUE_REQUIRED, 'Path to Moodle plugin', $plugin)
->addOption('db-type', null, InputOption::VALUE_REQUIRED, 'Database type, mysqli, pgsql or mariadb', $type)
->addOption('db-user', null, InputOption::VALUE_REQUIRED, 'Database user')
->addOption('db-pass', null, InputOption::VALUE_REQUIRED, 'Database pass', '')
->addOption('db-name', null, InputOption::VALUE_REQUIRED, 'Database name', 'moodle')
->addOption('db-host', null, InputOption::VALUE_REQUIRED, 'Database host', 'localhost')
->addOption('db-port', null, InputOption::VALUE_REQUIRED, 'Database port', '')
->addOption('db-user', null, InputOption::VALUE_REQUIRED, 'Database user', $db_user)
->addOption('db-pass', null, InputOption::VALUE_REQUIRED, 'Database pass', $db_pass)
->addOption('db-name', null, InputOption::VALUE_REQUIRED, 'Database name', $db_name)
->addOption('db-host', null, InputOption::VALUE_REQUIRED, 'Database host', $db_host)
->addOption('db-port', null, InputOption::VALUE_REQUIRED, 'Database port', $db_port)
->addOption('not-paths', null, InputOption::VALUE_REQUIRED, 'CSV of file paths to exclude', $paths)
->addOption('not-names', null, InputOption::VALUE_REQUIRED, 'CSV of file names to exclude', $names)
->addOption('extra-plugins', null, InputOption::VALUE_REQUIRED, 'Directory of extra plugins to install', $extra)
Expand Down

0 comments on commit 414c4b5

Please sign in to comment.