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
a907aa07340ef0051cd74bbab9618820e1bca1b8Fabiano Fidêncio# Those values are a sum up of the default warnings in all our
a907aa07340ef0051cd74bbab9618820e1bca1b8Fabiano Fidêncio# supported distros in our CI.
a907aa07340ef0051cd74bbab9618820e1bca1b8Fabiano Fidêncio# debian_testing: E121,E123,E126,E226,E24,E704,W503
a907aa07340ef0051cd74bbab9618820e1bca1b8Fabiano Fidêncio# fedora24: E121,E123,E126,E226,E24,E704
a907aa07340ef0051cd74bbab9618820e1bca1b8Fabiano Fidêncio# fedora25: E121,E123,E126,E226,E24,E704
a907aa07340ef0051cd74bbab9618820e1bca1b8Fabiano Fidêncio# fedora26: E121,E123,E126,E226,E24,E704
a907aa07340ef0051cd74bbab9618820e1bca1b8Fabiano Fidêncio# fedora27: E121,E123,E126,E226,E24,E704
a907aa07340ef0051cd74bbab9618820e1bca1b8Fabiano Fidêncio# fedora_rawhide: E121,E123,E126,E226,E24,E704
a907aa07340ef0051cd74bbab9618820e1bca1b8Fabiano Fidênciodeclare PEP8_IGNORE="--ignore=E121,E123,E126,E226,E24,E704,W503"
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...]
3e2f89726a90dfe091d7d7d3b558d97469e5d3afLukas Slebodnik declare -r config=$(basename $(readlink -f "/etc/mock/${chroot_name}.cfg"))
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.
8dff4a773dd9525ec587cd31646a9f67252122c1Nikolai Kondrashov # Extended glob pattern matching tests to run under Valgrind.
8dff4a773dd9525ec587cd31646a9f67252122c1Nikolai Kondrashov # NOTE: The particular pattern below is inverted
bc85b85227b87758d80e84b30e4823370d5ffca7Lukas Slebodnik declare valgrind_test_pattern="!(*.py|*/whitespace_test|"
bc85b85227b87758d80e84b30e4823370d5ffca7Lukas Slebodnik declare -r valgrind_test_pattern+="*/double_semicolon_test)"
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
444a82bd6d68c6f23e05d523ff92d328f6b2ec05Lukas Slebodnik stage make-tests make -j $CPU_NUM check LOG_COMPILER=true
444a82bd6d68c6f23e05d523ff92d328f6b2ec05Lukas Slebodnik valgrind-condense 99 \
444a82bd6d68c6f23e05d523ff92d328f6b2ec05Lukas Slebodnik --trace-children=yes \
223f4ff3cd9136414a8b593587f5742bf2c914cdLukas Slebodnik --trace-children-skip='*/bin/*,*/sbin/*,./dummy-child' \
444a82bd6d68c6f23e05d523ff92d328f6b2ec05Lukas Slebodnik --leak-check=full \
444a82bd6d68c6f23e05d523ff92d328f6b2ec05Lukas Slebodnik --gen-suppressions=all \
444a82bd6d68c6f23e05d523ff92d328f6b2ec05Lukas Slebodnik --suppressions=\"$CI_DIR/sssd.supp\" \
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov printf -v intgcheck_configure_args " %q" \
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov stage make-intgcheck make -j $CPU_NUM intgcheck \
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
3e2f89726a90dfe091d7d7d3b558d97469e5d3afLukas Slebodnik stage mock-build mock_privileged_deps "default" \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Run coverage build checks.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov declare -r coverage_report_dir="ci-report-coverage"
057f699b401097ad7f48fe3760e81c6993619a4bLukas Slebodnik if [[ "$DISTRO_BRANCH" == -redhat-redhatenterprise*-6.*- ||
057f699b401097ad7f48fe3760e81c6993619a4bLukas Slebodnik "$DISTRO_BRANCH" == -redhat-centos-6.*- ]]; then
057f699b401097ad7f48fe3760e81c6993619a4bLukas Slebodnik # enable optimisation to avoid bug in gcc < 4.6.0
057f699b401097ad7f48fe3760e81c6993619a4bLukas Slebodnik # gcc commit 7959b7e646b493f48a2ea7228fbf1c43f84bedea
057f699b401097ad7f48fe3760e81c6993619a4bLukas Slebodnik # git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162384
057f699b401097ad7f48fe3760e81c6993619a4bLukas Slebodnik export CFLAGS="$COVERAGE_CFLAGS $extra_CFLAGS"
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
444a82bd6d68c6f23e05d523ff92d328f6b2ec05Lukas Slebodnik stage make-tests make -j $CPU_NUM check LOG_COMPILER=true
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov stage lcov-pre lcov --capture --initial --directory . \
8d1b572126afceb60693ff4c4a734bd6dbdaf548Nikolai Kondrashov stage make-check make -j $CPU_NUM check || status=$?
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
89f5332ccf59672ecafc36abe07d2351e32a05d5Fabiano Fidêncio # Ignore "E722 do not use bare except" exceptions
89f5332ccf59672ecafc36abe07d2351e32a05d5Fabiano Fidêncio # that are only raised on debian_testing machines.
a907aa07340ef0051cd74bbab9618820e1bca1b8Fabiano Fidênciostage pep8 find . -path ./src/config -prune -o \