Build virtualenv using the Makefile

Add tidy target (don't use yet as there's a bug)

Make lint target cover all the files

Start at documentation generation using libdoc/testdoc within robot

Change-Id: I8117baf4bd006588ae9383e0731c49e17102348c
diff --git a/Makefile b/Makefile
index 8aacf10..b99d7ce 100644
--- a/Makefile
+++ b/Makefile
@@ -12,8 +12,55 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-LINT_ARGS           ?= --verbose --configure LineTooLong:130 --configure TooManyTestSteps:15 --ignore TooFewTestSteps --ignore TooFewKeywordSteps
+# use bash for pushd/popd, and to fail quickly. virtualenv's activate
+# has undefined variables, so no -u
+SHELL = bash -e -o pipefail
 
+# Variables
+LINT_ARGS   ?= --verbose --configure LineTooLong:120 --configure TooManyTestSteps:15
+VERSION     ?= $(shell cat ./VERSION)
 
-lint:
-	rflint $(LINT_ARGS) .
+sanity-kind: ROBOT_PORT_ARGS ?= -v ONOS_REST_PORT:8181 -v ONOS_SSH_PORT:8101
+sanity-kind: ROBOT_TEST_ARGS ?= --exclude notready --critical sanity
+sanity-kind: ROBOT_MISC_ARGS ?= -v num_onus:1
+sanity-kind: sanity
+
+# virtualenv for the robot tools
+vst_venv:
+	virtualenv $@ ;\
+	source ./$@/bin/activate ;\
+	pip install -r requirements.txt
+
+test: lint
+
+lint: vst_venv
+	source ./vst_venv/bin/activate ;\
+	set -u ;\
+	find . -name *.robot -exec rflint $(LINT_ARGS) {} +
+
+# tidy will be more useful once this issue with removing leading comments is
+# resolved: https://github.com/robotframework/robotframework/issues/3263
+tidy:
+	source ./vst_venv/bin/activate ;\
+	set -u ;\
+	find . -name *.robot -exec python -m robot.tidy --inplace {} \;
+
+sanity: vst_venv
+	source ./vst_venv/bin/activate ;\
+	set -u ;\
+	cd tests/sanity ;\
+	robot $(ROBOT_PORT_ARGS) $(ROBOT_TEST_ARGS) $(ROBOT_MISC_ARGS) sanity.robot
+
+gendocs: vst_venv
+	source ./vst_venv/bin/activate ;\
+	set -u ;\
+	mkdir -p gendocs ;\
+	python -m robot.libdoc --format HTML libraries/onos.robot gendocs/lib_onos_robot.html ;\
+	python -m robot.testdoc tests/Voltha_PODTests.robot gendocs/voltha_podtests.html
+
+# explore use of --docformat REST - integration w/Sphinx?
+clean:
+	find . -name output.xml -print
+
+clean-all: clean
+	rm -rf vst_venv gendocs