Added documentation

This commit is contained in:
Dmitry Khomutov 2016-07-17 20:20:35 +06:00
commit fa42071d01
49 changed files with 1255 additions and 0 deletions

19
docs/en/plugins/atoum.md Normal file
View file

@ -0,0 +1,19 @@
Allows you to run [Atoum](https://github.com/atoum/atoum) unit tests.
## Configuration
### Options
- **args** [string, optional] - Allows you to pass command line arguments to Atoum.
- **config** [string, optional] - Path to an Atoum configuration file.
- **directory** [string, optional] - Path in which to run Atom (defaults to the build root).
- **executable** [string, optional] - Allows you to provide a path to the Atom binary (defaults to PHPCI root, vendor/bin, or a system-provided Atom binary).
### Example
```yml
test:
atoum:
args: "command line arguments go here"
config: "path to config file"
directory: "directory to run tests"
executable: "path to atoum executable"
```

14
docs/en/plugins/behat.md Normal file
View file

@ -0,0 +1,14 @@
A very simple plugin for running [Behat](http://behat.org/) BDD tests.
## Configuration
### Options
- **executable** [string, optional] - Allows you to provide a path to the Behat binary (defaults to PHPCI root, vendor/bin, or a system-provided Behat binary).
- **features** [string, optional] - Provide a list of Behat features to run.
### Example
```yml
test:
behat:
executable: "path to behat binary"
features: "command line arguments"
```

View file

@ -0,0 +1,20 @@
This plugin joins a [Campfire](https://campfirenow.com/) room and sends a user-defined message, for example a "Build Succeeded" message.
## Configuration
### Options
- **authToken** [string, required] - Your Campfire user authentication token.
- **message** [string, required] - The message to send to the room.
- **roomId** [string, required] - Your Campfire room ID number.
- **url** [string, required] - Your Campfire chat room URL.
### Example
```yml
build_settings:
campfire:
authToken: "campfire auth token"
roomId: "campfire room ID"
url: "campfire URL"
success:
campfire:
message: "Build succeeded!"
```

View file

@ -0,0 +1,16 @@
Works through a list of files to remove from your build. Useful when used in combination with Copy Build or Package Build.
### Configuration Options:
* **remove** - Required - An array of files and / or directories to remove.
### Example Configuration:
```yml
complete:
clean_build:
remove:
- composer.json
- composer.phar
- config.dev.php
```

View file

@ -0,0 +1,42 @@
A simple plugin that allows you to run [Codeception](http://codeception.com/) tests.
### Configuration Options:
* **config** - Required - Can be either a single string pointing to a Codeception configuration file, or an array of configuration file paths. By default this is called `codeception.yml` and will be in the root of your project.
* **args** - Optional - The string of arguments to be passed to the run command. **Important**, due to the assumption made on line [132](https://github.com/Block8/PHPCI/blob/master/PHPCI/Plugin/Codeception.php#L132) regarding the value of `--xml` being the next argument which will not be correct if the user provides arguments using this config param, you must specify `report.xml` before any user input arguments to satisfy the report processing on line [146](https://github.com/Block8/PHPCI/blob/master/PHPCI/Plugin/Codeception.php#L146)
* **path** - Optional - The path from the root of your project to the root of the codeception _output directory
##### Default values
- config
- `codeception.yml` if it exists in the root of the project
- `codeception.dist.yml` if it exists in the root of the project
- null if no option provided and the above two fail, this will cause an Exception to be thrown on execution
- args
- Empty string
- path
- `tests/_output/`
##### Example on running codeception with default settings (when tests are in tests/ directory):
```
codeception:
config: "codeception.yml"
path: "tests/"
```
##### Example usage against the Yii2 framework
```
codeception:
allow_failures: false
config: "tests/codeception.yml"
path: "tests/codeception/_output/"
args: "report.xml --no-ansi --coverage-html"
```
The path value will need to be changed if you have your tests directory somewhere other than in the root of the project.

View file

@ -0,0 +1,24 @@
Allows you to run Composer within your build, to install dependencies prior to testing. Best run as a "setup" stage plugin.
## Configuration
### Options
* **directory** [optional, string] - Directory within which you want Composer to run (default: build root)
* **action** [optional, string, update|install] - Action you wish Composer to run (default: 'install')
* **prefer_dist** [optional, bool, true|false] - whether Composer should run with the `--prefer-dist` flag (default: false)
### Example
```yml
setup:
composer:
directory: "my/composer/dir"
action: "update"
prefer_dist: true
```
## Warning
If you are using a Composer private repository like Satis, with HTTP authentication, you must check your username and password inside the ```auth.json``` file. PHPCI uses the ```--no-interaction``` flag, so it will not warn if you must provide that info.
For more info, please check the Composer documentation.
https://getcomposer.org/doc/04-schema.md#config

View file

@ -0,0 +1,7 @@
Copies all files from your build, with the exception of those in the "ignore" build settings property, to a directory of your choosing.
### Configuration Options:
* **directory** - Required - The directory to which you want to copy the build.
* **respect_ignore** - Optional - Whether to respect the global "ignore" setting when copying files. Default is false.
* **wipe** - Optional - Set true if you want destination directory to be cleared before copying. Default is false.

View file

@ -0,0 +1,16 @@
Triggers a deployment of the project to run via [Deployer](http://phpdeployment.org)
**Configuration Options:**
### Options
* **webhook_url** [required, string] - The URL to your Deployer WebHook
* **reason** [optional, string] - Your deployment message. Default - PHPCI Build #%BUILD% - %COMMIT_MESSAGE%
* **update_only** [optional, bool, true|false] - Whether the deployment should only be run if the currently deployed branches matches the one being built. Default - true
### Example
```yaml
success:
deployer:
webhook_url: "https://deployer.example.com/deploy/QZaF1bMIUqbMFTmKDmgytUuykRN0cjCgW9SooTnwkIGETAYhDTTYoR8C431t"
reason: "PHPCI Build #%BUILD% - %COMMIT_MESSAGE%"
update_only: true
```

30
docs/en/plugins/email.md Normal file
View file

@ -0,0 +1,30 @@
Sends a build status email.
### Configuration Options:
* **committer** - Whether or not to send the email to the committer that prompted this build.
* **addresses** - A list of addresses to send to.
* **default_mailto_address** - A default address to send to.
* **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_
### Configuration Example
See [Adding PHPCI Support to Your Projects](https://www.phptesting.org/wiki/Adding-PHPCI-Support-to-Your-Projects) 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
failure:
email:
committer: true
default_mailto_address: one@example.com
```
Send an email to one@example.com every time a build is run:
```yml
complete:
email:
default_mailto_address: one@example.com
```

9
docs/en/plugins/env.md Normal file
View file

@ -0,0 +1,9 @@
Sets environment variables on the PHPCI server for the build.
### Sample Configuration:
```yml
setup:
env:
APPLICATION_ENV: "development"
```

18
docs/en/plugins/grunt.md Normal file
View file

@ -0,0 +1,18 @@
This plugin runs [Grunt](http://gruntjs.com/) tasks.
## Configuration
### Options
- **directory** [string, optional] - The directory in which to run Grunt (defaults to build root.)
- **grunt** [string, optional] - Allows you to provide a path to Grunt (defaults to PHPCI root, vendor/bin, or a system-provided Grunt).
- **gruntfile** [string, optional] - Gruntfile to run (defaults to `Gruntfile.js`).
- **task** [string, optional] - The Grunt task to run.
### Example
```yml
test:
grunt:
directory: "path to run grunt in"
grunt: "path to grunt executable"
gruntfile: "gruntfile.js"
task: "css"
```

View file

@ -0,0 +1,26 @@
This plugin joins a [HipChat](https://www.hipchat.com/) room and sends a user-defined message, for example a "Build Succeeded" message.
**Configuration Options:**
| Field | Required? | Description |
|-------|-----------|-------------|
| `authToken` | Yes | Your HipChat API authentication token (v1) |
| `room` | Yes | Your Hipchat room name or ID number. This can also be an array of room names or numbers, and the message will be sent to all rooms. |
| `message` | No | The message to send to the room. Default - `%PROJECT_TITLE% built at %BUILD_URI%` |
| `color` | No | Message color. Valid values: yellow, green, red, purple, gray, random. Default - `yellow`|
| `notify` | No | Whether or not this message should trigger a notification for people in the room (change the tab color, play a sound, etc). Default - `false`. |
Message can be formatted via HTML. Example:
```html
<b>%PROJECT_TITLE%</b> - build <a href="%BUILD_URI%">%BUILD%</a> failed!
```
Configuration example:
```yaml
hipchat_notify:
authToken: 123
room: 456
message: <b>%PROJECT_TITLE%</b> - build <a href="%BUILD_URI%">%BUILD%</a> failed!
color: red
notify: true
```

13
docs/en/plugins/irc.md Normal file
View file

@ -0,0 +1,13 @@
Connects to an IRC server and sends a defined message.
### Configuration Options:
* **message** - Required - The message to send.
### Build Settings
* **irc** - All child properties are required
* **server** - IRC server to connect to.
* **port** - IRC server port, defaults to 6667.
* **room** - The room you wish to send your message to (must start with a #)
* **nick** - The nickname you want the bot to use.

19
docs/en/plugins/lint.md Normal file
View file

@ -0,0 +1,19 @@
This plugin runs PHP's built in Lint (syntax / error check) functionality.
## Configuration
### Options
- **directory** [string, optional] - A single path in which you wish to lint files.
- **directories** [array, optional] - An array of paths in which you wish to lint files. This overrides `directory`.
- **recursive** [bool, optional] - Whether or not you want to recursively check sub-directories of the above (defaults to true).
### Example
```yml
test:
lint:
directory: "single path to lint files"
directories:
- "directory to lint files"
- "directory to lint files"
- "directory to lint files"
recursive: false
```

29
docs/en/plugins/mysql.md Normal file
View file

@ -0,0 +1,29 @@
Connects to a given MySQL server and runs a selection of queries.
### Example Configuration:
```yaml
build_settings:
mysql:
host: 'localhost'
user: 'testuser'
pass: '12345678'
setup:
mysql:
- "CREATE DATABASE my_app_test;"
complete:
mysql:
- "DROP DATABASE my_app_test;"
```
Import SQL from file:
```yaml
setup:
mysql:
import-from-file: # This key name doesn´t matter
import:
database: "foo" # Database name
file: "/path/dump.sql" # Relative path in build folder
```

View file

@ -0,0 +1,16 @@
Builds a tar or zip archive of your build and places it in a directory of your choosing.
### Configuration Options:
* **directory** - Required - Directory in which to put the package file.
* **filename** - Required - File name for the package.
* **format** - Required - `tar` or `zip`
You can use following variables in filename:
* %build.commit%
* %build.id%
* %build.branch%
* %project.title%
* %date%
* %time%

View file

@ -0,0 +1,5 @@
Runs [PDepend](http://pdepend.org/) software metrics.
### Configuration Options:
* **directory** - Required - Directory in which to run PDepend.

19
docs/en/plugins/pgsql.md Normal file
View file

@ -0,0 +1,19 @@
Connects to a given PostgreSQL server and runs a list of queries.
### Example Configuration:
```yaml
build_settings:
pgsql:
host: 'localhost'
user: 'testuser'
pass: '12345678'
setup:
pgsql:
- "CREATE DATABASE my_app_test;"
complete:
pgsql:
- "DROP DATABASE my_app_test;"
```

18
docs/en/plugins/phar.md Normal file
View file

@ -0,0 +1,18 @@
Allows you to create a [Phar](http://php.net/manual/en/book.phar.php) archive from your project.
### Example
```
phar:
directory: /path/to/directory
filename: foobar.phar
regexp: /\.(php|phtml)$/
stub: filestub.php
```
### Configuration Options
* **directory**: `phar` output directory. Default: `%buildpath%`;
* **filename**: `phar` filename inside output directory. Default: `build.phar`;
* **regexp**: regular expression for Phar iterator. Default: `/\.php$/`; and
* **stub**: stub content filename. No default value.

18
docs/en/plugins/phing.md Normal file
View file

@ -0,0 +1,18 @@
This plugin allows you to use the Phing build system to build your project.
### Configuration options:
* **directory** - Relative path to the directory in which you want to run phing.
* **build_file** - Your phing build.xml file.
* **targets** - Which build targets you want to run.
* **properties** - Any custom properties you wish to pass to phing.
* **property_file** - A file containing properties you wish to pass to phing.
### Sample config:
```yml
phing:
build_file: 'build.xml'
targets:
- "build:test"
properties:
config_file: "PHPCI"
```

View file

@ -0,0 +1,33 @@
Runs PHP Code Sniffer against your build.
## Configuration
### Options
* **allowed_warnings** [int, optional] - The warning limit for a successful build.
* **allowed_errors** [int, optional] - The error limit for a successful build.
* **suffixes** [array, optional] - An array of file extensions to check.
* **standard** [string, optional] - The standard against which your files should be checked (defaults to PSR2.)
* **tab_width** [int, optional] - Your chosen tab width.
* **encoding** [string, optional] - The file encoding you wish to check for.
* **path** [string, optional] - Path in which to run PHP Code Sniffer.
* **ignore** [array, optional] - A list of files / paths to ignore, defaults to the build_settings ignore list.
### Example
Simple example where PHPCS will run on app directory, but ignore the views folder, and use PSR-1 and PSR-2 rules for validation:
```yml
test:
php_code_sniffer:
path: "app"
ignore:
- "app/views"
standard: "PSR1,PSR2"
```
For use with an existing project:
```yml
test:
php_code_sniffer:
standard: "/phpcs.xml" # The leading slash is needed to trigger an external ruleset.
# Without it, PHPCI looks for a rule named "phpcs.xml"
allowed_errors: -1 # Even a single error will cause the build to fail. -1 = unlimited
allowed_warnings: -1
```

View file

@ -0,0 +1,18 @@
Runs PHP Copy / Paste Detector against your build.
## Configuration
### Options
* **path** - Optional - Path in which to run PHP Copy/Paste Detector (default: build root).
* **ignore** - Optional - A list of files / paths to ignore (default: build_settings > ignore).
* **standard** [string, optional] - which PSR standard to follow (default: 'PSR1').
### Example
```yml
test:
php_cpd:
standard: "PSR2"
path: "app"
ignore:
- "app/my/path"
```

View file

@ -0,0 +1,21 @@
Runs PHP Coding Standards Fixer against your build.
## Configuration
### Options
* **verbose** [bool, optional] - Whether to run in verbose mode (default: false)
* **diff** [bool, optional] - Whether to run with the `--diff` flag enabled (default: false)
* **level** [string, optional] - `psr0`, `psr1`, `psr2`, or `symphony` (default: all)
* **workingdir** [string, optional] - The directory in which PHP CS Fixer should work (default: build root)
### Example
```yml
test:
php_cs_fixer:
verbose: true
diff: true
level: "psr2"
workingdir: "my/dir/path"
```
## Warning
There is currently a bug with this plugin that will cause an error if you leave the level to default to `all`. That level does not exist and will cause the build to fail. Instead specify the level explicitly until this is fixed.

View file

@ -0,0 +1,16 @@
Runs the PHP Docblock Checker against your build. This tool verifies that all classes and methods have docblocks.
### Configuration Options:
* **allowed_warnings** - Optional - The warning limit for a successful build.
* **path** - Optional - Directory in which PHP Docblock Checker should run.
* **skip_methods** - Optional - Tells the checker to ignore methods that don't have a docblock.
* **skip_classes** - Optional - Tells the checker to ignore classes that don't have a docblock.
### Example config:
```yml
php_docblock_checker:
allowed_warnings: 10
skip_classes: true
```

View file

@ -0,0 +1,14 @@
Runs [PHPLoc](https://github.com/sebastianbergmann/phploc) against your project and records some key metrics.
## Configuration
### Options
* **directory** - Optional - The directory in which phploc should run.
### Example
Run PHPLOC against the app directory only. This will prevent inclusion of code from 3rd party libraries that are included outside of the app directory.
```yml
test:
php_loc:
directory: "app"
```

View file

@ -0,0 +1,30 @@
Runs PHP Mess Detector against your build. Records some key metrics, and also reports errors and warnings.
## Configuration
### Options
- **allowed_warnings** [int, optional] - The warning limit for a successful build (default: 0). -1 disables warnings. Setting allowed_warnings in conjunction with zero_config will override zero_config.
- **suffixes** [array, optional] - An array of file extensions to check (default: 'php')
- **ignore** [array, optional] - An array of files/paths to ignore (default: build_settings > ignore)
- **path** [string, optional] - Directory in which PHPMD should run (default: build root)
- **rules** [array, optional] - Array of rulesets that PHPMD should use when checking your build or a string containing at least one slash, will be treated as path to PHPMD ruleset. See http://phpmd.org/rules/index.html for complete details on the rules. (default: ['codesize', 'unusedcode', 'naming']).
- **zero_config** [bool, optional] - Suppresses build failure on errors and warnings if set to true. (default: false).
### Example
```yml
test:
php_mess_detector:
path: 'app'
ignore:
- 'vendor'
allowed_warnings: -1
rules:
- "cleancode"
- "controversial"
- "codesize"
- "design"
- "naming"
- "unusedcode"
- "somedir/customruleset.xml"
zero_config: true
```

View file

@ -0,0 +1,16 @@
Similar to the [standard PHP Lint plugin](https://github.com/Block8/PHPCI/wiki/Lint-plugin), except that it uses the [PHP Parallel Lint](https://github.com/JakubOnderka/PHP-Parallel-Lint) project to run.
## Configuration
### Options
* **directory** [string, optional] - directory to inspect (default: build root)
* **ignore** [array, optional] - directory to ignore (default: inherits ignores specified in setup)
### Example
```yml
test:
php_parallel_lint:
directory: "app"
ignore:
- "vendor"
- "test"
```

View file

@ -0,0 +1,24 @@
Runs [PHP Spec](http://www.phpspec.net/) tests against your build.
### Configuration Options:
* **bootstrap** - Optional - Path to a PHPSpec bootstrap file.
### Example
```
build_settings:
[...]
setup:
[...]
test:
php_spec:
complete:
[...]
success:
[...]
```

View file

@ -0,0 +1,34 @@
Runs PHPUnit tests against your build.
## Configuration
### Options
Has two modes:
#### phpunit.xml Configuration File
Its activated if you have phpunit.xml file in your build path, `tests/` subfolder, or you specify it as a parameter:
* **config** - Optional - Path to a PHP Unit XML configuration file.
* **run_from** - Optional - When running PHPUnit with an XML config, the command is run from this directory
* **coverage** - Optional - Value for the `--coverage-html` command line flag.
* **path** - Optional - In cases where tests files are in a sub path of the /tests path, allows this path to be set in the config.
#### Running Tests By Specifying Directory
* **directory** - Optional - The directory (or array of dirs) to run PHPUnit on
Both modes accept:
* **args** - Optional - Command line args (in string format) to pass to PHP Unit
### Examples
Specify config file and test directory:
```yml
test:
php_unit:
config:
- "path/to/phpunit.xml"
path: "app/tests/"
```
## Troubleshooting
If standard logging of PHPCI is not enough, to get standard output from any command, including PHPUnit, edit `BaseCommandExecutor::executeCommand()` to see what exactly is wrong
* Run `composer update` in phpunit plugin directory of PHPCI to get all of its dependencies
* If phpunit is inside of the project's composer.json, it might interfere with PHPCI's phpunit installation
* Make sure you have XDebug installed.`The Xdebug extension is not loaded. No code coverage will be generated.`
Otherwise test report parsing in `TapParser` will fail, wanting coverage report as well `Invalid TAP string, number of tests does not match specified test count.`

48
docs/en/plugins/shell.md Normal file
View file

@ -0,0 +1,48 @@
Runs a given Shell command.
**Note: ** Because this plugin could potentially be abused, it requires extra steps to enable it:
1. In the root of your PHPCI system, in the same directory where you'll find composer.json and vars.php, look for a file local_vars.php. If it does not exist, create it.
2. In local_vars.php add this code:
```php
<?php
define('ENABLE_SHELL_PLUGIN', true);
```
If `ENABLE_SHELL_PLUGIN` is either false or undefined, the shell plugin won't work.
### Configuration Options:
* **command** - Required - The shell command to run.
```yml
setup:
shell:
command: "bin/console build"
```
You should understand, that in old configuration type, you can run only one command!
### New format of Configuration Options
```yml
setup:
shell:
- "cd /www"
- "chmod u+x %BUILD_PATH%/bin/console"
- "%BUILD_PATH%/bin/console build"
```
#### Each new command forgets about what was before
So if you want cd to directory and then run script there, combine those two commands into one like:
```yml
setup:
shell:
- "cd %BUILD_PATH% && php artisan migrate" # Laravel Migrations
```
[See variables which you can use in shell commands](../interpolation.md)

View file

@ -0,0 +1,50 @@
This plugin joins a [Slack](https://www.slack.com/) room and sends a user-defined message, for example a "Build Succeeded" message.
**Configuration Options:**
| Field | Required? | Description |
|-------|-----------|-------------|
| `webhook_url` | Yes | The URL to your Slack WebHook |
| `room` | No | Your Slack room name. Default - #phpci |
| `username` | No | The name to send the message as. Default - PHPCI |
| `icon` | No | The URL to the user icon or an emoji such as :ghost:. Default - The value configured on Slack's WebHook setup |
| `message` | No | The message to send to the room. Default - `<%PROJECT_URI%|%PROJECT_TITLE%> - <%BUILD_URI%|Build #%BUILD%> has finished for commit <%COMMIT_URI%|%SHORT_COMMIT% (%COMMIT_EMAIL%)> on branch <%BRANCH_URI%|%BRANCH%>` |
| `show_status` | No | Whether or not to append the build status as an attachment in slack. Default - true
Send a message if the build fails:
```yaml
failure:
slack_notify:
webhook_url: "https://hooks.slack.com/services/R212T827A/G983UY31U/aIp0yuW9u0iTqwAMOEwTg"
room: "#phpci"
username: "PHPCI"
icon: ":ghost:"
message: "%PROJECT_TITLE% - build %BUILD% failed! :angry:"
show_status: false
```
Send a message if the build is successful:
```yaml
success:
slack_notify:
webhook_url: "https://hooks.slack.com/services/R212T827A/G983UY31U/aIp0yuW9u0iTqwAMOEwTg"
room: "#phpci"
username: "PHPCI"
icon: ":ghost:"
message: "%PROJECT_TITLE% - build %BUILD% succeeded! :smiley:"
show_status: false
```
Send a message every time the build runs:
```yaml
complete:
slack_notify:
webhook_url: "https://hooks.slack.com/services/R212T827A/G983UY31U/aIp0yuW9u0iTqwAMOEwTg"
room: "#phpci"
username: "PHPCI"
icon: ":ghost:"
message: "%PROJECT_TITLE% - build %BUILD% completed"
show_status: true
```

View file

@ -0,0 +1,5 @@
Checks all files in your project for TODOs and other technical debt.
## Configuration Options:
* **searches** - Optional - Case-insensitive array of terms to search for. Defaults to TODO, TO DO, FIXME and FIX ME.

31
docs/en/plugins/xmpp.md Normal file
View file

@ -0,0 +1,31 @@
## Requirements
- sendxmpp package
## Installation
1. On debian system (for example) use aptitude command to install sendxmpp
2. Add XMPP plugin in "complete" section of your phpci.yml
## Configuration options
- username : Username of your XMPP sender account. (example : login@server.com)
- password : Password of your XMPP sender account.
- recipients : List of your XMPP recipents account.
- server : If your server is not the same that your login server (optional, example : gtalk.google.com)
- tls : Set 1 to enable TLS connection or 0 to disable it. (optional, default is 0)
- alias : Alias of your sender account. (optional)
- date_format : strftime mask date format display in notification message. (optional, default is %c of strftime function)
## Configuration example
```
complete:
xmpp:
username: "login@gmail.com"
password: "AZERTY123"
recipients:
- "recipient1@jabber.org"
- "recipient2@jabber.org"
server: "gtalk.google.com"
tls: 1
alias: "PHPCi Notification"
date_format: "%d/%m/%Y"
```