From 3891e435c1e6dd1449dcaadfe2713b5dca42575a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Thu, 1 Nov 2018 23:53:36 +0100 Subject: [PATCH] Added a build system based on Robo --- RoboFile.php | 89 +++++++++++++++++++++++++++++++++++ lib/models/TeamPermission.php | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 RoboFile.php diff --git a/RoboFile.php b/RoboFile.php new file mode 100644 index 0000000..58c088d --- /dev/null +++ b/RoboFile.php @@ -0,0 +1,89 @@ +_cleanDir('var'); + $this->_deleteDir(['build', 'doc/api', 'web']); + } + + /** + * Uploads the results of the code coverage. + */ + function coverage(): void { + $this->_exec('coveralls var/coverage.xml'); + } + + /** + * Builds the documentation. + */ + function doc(): void { + $this->_exec('phpdoc'); + } + + /** + * Performs the static analysis of source code. + */ + function lint(): void { + $this->_exec('php -l example/main.php'); + $this->_exec('phpstan analyse'); + } + + /** + * Runs the test suites. + * @return Result The task result. + */ + function test(): Result { + return $this->taskPhpUnit()->run(); + } + + /** + * Upgrades the project to the latest revision. + */ + function upgrade(): void { + $composer = escapeshellarg(PHP_OS_FAMILY == 'Windows' ? 'C:\Program Files\PHP\share\composer.phar' : '/usr/local/bin/composer'); + $this->taskExecStack()->stopOnFail() + ->exec('git reset --hard') + ->exec('git fetch --all --prune') + ->exec('git pull --rebase') + ->exec("php $composer update --no-interaction") + ->run(); + } + + /** + * Increments the version number of the package. + * @param string $component The part in the version number to increment. + */ + function version(string $component = 'patch'): void { + $this->taskSemVer('.semver')->increment($component)->run(); + } + + /** + * Watches for file changes. + */ + function watch(): void { + $this->taskWatch() + ->monitor(['lib', 'test'], function() { $this->test(); }) + ->run(); + } +} diff --git a/lib/models/TeamPermission.php b/lib/models/TeamPermission.php index b734623..b977398 100644 --- a/lib/models/TeamPermission.php +++ b/lib/models/TeamPermission.php @@ -1,6 +1,6 @@