From e9444569430f55d856ddebe32a16f81c93d6b528 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Thu, 24 Sep 2020 05:32:03 -0500 Subject: [PATCH] Use lnms dev:check instead of pre-commit.php (#12149) * Remove pre-commit.php references WIP * remove pre-commit.php references --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- doc/Developing/Validating-Code.md | 18 ++++++------------ doc/Developing/os/Test-Units.md | 14 +++++++------- scripts/git-pre-commit-hook.sh | 4 ++-- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index abf0d02708..d09f26a928 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,7 +4,7 @@ DO NOT DELETE THE UNDERLYING TEXT #### Please note -> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting. +> Please read this information carefully. You can run `./lnms dev:check` to check your code before submitting. - [ ] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) - [ ] If my Pull Request does some changes/fixes/enhancements in the WebUI, I have inserted a screenshot of it. diff --git a/doc/Developing/Validating-Code.md b/doc/Developing/Validating-Code.md index d6e3c39f60..8a730d50c3 100644 --- a/doc/Developing/Validating-Code.md +++ b/doc/Developing/Validating-Code.md @@ -25,7 +25,7 @@ Now install the dependencies we require: Once composer is installed you can now run the code validation script: -`./scripts/pre-commit.php` +`./lnms dev:check` 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. @@ -33,16 +33,10 @@ other output then it should contain what you need to resolve the issues and re- #### Git Hooks Git has a hook system which you can use to trigger checks at various -stages. Utilising the `pre-commit.php` you can make this part of your -commit process. You can do this in two ways: +stages. Utilising the `./lnms dev:check` you can make this part of your +commit process. -1. If you already make use of `.git/hooks/pre-commit` then you can add: +Add `./lnms dev:check` to your `.git/hooks/pre-commit`: -./scripts/pre-commit.php - -to be excecuted when you run `git commit`. - -1. You can symlink the `pre-commit.php` file so it's executed directly - on a `git commit`: - -`ln -s /opt/librenms/scripts/pre-commit.php /opt/librenms/.git/hooks/pre-commit` + echo "/opt/librenms/lnms dev:check" >> /opt/librenms/.git/hooks/pre-commit + chmod +x /opt/librenms/.git/hooks/pre-commit diff --git a/doc/Developing/os/Test-Units.md b/doc/Developing/os/Test-Units.md index 3ab2f09c3a..1f6eb5b66d 100644 --- a/doc/Developing/os/Test-Units.md +++ b/doc/Developing/os/Test-Units.md @@ -16,7 +16,7 @@ make sure it is modified in a consistent manner. > testing. For OS discovery, we can mock snmpsim, but for other tests > you will need it installed and functioning. We run snmpsim during > our integration tests, but not by default when running -> `./scripts/pre-commit.php`. You can install snmpsim with the +> `./lnms dev:check`. You can install snmpsim with the > command `pip3 install snmpsim`. ## Capturing test data @@ -58,18 +58,18 @@ After you have the data you need in the snmprec file, you can just use save-test directory. This will read composer.json and install any dependencies required. After you have saved your test data, you should run -`./scripts/pre-commit.php -p -u` verify they pass. +`./lnms dev:check` verify they pass. To run the full suite of tests enable database and snmpsim reliant -tests: `./scripts/pre-commit.php --db --snmpsim -p -u` +tests: `./lnms dev:check unit --db --snmpsim` ### Specific OS -`./scripts/pre-commit.php -p -o osname` +`./lnms dev:check unit -o osname` ### Specific Module -`./scripts/pre-commit.php -p -m modulename` +`./lnms dev:check unit -m modulename` ## Using snmpsim for testing @@ -143,7 +143,7 @@ must use a variant to store your test data (-v). 1. If there is additional snmp data required, run `./scripts/collect-snmp-data.php -h 42` 1. Run `./scripts/save-test-data.php -o example-os` to update the dumped database data. 1. Review data. If you modified the snmprec or code (don't modify json manually) run `./scripts/save-test-data.php -o example-os -m os` -1. Run `./scripts/pre-commit.php --db --snmpsim` +1. Run `./lnms dev:check unit --db --snmpsim` 1. If the tests succeed submit a pull request ### Additional module support or test data @@ -153,5 +153,5 @@ must use a variant to store your test data (-v). more data to the snmprec file 1. Review data. If you modified the snmprec (don't modify json manually) run `./scripts/save-test-data.php -o example-os -m ` -1. Run `./scripts/pre-commit.php --db --snmpsim` +1. Run `./lnms dev:check unit --db --snmpsim` 1. If the tests succeed submit a pull request diff --git a/scripts/git-pre-commit-hook.sh b/scripts/git-pre-commit-hook.sh index 3a475e0a67..f19e126cba 100755 --- a/scripts/git-pre-commit-hook.sh +++ b/scripts/git-pre-commit-hook.sh @@ -1,5 +1,5 @@ #!/usr/bin/env sh -# Call pre-commit.php with options that work well when used as a git pre-commit hook +# Call ./lnms dev:check with options that work well when used as a git pre-commit hook SCRIPT_DIR=`dirname "$(readlink -f "$0")"` -${SCRIPT_DIR}/pre-commit.php --lint --style --unit --fail-fast +${SCRIPT_DIR}/lnms dev:check