This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/incubator-openwhisk-utilities.git


The following commit(s) were added to refs/heads/master by this push:
     new 0ca1077  Update README.md with instructions for running scancode and 
adding hook. (#40)
0ca1077 is described below

commit 0ca10776cfec75809a3a5af1cf0fce71e48b22b8
Author: rodric rabbah <[email protected]>
AuthorDate: Sat May 19 20:53:15 2018 -0400

    Update README.md with instructions for running scancode and adding hook. 
(#40)
---
 README.md | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 6012701..4bd83a1 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,50 @@ Shared utilities used across Apache OpenWhisk project 
repositories.
 
 The following utilities are included in this repository (by subdirectory):
 
-- _**scancode**_ - Configurable code scanning utility that performs file and 
line-level checks on all files (exclusions permitted) on a provided path.
+- _**scancode**_ - Configurable code scanning utility that performs file and 
line-level checks on all files (exclusions permitted) on a provided path. It is 
intended for Git commit hooks and continuous integration (CI) builds to enforce 
certain coding conventions.
+
+
+If you "push" code that follows all conventions, you will see the message:
+```bash
+Scanning files starting at [./mycodepath/]...
+All checks passed.
+```
+However, if you push code containing tabs, trailing whitespace or missing 
Apache License headers, your build will fail immediately with one of the 
following messages:
+```bash
+Scan detected 3 error(s) in 1 file(s):
+  [./mycodepath/sourcecode.go]:
+       1: file does not include required license header.
+      18: line contains tabs.
+      27: line has trailing whitespaces.
+```
+
+To make sure this never happens to you, you can run the same tests on your 
local machine every time you commit changes. 
+
+1. Clone the OpenWhisk utilities project repo.:
+```bash
+$ git clone https://github.com/apache/incubator-openwhisk-utilities.git
+```
+
+2. Run the scancode utility against the root directory of your project or 
subdirectory where your code changes live:
+```bash
+# Invoke Python utility (works with either Python 2 or 3)
+$ python ./incubator-openwhisk-utilities/scancode/scanCode.py $ROOTDIR
+```
+
+It is worth adding a Git [pre-commit 
hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to 
automatically run the checks before you can even type in a Git commit message. 
Here is a sample `pre-commit` file:
+
+```bash
+$ cat /path/to/openwhisk/.git/hooks/pre-commit
+#!/usr/bin/env bash
+
+# determine openwhisk base directory
+root="$(git rev-parse --show-toplevel)"
+python /path/to/incubator-openwhisk-utilities/scancode/scanCode.py . --config 
$root/tools/
+```
+
+_Note_: A hook a locally installed, so if you check out the repository again, 
you will need to reinstall it.
+
+If your project repo. is new or does not run scancode yet, you can choose to 
create a "pre-build" Bash script that can be included in your Travis CI 
integration that includes code similar to Step 1 and 2. You can invoke this 
script within the ".travis.yml" file early in your install or build scripts.
 
 ### Issues
 

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to