From 2b7b7c754721bee1d19367b91fcb529e98990006 Mon Sep 17 00:00:00 2001 From: Edward Oakes Date: Tue, 9 Jul 2019 21:49:12 -0700 Subject: [PATCH] Add linting pre-push hook (#5154) --- CONTRIBUTING.rst | 4 +++- hooks/pre-push | 18 ++++++++++++++++++ setup_hooks.sh | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100755 hooks/pre-push create mode 100755 setup_hooks.sh diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index eba7aa46c..f97704a4d 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -18,7 +18,9 @@ To contribute a patch: harder to merge in a large change with a lot of disjoint features. 2. Submit the patch as a GitHub pull request against the master branch. 3. Make sure that your code passes the unit tests. -4. Add new unit tests for your code. +4. Make sure that your code passes the linter. Run setup_hooks.sh to create + a git hook that will run the linter before you push your changes. +5. Add new unit tests for your code. .. _`ray-dev@googlegroups.com`: https://groups.google.com/forum/#!forum/ray-dev .. _`GitHub Issues`: https://github.com/ray-project/ray/issues diff --git a/hooks/pre-push b/hooks/pre-push new file mode 100755 index 000000000..c096fd532 --- /dev/null +++ b/hooks/pre-push @@ -0,0 +1,18 @@ +#!/bin/sh + +echo "Linting changes as part of pre-push hook" +echo "" +echo "ci/travis/format.sh:" +ci/travis/format.sh + +lint_exit_status=$? +if [ $lint_exit_status -ne 0 ]; then + echo "" + echo "Linting changes failed." + echo "Please make sure 'ci/travis/format.sh'"\ + "runs with no errors before pushing." + echo "If you want to ignore this and push anyways,"\ + "re-run with '--no-verify'." + exit 1 +fi +exit 0 diff --git a/setup_hooks.sh b/setup_hooks.sh new file mode 100755 index 000000000..3d92fbfef --- /dev/null +++ b/setup_hooks.sh @@ -0,0 +1,2 @@ +#!/bin/bash +ln -s $PWD/hooks/pre-push $PWD/.git/hooks/pre-push