Last active
January 29, 2016 18:19
-
-
Save wxactly/eff087bf1620a4d0cd78 to your computer and use it in GitHub Desktop.
ThinkShout/Cascade RoboFile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This is project's console commands configuration for Robo task runner. | |
* | |
* @see http://robo.li/ | |
*/ | |
class RoboFile extends \Robo\Tasks | |
{ | |
use \Robo\Common\Timer; | |
/** | |
* Run Drupal tests. | |
* | |
* @param string $group Test group(s) to be run, separated by commas. | |
* | |
* @return \Robo\Result | |
*/ | |
public function test($group = 'Cascade') { | |
return $this->taskExec('php') | |
->arg('public/scripts/run-tests.sh') | |
->arg($group) | |
->run(); | |
} | |
/** | |
* Clean Drupal tests. | |
* | |
* @return \Robo\Result | |
*/ | |
public function testClean() { | |
return $this->taskExec('php') | |
->arg('public/scripts/run-tests.sh') | |
->arg('--clean') | |
->run(); | |
} | |
/** | |
* Import a sql database to the current site. | |
* | |
* @param string $path Path to a sql db dump. | |
* | |
* @return \Robo\Result | |
*/ | |
public function import($path) { | |
$this->say('You will destroy data in your current site and replace with data from ' . $path); | |
if ($this->confirm('Do you really want to continue?')) { | |
return $this->taskExecStack() | |
->stopOnFail() | |
->dir('public') | |
->exec('drush sql-drop -y') | |
->exec('$(drush sql-connect) < ' . $path) | |
->run(); | |
} | |
} | |
/** | |
* Cascade ts dev scaffold process for converting a live database. | |
* | |
* @return \Robo\Result | |
*/ | |
public function scaffold() { | |
$this->startTimer(); | |
$tasks[] = $this->taskExecStack() | |
->stopOnFail() | |
->dir('public') | |
->exec('chmod 755 sites/default'); | |
$tasks[] = $this->taskGitStack() | |
->checkout('ts_dev_scaffold'); | |
$tasks[] = $this->taskExecStack() | |
->stopOnFail() | |
->dir('public') | |
->exec('brew services restart memcached') | |
->exec('drush rr') | |
->exec('drush updb -y'); | |
$tasks[] = $this->taskGitStack() | |
->checkout('ts_dev'); | |
$tasks[] = $this->taskExecStack() | |
->stopOnFail() | |
->dir('public') | |
->exec('brew services restart memcached') | |
->exec('drush rr') | |
->exec('drush updb -y') | |
->exec('drush fra -y'); | |
foreach ($tasks as $task) { | |
$result = $task->run(); | |
if (!$result->wasSuccessful()) { | |
return $result; | |
} | |
} | |
$this->stopTimer(); | |
$minutes = intval($this->getExecutionTime() / 60); | |
$seconds = intval($this->getExecutionTime() % 60); | |
$this->say('ts dev scaffold success (' . $minutes . 'm ' . $seconds . 's)'); | |
return TRUE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment