From ce6cd03f6c7f020a8127025c49224f1bb920bc18 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 10 Dec 2015 14:28:50 +0000 Subject: [PATCH] Enforce metrics related to moving toward modern client infrastructure. Having a CI enforced blacklist and then a whitelist of files failing to meet style guidelines (as well as expanding list of rules enforced) may have helped create incentive to rework Galaxy toward a more compliant and uniform Python styling. We briefly discussed the possibility of doing this with other team code base objectives on a conference call - in particular to help the transition toward replacing all of the web controllers with API controllers and eliminating the use of Python mako files for rendering web content and replacing it with client side templates. To do this I have created two rough metrics - the number of lines of web controller code in the Galaxy app and the number of mako files in the templates directory. The hope is that people feel ... compelled to lower these numbers. While these metrics are admittedly rough, they do also encourage de-duplication of mako templates and transition of API code into managers (in addition to elimination of functions) both of these secondary incentives are also good things and should be project objectives. --- .ci/check_controller.sh | 6 ++++++ .ci/check_mako.sh | 6 ++++++ tox.ini | 11 ++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .ci/check_controller.sh create mode 100644 .ci/check_mako.sh diff --git a/.ci/check_controller.sh b/.ci/check_controller.sh new file mode 100644 index 00000000000..73e3931a7b9 --- /dev/null +++ b/.ci/check_controller.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +MAX_LINE_COUNT=19900 +project_dir=`dirname $0`/.. +cd $project_dir +bash -c "[ `find lib/galaxy/webapps/galaxy/controllers/ -name '*.py' | xargs wc -l | tail -n 1 | awk '{ printf \$1; }'` -lt $MAX_LINE_COUNT ]" diff --git a/.ci/check_mako.sh b/.ci/check_mako.sh new file mode 100644 index 00000000000..0c0fb773ff4 --- /dev/null +++ b/.ci/check_mako.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +MAX_MAKO_COUNT=330 +project_dir=`dirname $0`/.. +cd $project_dir +bash -c "[ `find templates -iname '*.mako' | wc -l | cut -f1 -d' '` -lt $MAX_MAKO_COUNT ]" diff --git a/tox.ini b/tox.ini index 24bf4de692e..7b102d7a642 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,8 @@ [tox] -envlist = py27-lint, py26-lint, py27-unit, py26-unit, qunit +envlist = py27-lint, py26-lint, py27-unit, py26-unit, qunit, mako-count, web-controller-line-count skipsdist = True + [testenv:py27-lint] commands = bash .ci/flake8_wrapper.sh whitelist_externals = bash @@ -32,3 +33,11 @@ deps = [testenv:qunit] commands = bash run_tests.sh -q whitelist_externals = bash + +[testenv:mako-count] +commands = bash .ci/check_mako.sh +whitelist_externals = bash + +[testenv:web-controller-line-count] +commands = bash .ci/check_controller.sh +whitelist_externals = bash