run revision 6398f22526303343193a18e514602f1af6fb29cb
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Run continuous integration tests.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Copyright (C) 2014 Red Hat
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# This program is free software; you can redistribute it and/or modify
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# it under the terms of the GNU General Public License as published by
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# the Free Software Foundation; either version 3 of the License, or
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# (at your option) any later version.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# This program is distributed in the hope that it will be useful,
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# but WITHOUT ANY WARRANTY; without even the implied warranty of
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# GNU General Public License for more details.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# You should have received a copy of the GNU General Public License
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# along with this program. If not, see <http://www.gnu.org/licenses/>.
6398f22526303343193a18e514602f1af6fb29cbNikolai Kondrashovdeclare -r CI_DIR=`dirname "\`readlink -f \"\$0\"\`"`
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovdeclare -r COVERAGE_CFLAGS="-g3 -O0 --coverage"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovdeclare -r CPU_NUM=`getconf _NPROCESSORS_ONLN`
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Minimum percentage of code lines covered by tests
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Minimum percentage of code functions covered by tests
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Output program usage information.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovUsage: `basename "$0"` [OPTION...]
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovRun continuous integration tests.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov -h, --help Output this help message and exit.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov -p, --prefix=STRING Use STRING as the prefix to prepend to file and
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov directory paths in output.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov -n, --no-deps Don't attempt to install dependencies.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov -e, --essential Run the essential subset of tests.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov -m, --moderate Run the moderate subset of tests.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov -r, --rigorous,
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov -f, --full Run the rigorous (full) set of tests.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovDefault options: --essential
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Output a file display path: a path relocated from base directory (BASE_DIR)
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# to base prefix (BASE_PFX).
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov printf "%s" "$BASE_PFX${path:${#BASE_DIR}+1}"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Args: id cmd [arg...]
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Execute mock as is, or, if the user is not in the "mock" group, under sudo,
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# which has password prompt/input on the console, instead of stderr/stdin.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Args: [mock_arg...]
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov declare prompt=$'Not a "mock" group member.\n'
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov prompt+="To run mock enter sudo password for $USER: "
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Execute mock_privileged with extra chroot configuration added.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Args: chroot [mock_arg...]
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Input: extra configuration
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov conf_dir=`mktemp --tmpdir --directory mock-config.XXXXXXXX`
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov trap 'trap - RETURN; rm -R "$conf_dir";' RETURN
8ef1a136c1406bd1bab66e4ebf75b9375090cd86Nikolai Kondrashov # Preserve timestamps to avoid unnecessary cache rebuilds
8ef1a136c1406bd1bab66e4ebf75b9375090cd86Nikolai Kondrashov cp -r --preserve=timestamps /etc/mock/* "$conf_dir"/
8ef1a136c1406bd1bab66e4ebf75b9375090cd86Nikolai Kondrashov touch --reference="/etc/mock/${chroot}.cfg" "${conf_dir}/${chroot}.cfg"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov mock_privileged --configdir="$conf_dir" --root="$chroot" "$@"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Execute mock_privileged with dependency package source configuration added.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Args: chroot [mock_arg...]
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov elif [[ "$chroot" =~ epel-([0-9]+) ]]; then
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov repo="epel-${BASH_REMATCH[1]}-\$basearch"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov echo "Unknown chroot config: $chroot" >&2
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovconfig_opts['yum.conf'] += '''
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovname=Extra SSSD dependencies
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovbaseurl=http://copr-be.cloud.fedoraproject.org/results/lslebodn/sssd-deps/$repo/
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovskip_if_unavailable=true
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Run debug build checks.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov test_dir=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov # Not building "tests" due to https://fedorahosted.org/sssd/ticket/2350
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov stage make-tests make-check-wrap -j $CPU_NUM check -- true
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov # Ignored until issues found by Valgrind are fixed
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov --trace-children-skip='*/bin/*,*/sbin/*' \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov test_dir_distcheck=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov # Single thread due to https://fedorahosted.org/sssd/ticket/2354
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov printf -v distcheck_configure_args " %q" \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov mv "$test_dir_distcheck" ci-test-dir-distcheck
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov if [[ "$DISTRO_BRANCH" == -redhat-* ]]; then
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov stage make-srpm env -u CFLAGS -- make srpm
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov stage mock-epel6 mock_privileged_deps "epel-6-$ARCH" \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov stage mock-fedora20 mock_privileged_deps "fedora-20-$ARCH" \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Run coverage build checks.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov declare -r scan_report_dir="ci-report-scan"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov declare -r coverage_report_dir="ci-report-coverage"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov test_dir=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov stage configure scan-build "$BASE_DIR/configure" \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov # Not building "tests" due to https://fedorahosted.org/sssd/ticket/2350
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov stage scan-make-tests scan_build_single \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov --html-title="sssd - scan-build report" \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov make-check-wrap -j $CPU_NUM check -- true
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov "`disppath \"\$scan_report_dir/index.html\"`"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov # Ignored until issues found by the scanner are fixed
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov stage scan-check scan_check "$scan_report_dir" ||
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov stage lcov-pre lcov --capture --initial --directory . \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov stage make-check scan-build make -j $CPU_NUM check || true
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov stage lcov-post lcov --capture --directory . \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov stage lcov-merge lcov --add-tracefile ci-base.info \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov stage lcov-clean lcov --remove ci-dirty.info \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov stage genhtml eval 'genhtml --output-directory \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov "$coverage_report_dir" \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov --title "sssd" --show-details \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov --legend --prefix "$BASE_DIR" \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov "`disppath \"\$coverage_report_dir/index.html\"`"
933c7c5efc76b4a9f3206b36bf6fe60e5dd635f1Nikolai Kondrashov stage lcov-check eval 'lcov_check "$COVERAGE_MIN_LINES" \
933c7c5efc76b4a9f3206b36bf6fe60e5dd635f1Nikolai Kondrashov "$COVERAGE_MIN_FUNCS" \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Run a build inside a sub-directory.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Args: id cmd [arg...]
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovargs_expr=`getopt --name \`basename "\$0"\` \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov --longoptions essential,moderate,rigorous,full \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov DEPS=false; shift;;
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov shift; break;;
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovif [ $# != 0 ]; then
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov echo "Positional arguments are not accepted." >&2