2016-08-26 00:40:11 +01:00
|
|
|
source: Developing/Validating-Code.md
|
2018-10-27 23:04:34 +01:00
|
|
|
path: blob/master/doc/
|
2016-08-26 00:40:11 +01:00
|
|
|
|
2016-09-20 16:21:03 +01:00
|
|
|
#### Validating Code
|
|
|
|
|
2019-06-20 13:53:45 -05:00
|
|
|
As part of the pull request process with GitHub we run some automated
|
|
|
|
build tests to ensure that the code is error free, standards [compliant](http://docs.librenms.org/Developing/Code-Guidelines/)
|
2016-08-26 00:40:11 +01:00
|
|
|
and our test suite builds successfully.
|
|
|
|
|
2019-06-20 13:53:45 -05:00
|
|
|
Rather than submit a pull request and wait for the results, you can
|
|
|
|
run these checks yourself to ensure a more seamless merge.
|
2016-08-26 00:40:11 +01:00
|
|
|
|
2019-06-20 13:53:45 -05:00
|
|
|
> All of these commands should be run from within the librenms
|
|
|
|
> directory and can be run as the librenms user unless otherwise noted.
|
2016-08-26 00:40:11 +01:00
|
|
|
|
|
|
|
Install composer (you can skip this if composer is already installed).
|
|
|
|
|
|
|
|
`curl -sS https://getcomposer.org/installer | php`
|
|
|
|
|
|
|
|
Composer will now be installed into /opt/librenms/composer.phar.
|
|
|
|
|
|
|
|
Now install the dependencies we require:
|
|
|
|
|
2017-06-06 22:49:53 +01:00
|
|
|
`./composer.phar install`
|
2016-08-26 00:40:11 +01:00
|
|
|
|
|
|
|
Once composer is installed you can now run the code validation script:
|
|
|
|
|
2020-09-24 05:32:03 -05:00
|
|
|
`./lnms dev:check`
|
2016-08-26 00:40:11 +01:00
|
|
|
|
2019-06-20 13:53:45 -05:00
|
|
|
If you see `Tests ok, submit away :)` then all is well. If you see
|
|
|
|
other output then it should contain what you need to resolve the issues and re-test.
|
2016-09-20 16:21:03 +01:00
|
|
|
|
|
|
|
#### Git Hooks
|
|
|
|
|
2019-06-20 13:53:45 -05:00
|
|
|
Git has a hook system which you can use to trigger checks at various
|
2020-09-24 05:32:03 -05:00
|
|
|
stages. Utilising the `./lnms dev:check` you can make this part of your
|
|
|
|
commit process.
|
2016-09-20 16:21:03 +01:00
|
|
|
|
2020-09-24 05:32:03 -05:00
|
|
|
Add `./lnms dev:check` to your `.git/hooks/pre-commit`:
|
2016-09-20 16:21:03 +01:00
|
|
|
|
2020-09-24 05:32:03 -05:00
|
|
|
echo "/opt/librenms/lnms dev:check" >> /opt/librenms/.git/hooks/pre-commit
|
|
|
|
chmod +x /opt/librenms/.git/hooks/pre-commit
|