From 327f442ebb9e66448907625b3325f3302be20695 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Thu, 2 Feb 2017 19:32:17 +0700 Subject: [PATCH] Small content fixes --- README.md | 2 +- composer.json | 4 +- docs/en/README.md | 2 +- docs/en/config.md | 62 -------------------- docs/en/configuring.md | 53 ++++++++++++++--- docs/en/configuring_project.md | 75 ++++++++++++++++++++++++ docs/en/plugins/email.md | 3 +- src/PHPCensor/Command/InstallCommand.php | 3 + src/PHPCensor/Plugin/Util/Executor.php | 1 - 9 files changed, 127 insertions(+), 78 deletions(-) delete mode 100644 docs/en/config.md create mode 100644 docs/en/configuring_project.md diff --git a/README.md b/README.md index 7f6c7415..ee59add4 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ complete: default_mailto_address: admin@php-censor.local ``` -More details about [configuring project](docs/en/config.md). +More details about [configuring project](docs/en/configuring_project.md). Installing ---------- diff --git a/composer.json b/composer.json index 5d40f176..715e7e29 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { "name": "corpsee/php-censor", - "description": "PHP Censor is a fork of PHPCI and is a open source continuous integration tool specifically designed for PHP", + "description": "PHP Censor is a open source self-hosted continuous integration server for PHP projects (Fork of PHPCI)", "minimum-stability": "stable", "type": "application", - "keywords": ["php", "php-censor", "ci", "continuous integration"], + "keywords": ["php", "php-censor", "phpci", "ci-server", "testing", "self-hosted", "open-source", "ci", "continuous integration"], "homepage": "https://github.com/corpsee/php-censor", "license": "BSD-2-Clause", "authors": [ diff --git a/docs/en/README.md b/docs/en/README.md index ab0057de..9f596185 100644 --- a/docs/en/README.md +++ b/docs/en/README.md @@ -8,7 +8,7 @@ Getting Started * [Adding a Virtual Host](virtual_host.md) * [Run builds using a worker](workers/worker.md) * [Run builds using cronjob](workers/cron.md) -* [Adding PHP Censor Support to Your Projects](config.md) +* [Adding PHP Censor Support to Your Projects](configuring_project.md) * [Setting up Logging](logging.md) * [Updating PHP Censor](updating.md) * [Configuring PHP Censor](configuring.md) diff --git a/docs/en/config.md b/docs/en/config.md deleted file mode 100644 index 29027ecd..00000000 --- a/docs/en/config.md +++ /dev/null @@ -1,62 +0,0 @@ -Adding PHP Censor Support to Your Projects -========================================== - -Similar to Travis CI, to support PHP Censor in your project, you simply need to add a `.php-censor.yml` (`phpci.yml`/`.phpci.yml` for backward compatibility with PHPCI) file to the root of -your repository. The file should look something like this: - -```yml -build_settings: - clone_depth: 1 # depth of 1 is a shallow clone, remove this line to clone entire repo - ignore: - - "vendor" - - "tests" - mysql: - host: "localhost" - user: "root" - pass: "" - -setup: - mysql: - - "DROP DATABASE IF EXISTS test;" - - "CREATE DATABASE test;" - - "GRANT ALL PRIVILEGES ON test.* TO test@'localhost' IDENTIFIED BY 'test';" - composer: - action: "install" - -test: - php_unit: - config: - - "PHPUnit-all.xml" - - "PHPUnit-ubuntu-fix.xml" - directory: - - "tests/" - run_from: "phpunit/" - coverage: "tests/logs/coverage" - php_mess_detector: - allow_failures: true - php_code_sniffer: - standard: "PSR2" - php_cpd: - allow_failures: true - grunt: - task: "build" - -complete: - mysql: - host: "localhost" - user: "root" - pass: "" - - "DROP DATABASE IF EXISTS test;" -``` - -As mentioned earlier, PHP Censor is powered by plugins, there are several phases in which plugins can be run: - -* `setup` - This phase is designed to initialise the build procedure. -* `test` - The tests that should be run during the build. Plugins run during this phase will contribute to the success or failure of the build. -* `complete` - Always called when the `test` phase completes, regardless of success or failure. **Note** that is you do any DB stuff here, you will need to add the DB credentials to this section as well, as it runs in a separate instance. -* `success` - Called upon success of the `test` phase. -* `failure` - Called upon failure of the `test` phase. -* `fixed` - Called upon success of the `test` phase if the previous build of the branch was a success. -* `broken` - Called upon failure of the `test` phase if the previous build of the branch was a failure. - -The `ignore` section is merely an array of paths that should be ignored in all tests (where possible.) diff --git a/docs/en/configuring.md b/docs/en/configuring.md index 62cb30b0..777e18a9 100644 --- a/docs/en/configuring.md +++ b/docs/en/configuring.md @@ -4,17 +4,52 @@ Configuring PHP Censor The PHP Censor configuration on the server is automatically generated into the `config.yml` file during installation. One might need to also edit the file manually. -For example, one could log into PHP Censor and go into the settings to disable it. But if you have already set up a -username/password pair and have forgotten the password, and if the server is on a local network, and it's not sending -the `forgot password` email, then editing the config file manually would be handy. To do so, just edit the `php-censor` -section in the config file (which is in [yaml format](https://en.wikipedia.org/wiki/YAML)), and add +There is `config.yml` example: ```yml +b8: + database: + servers: + read: + - host: localhost + port: 3306 + write: + - host: localhost + port: 3306 + type: mysql # Database type: "mysql" or "pgsql" + name: php-censor-db + username: php-censor-user + password: php-censor-password php-censor: + language: en + per_page: 10 + url: 'http://php-censor.local' + email_settings: + from_address: 'no-reply@php-censor.local' + smtp_address: + queue: + use_queue: true + host: localhost + name: php-censor-queue + lifetime: 600 + github: + token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' + comments: + commit: false # This option allow/deny to post comments to Github commit + pull_request: false # This option allow/deny to post comments to Github Pull Request + build: + remove_builds: true # This option allow/deny build cleaning security: - disable_auth: true - default_user_id: 1 + disable_auth: false # This option allows/deny you to disable authentication for PHP Censor + default_user_id: 1 # Default user when authentication disabled + auth_providers: # Authentication providers + internal: + type: internal # Default provider (PHP Censor internal authentication) + ldap: + type: ldap # Your LDAP provider + data: + host: 'ldap.php-censor.local' + port: 389 + base_dn: 'dc=php-censor,dc=local' + mail_attribute: mail ``` - -where you can get the `default_user_id` by logging into the database and selecting your user ID from the `users` table in -the PHP Censor database. diff --git a/docs/en/configuring_project.md b/docs/en/configuring_project.md new file mode 100644 index 00000000..434d83a7 --- /dev/null +++ b/docs/en/configuring_project.md @@ -0,0 +1,75 @@ +Adding PHP Censor Support to Your Projects +========================================== + +Similar to Travis CI, to support PHP Censor in your project, you simply need to add a `.php-censor.yml` +(`phpci.yml`/`.phpci.yml` for backward compatibility with PHPCI) file to the root of your repository. The file should +look something like this: + +```yml +build_settings: + clone_depth: 1 # depth of 1 is a shallow clone, remove this line to clone entire repo + ignore: + - "vendor" + - "tests" + mysql: + host: "localhost" + user: "root" + pass: "" + +setup: + mysql: + - "DROP DATABASE IF EXISTS test;" + - "CREATE DATABASE test;" + - "GRANT ALL PRIVILEGES ON test.* TO test@'localhost' IDENTIFIED BY 'test';" + composer: + action: "install" + +test: + php_unit: + config: + - "PHPUnit-all.xml" + - "PHPUnit-ubuntu-fix.xml" + directory: + - "tests/" + run_from: "phpunit/" + coverage: "tests/logs/coverage" + php_mess_detector: + allow_failures: true + php_code_sniffer: + standard: "PSR2" + php_cpd: + allow_failures: true + grunt: + task: "build" + +complete: + mysql: + host: "localhost" + user: "root" + pass: "" + - "DROP DATABASE IF EXISTS test;" + +branch-dev: # Branch-specific config (for "dev" branch) + run-option: replace # "run-option" parameter can be set to 'replace', 'after' or 'before' + test: + grunt: + task: "build-dev" +``` + +As mentioned earlier, PHP Censor is powered by plugins, there are several phases in which plugins can be run: + +* `setup` - This phase is designed to initialise the build procedure. + +* `test` - The tests that should be run during the build. Plugins run during this phase will contribute to the success or failure of the build. + +* `complete` - Always called when the `test` phase completes, regardless of success or failure. **Note** that is you do any DB stuff here, you will need to add the DB credentials to this section as well, as it runs in a separate instance. + +* `success` - Called upon success of the `test` phase. + +* `failure` - Called upon failure of the `test` phase. + +* `fixed` - Called upon success of the `test` phase if the previous build of the branch was a success. + +* `broken` - Called upon failure of the `test` phase if the previous build of the branch was a failure. + +The `ignore` section is merely an array of paths that should be ignored in all tests (where possible). diff --git a/docs/en/plugins/email.md b/docs/en/plugins/email.md index 23d15675..996fdaa2 100644 --- a/docs/en/plugins/email.md +++ b/docs/en/plugins/email.md @@ -14,12 +14,11 @@ Configuration * **cc** - A list of addresses that will receive a copy of every emails sent. * **template** - The template to use, options are short and long. Default is short on success and long otherwise. - **Note:** _This plugin will only work if you configured email settings during installation or configured them later in Admin Options > Settings > Email Settings_ ### Examples -See [Adding PHP Censor Support to Your Projects](../config.md) for more information about how to configure plugins. +See [Adding PHP Censor Support to Your Projects](../configuring_project.md) for more information about how to configure plugins. Send an email to the committer as well as one@exameple.com if a build fails: ```yml diff --git a/src/PHPCensor/Command/InstallCommand.php b/src/PHPCensor/Command/InstallCommand.php index d3a7c4bc..ba59c918 100644 --- a/src/PHPCensor/Command/InstallCommand.php +++ b/src/PHPCensor/Command/InstallCommand.php @@ -268,6 +268,9 @@ class InstallCommand extends Command { $skipQueueConfig = [ 'queue-use' => false, + 'host' => null, + 'name' => null, + 'lifetime' => 600 ]; if (!$input->getOption('queue-use')) { diff --git a/src/PHPCensor/Plugin/Util/Executor.php b/src/PHPCensor/Plugin/Util/Executor.php index 8af07545..17721af7 100644 --- a/src/PHPCensor/Plugin/Util/Executor.php +++ b/src/PHPCensor/Plugin/Util/Executor.php @@ -93,7 +93,6 @@ class Executor $plugins = $branchConfig[$stage]; $runOption = 'after'; - if (!empty($branchConfig['run-option'])) { $runOption = $branchConfig['run-option']; }