From 8c5910e6ff12d754b10561b7554e5720b09c6e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Dagef=C3=B6rde?= Date: Mon, 23 Oct 2017 21:18:50 +0200 Subject: [PATCH] Fix #65: Provide optional argument for `install` to skip DB installation --- docs/CHANGELOG.md | 1 + src/Command/InstallCommand.php | 4 +++- src/Installer/InstallerFactory.php | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 68faf7f..8dd990c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,6 +11,7 @@ The format of this change log follows the advice given at [Keep a CHANGELOG](htt ## [Unreleased] ### Fixed - `moodle-plugin-ci validate` now only regards required language strings as present if they are assigned to the `$string` array. Before, other array variables were accepted although Moodle would not recognise them. +- `moodle-plugin-ci install` now provides an option `--skip-db-install` to skip DB installation if execution of unit tests and behat test will not be required. ## [2.1.1] ### Fixed diff --git a/src/Command/InstallCommand.php b/src/Command/InstallCommand.php index fc155f6..bb24bc2 100644 --- a/src/Command/InstallCommand.php +++ b/src/Command/InstallCommand.php @@ -87,7 +87,8 @@ protected function configure() ->addOption('db-host', null, InputOption::VALUE_REQUIRED, 'Database host', 'localhost') ->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); + ->addOption('extra-plugins', null, InputOption::VALUE_REQUIRED, 'Directory of extra plugins to install', $extra) + ->addOption('skip-db-install', null, InputOption::VALUE_REQUIRED, 'Skip DB installation, e.g. if only static analyses are required', false); } protected function initialize(InputInterface $input, OutputInterface $output) @@ -163,6 +164,7 @@ public function initializeInstallerFactory(InputInterface $input) $input->getOption('db-pass'), $input->getOption('db-host') ); + $factory->skipDbInstall = $input->getOption('skip-db-install'); return $factory; } diff --git a/src/Installer/InstallerFactory.php b/src/Installer/InstallerFactory.php index a959ee1..d12c9c1 100644 --- a/src/Installer/InstallerFactory.php +++ b/src/Installer/InstallerFactory.php @@ -68,6 +68,11 @@ class InstallerFactory */ public $pluginsDir; + /** + * @var bool + */ + public $skipDbInstall; + /** * Given a big bag of install options, add installers to the collection. * @@ -79,7 +84,9 @@ public function addInstallers(InstallerCollection $installers) $installers->add(new PluginInstaller($this->moodle, $this->plugin, $this->pluginsDir, $this->dumper)); $installers->add(new VendorInstaller($this->moodle, $this->plugin, $this->execute)); - if ($this->plugin->hasBehatFeatures() || $this->plugin->hasUnitTests()) { + if ($this->skipDbInstall) { + return; + } elseif ($this->plugin->hasBehatFeatures() || $this->plugin->hasUnitTests()) { $installers->add(new TestSuiteInstaller($this->moodle, $this->plugin, $this->execute)); } }