- Document usage
- - Allow specifying the template file for the CI setup that should be used.
-
- - Allow offline installs
+ - Allow offline installs and testing
- Add module for an initial empty PEAR template
- Add a release helper module.
+ - Maybe prefix the job names of packages from the framework with Horde_
+
- Allow absolute/relative paths as arguments
- Fail on missing dependencies in a decent way
+ - WWW frontend
--- /dev/null
+<?php
+/**
+ * Components_Config_Application:: provides a wrapper that provides application
+ * specific configuration values by combining defaults and options provided at
+ * runtime.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Components
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Components
+ */
+
+/**
+ * Components_Config_Application:: provides a wrapper that provides application
+ * specific configuration values by combining defaults and options provided at
+ * runtime.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package Components
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Components
+ */
+class Components_Config_Application
+{
+ /**
+ * The generic configuration handler.
+ *
+ * @var Components_Config
+ */
+ private $_config;
+
+ /**
+ * Constructor.
+ *
+ * @param Components_Config $config The generic configuration handler.
+ */
+ public function __construct(
+ Components_Config $config
+ ) {
+ $this->_config = $config;
+ }
+
+ /**
+ * Return the path to the template directory
+ *
+ * @return string The path to the template directory.
+ */
+ public function getTemplateDirectory()
+ {
+ $options = $this->_config->getOptions();
+ if (!isset($options['templatedir'])) {
+ return Components_Constants::getDataDirectory();
+ } else {
+ return $options['templatedir'];
+ }
+ }
+}
)
)
);
+ $parser->addOption(
+ new Horde_Argv_Option(
+ '-t',
+ '--templatedir',
+ array(
+ 'action' => 'store',
+ 'help' => 'Location of a template directory that contains template definitions (see the data directory of this package to get an impression of which templates are available).'
+ )
+ )
+ );
}
/**
public function getRunnerCiSetup();
/**
+ * Returns the continuous integration pre-build handler.
+ *
+ * @return Components_Runner_CiPrebuild The CI pre-build handler.
+ */
+ public function getRunnerCiPrebuild();
+
+ /**
* Returns the distribution handler for a package.
*
* @return Components_Runner_Distribute The distribution handler.
}
/**
+ * Returns the continuous integration pre-build handler.
+ *
+ * @return Components_Runner_CiPrebuild The CI pre-build handler.
+ */
+ public function getRunnerCiPrebuild()
+ {
+ return $this->getInstance('Components_Runner_CiPrebuild');
+ }
+
+ /**
* Returns the distribution handler for a package.
*
* @return Components_Runner_Distribute The distribution handler.
{
$options = $config->getOptions();
//@todo Split into two different runners here
- if (!empty($options['cisetup']) | !empty($options['ciprebuild'])) {
+ if (!empty($options['cisetup'])) {
$this->_dependencies->getRunnerCiSetup()->run();
}
+ if (!empty($options['ciprebuild'])) {
+ $this->_dependencies->getRunnerCiPrebuild()->run();
+ }
}
}
'help' => 'Prepare the component package in the specified DISTRIBUTE location'
)
),
- new Horde_Argv_Option(
- '-t',
- '--template',
- array(
- 'action' => 'store',
- 'help' => 'Location of a template that will be rewritten into the final package definition.'
- )
- ),
);
}
--- /dev/null
+<?php
+/**
+ * Components_Runner_CiPrebuild:: prepares a continuous integration setup for a
+ * component.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Components
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Components
+ */
+
+/**
+ * Components_Runner_CiPrebuild:: prepares a continuous integration setup for a
+ * component.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package Components
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Components
+ */
+class Components_Runner_CiPrebuild
+{
+ /**
+ * The configuration for the current job.
+ *
+ * @var Components_Config
+ */
+ private $_config;
+
+ /**
+ * The application configuration.
+ *
+ * @var Components_Config_Application
+ */
+ private $_config_application;
+
+ /**
+ * The package handler.
+ *
+ * @var Components_Pear_Package
+ */
+ private $_package;
+
+ /**
+ * Constructor.
+ *
+ * @param Components_Config $config The configuration for the
+ * current job.
+ * @param Components_Config_Application $cfgapp The application
+ * configuration.
+ * @param Components_Pear_InstallLocation $location Represents the install
+ * location and its
+ * corresponding configuration.
+ * @param Components_Pear_Package $package Package handler.
+ */
+ public function __construct(
+ Components_Config $config,
+ Components_Config_Application $cfgapp,
+ Components_Pear_InstallLocation $location,
+ Components_Pear_Package $package
+ ) {
+ $this->_config = $config;
+ $this->_config_application = $cfgapp;
+ $this->_location = $location;
+ $this->_package = $package;
+ }
+
+ public function run()
+ {
+ $options = $this->_config->getOptions();
+ $arguments = $this->_config->getArguments();
+ $pkgfile = $arguments[0] . DIRECTORY_SEPARATOR . 'package.xml';
+ $name = basename($arguments[0]);
+ if (basename(dirname($arguments[0])) == 'framework') {
+ $origin = 'framework' . DIRECTORY_SEPARATOR . $name;
+ } else {
+ $origin = $name;
+ }
+ $test_path = strtr($name, '_', '/');
+
+ if (!isset($options['toolsdir'])) {
+ $options['toolsdir'] = 'php-hudson-tools/workspace/pear/pear';
+ }
+ if (!isset($options['pearrc'])) {
+ throw new Components_Exception(
+ 'You are required to set the path to a PEAR environment for this package'
+ );
+ }
+
+ $this->_location->setLocation(
+ dirname($options['pearrc']),
+ basename($options['pearrc'])
+ );
+ $this->_package->setEnvironment($this->_location);
+ $this->_package->setPackage($pkgfile);
+ $description = $this->_package->getPackageFile()->getDescription();
+
+ $in = file_get_contents(
+ $this->_config_application->getTemplateDirectory()
+ . DIRECTORY_SEPARATOR . 'hudson-component-build.xml.template',
+ 'r'
+ );
+ file_put_contents(
+ $options['ciprebuild'] . DIRECTORY_SEPARATOR . 'build.xml',
+ sprintf($in, $options['toolsdir'])
+ );
+ $in = file_get_contents(
+ $this->_config_application->getTemplateDirectory()
+ . DIRECTORY_SEPARATOR . 'hudson-component-phpunit.xml.template',
+ 'r'
+ );
+ file_put_contents(
+ $options['ciprebuild'] . DIRECTORY_SEPARATOR . 'phpunit.xml',
+ sprintf($in, $name, $test_path)
+ );
+ }
+}
private $_config;
/**
+ * The application configuration.
+ *
+ * @var Components_Config_Application
+ */
+ private $_config_application;
+
+ /**
* The package handler.
*
* @var Components_Pear_Package
*
* @param Components_Config $config The configuration for the
* current job.
+ * @param Components_Config_Application $cfgapp The application
+ * configuration.
* @param Components_Pear_InstallLocation $location Represents the install
* location and its
* corresponding configuration.
*/
public function __construct(
Components_Config $config,
+ Components_Config_Application $cfgapp,
Components_Pear_InstallLocation $location,
Components_Pear_Package $package
) {
- $this->_config = $config;
- $this->_location = $location;
- $this->_package = $package;
+ $this->_config = $config;
+ $this->_config_application = $cfgapp;
+ $this->_location = $location;
+ $this->_package = $package;
}
public function run()
$this->_package->setPackage($pkgfile);
$description = $this->_package->getPackageFile()->getDescription();
- if (!empty($options['cisetup'])) {
- $in = file_get_contents(
- Components_Constants::getDataDirectory()
- . DIRECTORY_SEPARATOR . 'hudson-component-config.xml.template',
- 'r'
- );
- file_put_contents(
- $options['cisetup'] . DIRECTORY_SEPARATOR . 'config.xml',
- sprintf($in, $origin, 'horde', $options['toolsdir'], $description)
- );
- }
-
- if (!empty($options['ciprebuild'])) {
- $in = file_get_contents(
- Components_Constants::getDataDirectory()
- . DIRECTORY_SEPARATOR . 'hudson-component-build.xml.template',
- 'r'
- );
- file_put_contents(
- $options['ciprebuild'] . DIRECTORY_SEPARATOR . 'build.xml',
- sprintf($in, $options['toolsdir'])
- );
- $in = file_get_contents(
- Components_Constants::getDataDirectory()
- . DIRECTORY_SEPARATOR . 'hudson-component-phpunit.xml.template',
- 'r'
- );
- file_put_contents(
- $options['ciprebuild'] . DIRECTORY_SEPARATOR . 'phpunit.xml',
- sprintf($in, $name, $test_path)
- );
- }
+ $in = file_get_contents(
+ $this->_config_application->getTemplateDirectory()
+ . DIRECTORY_SEPARATOR . 'hudson-component-config.xml.template',
+ 'r'
+ );
+ file_put_contents(
+ $options['cisetup'] . DIRECTORY_SEPARATOR . 'config.xml',
+ sprintf($in, $origin, 'horde', $options['toolsdir'], $description)
+ );
}
}
)
->then('the CI build script will be installed.');
}
+
+ /**
+ * @scenario
+ */
+ public function theCisetupOptionCreatesABaseCiConfigurationForAComponentFromAUserTemplate()
+ {
+ $this->given('the default Components setup')
+ ->when(
+ 'calling the package with the cisetup, pearrc, template options and path',
+ dirname(dirname(dirname(dirname(__FILE__)))) . '/fixture/simple'
+ )
+ ->then('the CI configuration will be installed according to the specified template.');
+ }
+
+ /**
+ * @scenario
+ */
+ public function theCiprebuildOptionCreatesABaseCiConfigurationForAComponentFromAUserTemplate()
+ {
+ $this->given('the default Components setup')
+ ->when(
+ 'calling the package with the ciprebuild, pearrc, template options and path',
+ dirname(dirname(dirname(dirname(__FILE__)))) . '/fixture/simple'
+ )
+ ->then('the CI build script will be installed according to the specified template.');
+ }
}
\ No newline at end of file
);
$world['output'] = $this->_callUnstrictComponents();
break;
+ case 'calling the package with the cisetup, pearrc, template options and path':
+ $tmp = $this->_getTemporaryDirectory();
+ $_SERVER['argv'] = array(
+ 'horde-components',
+ '--cisetup=' . $tmp,
+ '--pearrc=' . $tmp . DIRECTORY_SEPARATOR . '.pearrc',
+ '--templatedir=' . dirname(__FILE__) . '/fixture/templates',
+ $arguments[0]
+ );
+ $world['output'] = $this->_callUnstrictComponents();
+ break;
+ case 'calling the package with the ciprebuild, pearrc, template options and path':
+ $tmp = $this->_getTemporaryDirectory();
+ $_SERVER['argv'] = array(
+ 'horde-components',
+ '--ciprebuild=' . $tmp,
+ '--pearrc=' . $tmp . DIRECTORY_SEPARATOR . '.pearrc',
+ '--templatedir=' . dirname(__FILE__) . '/fixture/templates',
+ $arguments[0]
+ );
+ $world['output'] = $this->_callUnstrictComponents();
+ break;
case 'calling the package with the install option and a Horde element':
$_SERVER['argv'] = array(
'horde-components',
)
);
break;
+ case 'the CI configuration will be installed according to the specified template.':
+ $this->assertEquals(
+ "CONFIG.XML\n",
+ file_get_contents(
+ $this->_temp_dir . DIRECTORY_SEPARATOR
+ . 'config.xml'
+ )
+ );
+ break;
+ case 'the CI build script will be installed according to the specified template.':
+ $this->assertEquals(
+ "BUILD.XML\n",
+ file_get_contents(
+ $this->_temp_dir . DIRECTORY_SEPARATOR
+ . 'build.xml'
+ )
+ );
+ break;
case 'the call will fail with':
$this->assertContains(
$arguments[0],
--- /dev/null
+CONFIG.XML
--- /dev/null
+PHPUNIT.XML