--- /dev/null
+#!/bin/bash
+#
+# This file is part of the GROMACS molecular simulation package.
+#
+# Copyright (c) 2015, by the GROMACS development team, led by
+# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+# and including many others, as listed in the AUTHORS file in the
+# top-level source directory and at http://www.gromacs.org.
+#
+# GROMACS is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2.1
+# of the License, or (at your option) any later version.
+#
+# GROMACS is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with GROMACS; if not, see
+# http://www.gnu.org/licenses, or write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# If you want to redistribute modifications to GROMACS, please
+# consider that scientific software is very special. Version
+# control is crucial - bugs must be traceable. We will be happy to
+# consider code for inclusion in the official distribution, but
+# derived work must not be called official GROMACS. Details are found
+# in the README & COPYING files - if they are missing, get the
+# official version at http://www.gromacs.org.
+#
+# To help us fund GROMACS development, we humbly ask that you cite
+# the research papers on the package. Check out http://www.gromacs.org.
+
+# This script is used by Gerrit to run uncrustify in the uncrustify_* jobs.
+# The main purpose of this script is to isolate Jenkins from the details of
+# the uncrustify.sh script, and to provide a facade that can keep the interface
+# to Jenkins the same even if uncrustify.sh changes.
+# It also provides some logic to produce better messages for Jenkins.
+#
+# Interface from Jenkins to this script is:
+# * location of the script
+# * UNCRUSTIFY environment variable to specify the location of uncrustify
+#
+# Communication back to Jenkins is through
+# * return value of this script (non-zero marks the build failed).
+# * stdout (any instance of "FAILED" marks the build unstable),
+# * unsuccessful-reason.log contains a short description of what failed
+# or was unstable
+# * uncrustify.log contains messages about what files needed changes
+
+srcdir=`git rev-parse --show-toplevel`
+cd $srcdir
+if [ ! -f "admin/run-uncrustify.sh" ] ; then
+ echo "Failed to find root of the source tree"
+ exit 1
+fi
+
+warning_log=uncrustify.log
+unsuccessful_log=unsuccessful-reason.log
+
+admin/uncrustify.sh check --rev=HEAD^ --warnings=$warning_log
+stat=$?
+if [ $stat -eq 1 ] ; then
+ echo "FAILED: uncrustify.sh found issues"
+ warning_count=`wc -l <$warning_log`
+ if [ $warning_count -lt 5 ] ; then
+ cp -f $warning_log $unsuccessful_log
+ else
+ rm -f $unsuccessful_log
+ uncrustify_count=`grep "needs uncrustify" $warning_log | wc -l`
+ cpyear_count=`grep "copyright year" $warning_log | wc -l`
+ cpheader_count=`grep "copyright header" $warning_log | wc -l`
+ [ $uncrustify_count -gt 0 ] && echo "formatting issues in" $uncrustify_count "file(s)" >> $unsuccessful_log
+ [ $cpyear_count -gt 0 ] && echo "copyright year missing in" $cpyear_count "file(s)" >> $unsuccessful_log
+ [ $cpheader_count -gt 0 ] && echo "copyright header issues in" $cpheader_count "file(s)" >> $unsuccessful_log
+ cat $unsuccessful_log
+ fi
+ exit 0
+elif [ $stat -ne 0 ] ; then
+ echo "FAILED: uncrustify.sh failed to run"
+ echo "uncrustify.sh failed to run" > $unsuccessful_log
+ exit 1
+fi
+exit 0
# Parse command-line arguments
function usage() {
echo "usage: uncrustify.sh [-f|--force] [--rev=REV]"
- echo " [--uncrustify=(off|check)] [--copyright=<cmode>] [<action>]"
+ echo " [--uncrustify=(off|check)] [--copyright=<cmode>]"
+ echo " [--warnings=<file>] [<action>]"
echo "<action>: (check*|diff|update)[-(index|workdir*)] (*=default)"
echo "<cmode>: off|add|update*|replace|full"
}
force=
uncrustify_mode=check
copyright_mode=update
+warning_file=
for arg in "$@" ; do
if [[ "$arg" == "check-index" || "$arg" == "check-workdir" || \
"$arg" == "diff-index" || "$arg" == "diff-workdir" || \
force=1
elif [[ "$arg" == --rev=* ]] ; then
baserev=${arg#--rev=}
+ elif [[ "$arg" == --warnings=* ]] ; then
+ warning_file=${arg#--warnings=}
elif [[ "$arg" == "-h" || "$arg" == "--help" ]] ; then
usage
exit 0
fi
# Report what was done
-sort $tmpdir/messages
+sort $tmpdir/messages | tee $srcdir/$warning_file
rm -rf $tmpdir
exit $changes
and use of braces, as well as for copyright headers. See :doc:`formatting` for
the guidelines that are enforced.
-Technically, the build simply runs :file:`admin/uncrustify.sh` as ::
-
- admin/uncrustify.sh check --rev=HEAD^
-
-to check the formatting in the changes for the commit.
-If the return value is non-zero (i.e., any changes would be required), the
-build is marked unstable.
-Currently, only the console log of the build shows what actually was the issue.
-See :doc:`uncrustify` for more details on the script and uncrustify.
+Technically, the build simply runs :file:`admin/run-uncrustify.sh` to check the
+formatting in the changes for the commit.
+If the any changes are required, the build is marked unstable.
+If the script completely fails (should be rare), the build fails.
+A file with issues found by the script is archived as an artifact in the build,
+and a summary is reported back to Gerrit (or the actual issues if there are
+only a few).
+See :doc:`uncrustify` for more details on uncrustify and on scripts to run it.
.. TODO: Provide links to the build system page, once there are on the git
commit chain...