|
@ -2,10 +2,20 @@ |
|
|
|
|
|
|
|
|
use Robo\Result; |
|
|
use Robo\Result; |
|
|
|
|
|
|
|
|
class RoboFile extends \Robo\Tasks { |
|
|
|
|
|
const BASE = __DIR__.\DIRECTORY_SEPARATOR; |
|
|
|
|
|
const BASE_TEST = self::BASE."tests".\DIRECTORY_SEPARATOR; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const BASE = __DIR__.\DIRECTORY_SEPARATOR; |
|
|
|
|
|
const BASE_TEST = BASE."tests".\DIRECTORY_SEPARATOR; |
|
|
|
|
|
define("IS_WIN", defined("PHP_WINDOWS_VERSION_MAJOR")); |
|
|
|
|
|
|
|
|
|
|
|
function norm(string $path): string { |
|
|
|
|
|
$out = realpath($path); |
|
|
|
|
|
if (!$out) { |
|
|
|
|
|
$out = str_replace(["/", "\\"], \DIRECTORY_SEPARATOR, $path); |
|
|
|
|
|
} |
|
|
|
|
|
return $out; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class RoboFile extends \Robo\Tasks { |
|
|
/** Runs the typical test suite |
|
|
/** Runs the typical test suite |
|
|
* |
|
|
* |
|
|
* Arguments passed to the task are passed on to PHPUnit. Thus one may, for |
|
|
* Arguments passed to the task are passed on to PHPUnit. Thus one may, for |
|
@ -50,7 +60,7 @@ class RoboFile extends \Robo\Tasks { |
|
|
public function coverage(array $args): Result { |
|
|
public function coverage(array $args): Result { |
|
|
// run tests with code coverage reporting enabled |
|
|
// run tests with code coverage reporting enabled |
|
|
$exec = $this->findCoverageEngine(); |
|
|
$exec = $this->findCoverageEngine(); |
|
|
return $this->runTests($exec, "coverage", array_merge(["--coverage-html", self::BASE_TEST."coverage"], $args)); |
|
|
return $this->runTests($exec, "coverage", array_merge(["--coverage-html", BASE_TEST."coverage"], $args)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** Produces a code coverage report, with redundant tests |
|
|
/** Produces a code coverage report, with redundant tests |
|
@ -65,12 +75,12 @@ class RoboFile extends \Robo\Tasks { |
|
|
public function coverageFull(array $args): Result { |
|
|
public function coverageFull(array $args): Result { |
|
|
// run tests with code coverage reporting enabled |
|
|
// run tests with code coverage reporting enabled |
|
|
$exec = $this->findCoverageEngine(); |
|
|
$exec = $this->findCoverageEngine(); |
|
|
return $this->runTests($exec, "typical", array_merge(["--coverage-html", self::BASE_TEST."coverage"], $args)); |
|
|
return $this->runTests($exec, "typical", array_merge(["--coverage-html", BASE_TEST."coverage"], $args)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** Runs the coding standards fixer */ |
|
|
/** Runs the coding standards fixer */ |
|
|
public function clean($opts = ['demo|d' => false]): Result { |
|
|
public function clean($opts = ['demo|d' => false]): Result { |
|
|
$t = $this->taskExec(realpath(self::BASE."vendor/bin/php-cs-fixer")); |
|
|
$t = $this->taskExec(norm(BASE."vendor/bin/php-cs-fixer")); |
|
|
$t->arg("fix"); |
|
|
$t->arg("fix"); |
|
|
if ($opts['demo']) { |
|
|
if ($opts['demo']) { |
|
|
$t->args("--dry-run", "--diff")->option("--diff-format", "udiff"); |
|
|
$t->args("--dry-run", "--diff")->option("--diff-format", "udiff"); |
|
@ -79,7 +89,7 @@ class RoboFile extends \Robo\Tasks { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected function findCoverageEngine(): string { |
|
|
protected function findCoverageEngine(): string { |
|
|
if ($this->isWindows()) { |
|
|
if (IS_WIN) { |
|
|
$dbg = dirname(\PHP_BINARY)."\\phpdbg.exe"; |
|
|
$dbg = dirname(\PHP_BINARY)."\\phpdbg.exe"; |
|
|
$dbg = file_exists($dbg) ? $dbg : ""; |
|
|
$dbg = file_exists($dbg) ? $dbg : ""; |
|
|
} else { |
|
|
} else { |
|
@ -92,12 +102,8 @@ class RoboFile extends \Robo\Tasks { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected function isWindows(): bool { |
|
|
|
|
|
return defined("PHP_WINDOWS_VERSION_MAJOR"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function blackhole(bool $all = false): string { |
|
|
protected function blackhole(bool $all = false): string { |
|
|
$hole = $this->isWindows() ? "nul" : "/dev/null"; |
|
|
$hole = IS_WIN ? "nul" : "/dev/null"; |
|
|
return $all ? ">$hole 2>&1" : "2>$hole"; |
|
|
return $all ? ">$hole 2>&1" : "2>$hole"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -118,9 +124,9 @@ class RoboFile extends \Robo\Tasks { |
|
|
default: |
|
|
default: |
|
|
throw new \Exception; |
|
|
throw new \Exception; |
|
|
} |
|
|
} |
|
|
$execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit"); |
|
|
$execpath = norm(BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit"); |
|
|
$confpath = realpath(self::BASE_TEST."phpunit.dist.xml") ?: realpath(self::BASE_TEST."phpunit.xml"); |
|
|
$confpath = realpath(BASE_TEST."phpunit.dist.xml") ?: norm(BASE_TEST."phpunit.xml"); |
|
|
$this->taskServer(8000)->host("localhost")->dir(self::BASE_TEST."docroot")->rawArg("-n")->arg(self::BASE_TEST."server.php")->rawArg($this->blackhole())->background()->run(); |
|
|
$this->taskServer(8000)->host("localhost")->dir(BASE_TEST."docroot")->rawArg("-n")->arg(BASE_TEST."server.php")->rawArg($this->blackhole())->background()->run(); |
|
|
return $this->taskExec($executor)->arg($execpath)->option("-c", $confpath)->args(array_merge($set, $args))->run(); |
|
|
return $this->taskExec($executor)->arg($execpath)->option("-c", $confpath)->args(array_merge($set, $args))->run(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -137,7 +143,7 @@ class RoboFile extends \Robo\Tasks { |
|
|
public function package(string $version = null): Result { |
|
|
public function package(string $version = null): Result { |
|
|
// establish which commit to package |
|
|
// establish which commit to package |
|
|
$version = $version ?? $this->askDefault("Commit to package:", "HEAD"); |
|
|
$version = $version ?? $this->askDefault("Commit to package:", "HEAD"); |
|
|
$archive = self::BASE."arsse-$version.tar.gz"; |
|
|
$archive = BASE."arsse-$version.tar.gz"; |
|
|
// start a collection |
|
|
// start a collection |
|
|
$t = $this->collectionBuilder(); |
|
|
$t = $this->collectionBuilder(); |
|
|
// create a temporary directory |
|
|
// create a temporary directory |
|
@ -188,17 +194,17 @@ class RoboFile extends \Robo\Tasks { |
|
|
* The resultant files are suitable for offline viewing and inclusion into release builds |
|
|
* The resultant files are suitable for offline viewing and inclusion into release builds |
|
|
*/ |
|
|
*/ |
|
|
public function manual(array $args): Result { |
|
|
public function manual(array $args): Result { |
|
|
$execpath = escapeshellarg(realpath(self::BASE."vendor/bin/daux")); |
|
|
$execpath = escapeshellarg(norm(BASE."vendor/bin/daux")); |
|
|
$t = $this->collectionBuilder(); |
|
|
$t = $this->collectionBuilder(); |
|
|
$t->taskExec($execpath)->arg("generate")->option("-d", self::BASE."manual")->args($args); |
|
|
$t->taskExec($execpath)->arg("generate")->option("-d", BASE."manual")->args($args); |
|
|
$t->taskDeleteDir(self::BASE."manual/theme"); |
|
|
$t->taskDeleteDir(BASE."manual/theme"); |
|
|
$t->taskDeleteDir(self::BASE."manual/themes/src"); |
|
|
$t->taskDeleteDir(BASE."manual/themes/src"); |
|
|
return $t->run(); |
|
|
return $t->run(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** Serves a live view of the manual using the built-in Web server */ |
|
|
/** Serves a live view of the manual using the built-in Web server */ |
|
|
public function manualLive(array $args): Result { |
|
|
public function manualLive(array $args): Result { |
|
|
$execpath = escapeshellarg(realpath(self::BASE."vendor/bin/daux")); |
|
|
$execpath = escapeshellarg(norm(BASE."vendor/bin/daux")); |
|
|
return $this->taskExec($execpath)->arg("serve")->args($args)->run(); |
|
|
return $this->taskExec($execpath)->arg("serve")->args($args)->run(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -209,8 +215,8 @@ class RoboFile extends \Robo\Tasks { |
|
|
*/ |
|
|
*/ |
|
|
public function manualTheme(array $args): Result { |
|
|
public function manualTheme(array $args): Result { |
|
|
$languages = ["php", "bash", "shell", "xml", "nginx", "apache"]; |
|
|
$languages = ["php", "bash", "shell", "xml", "nginx", "apache"]; |
|
|
$themeout = realpath(self::BASE."docs/theme/arsse/").\DIRECTORY_SEPARATOR; |
|
|
$themeout = norm(BASE."docs/theme/arsse/").\DIRECTORY_SEPARATOR; |
|
|
$dauxjs = realpath(self::BASE."vendor-bin/daux/vendor/daux/daux.io/themes/daux/js/").\DIRECTORY_SEPARATOR; |
|
|
$dauxjs = norm(BASE."vendor-bin/daux/vendor/daux/daux.io/themes/daux/js/").\DIRECTORY_SEPARATOR; |
|
|
// start a collection; this stops after the first failure |
|
|
// start a collection; this stops after the first failure |
|
|
$t = $this->collectionBuilder(); |
|
|
$t = $this->collectionBuilder(); |
|
|
$tmp = $t->tmpDir().\DIRECTORY_SEPARATOR; |
|
|
$tmp = $t->tmpDir().\DIRECTORY_SEPARATOR; |
|
@ -278,9 +284,9 @@ class RoboFile extends \Robo\Tasks { |
|
|
// install dependencies via Yarn |
|
|
// install dependencies via Yarn |
|
|
$t->taskExec("yarn install"); |
|
|
$t->taskExec("yarn install"); |
|
|
// compile the stylesheet |
|
|
// compile the stylesheet |
|
|
$postcss = escapeshellarg(realpath(self::BASE."node_modules/.bin/postcss")); |
|
|
$postcss = escapeshellarg(norm(BASE."node_modules/.bin/postcss")); |
|
|
$themesrc = realpath(self::BASE."docs/theme/src/").\DIRECTORY_SEPARATOR; |
|
|
$themesrc = norm(BASE."docs/theme/src/").\DIRECTORY_SEPARATOR; |
|
|
$themeout = realpath(self::BASE."docs/theme/arsse/").\DIRECTORY_SEPARATOR; |
|
|
$themeout = norm(BASE."docs/theme/arsse/").\DIRECTORY_SEPARATOR; |
|
|
$t->taskExec($postcss)->arg($themesrc."arsse.scss")->option("-o", $themeout."arsse.css"); |
|
|
$t->taskExec($postcss)->arg($themesrc."arsse.scss")->option("-o", $themeout."arsse.css"); |
|
|
// execute the collection |
|
|
// execute the collection |
|
|
return $t->run(); |
|
|
return $t->run(); |
|
|