summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0dminnimda <0dminnimda@gmail.com>2021-10-07 10:56:43 +0300
committerGitHub <noreply@github.com>2021-10-07 09:56:43 +0200
commit72c18e73679fc3b74d2acd037b4de2cbfff25257 (patch)
tree1834561c252550acef6e670705bbfe09fd3f74c3
parent454a49850d7b0328f566d3026788ef08186c30a5 (diff)
downloadcython-72c18e73679fc3b74d2acd037b4de2cbfff25257.tar.gz
Improve ci-run.sh (GH-4398)
-rw-r--r--Tools/ci-run.sh89
1 files changed, 66 insertions, 23 deletions
diff --git a/Tools/ci-run.sh b/Tools/ci-run.sh
index e4f39eba9..34519c793 100644
--- a/Tools/ci-run.sh
+++ b/Tools/ci-run.sh
@@ -3,28 +3,36 @@
GCC_VERSION=${GCC_VERSION:=8}
# Set up compilers
-if [ "${OS_NAME##ubuntu*}" == "" -a "$TEST_CODE_STYLE" != "1" ]; then
+if [ "$TEST_CODE_STYLE" == "1" ]; then
+ echo "Skipping compiler setup"
+elif [ "${OSTYPE##linux-gnu*}" == "" ]; then
+ echo "Setting up linux compiler"
echo "Installing requirements [apt]"
sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
sudo apt update -y -q
sudo apt install -y -q ccache gdb python-dbg python3-dbg gcc-$GCC_VERSION || exit 1
+
+ ALTERNATIVE_ARGS=""
if [ -z "${BACKEND##*cpp*}" ]; then
sudo apt install -y -q g++-$GCC_VERSION || exit 1
+ ALTERNATIVE_ARGS="--slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION"
fi
sudo /usr/sbin/update-ccache-symlinks
echo "/usr/lib/ccache" >> $GITHUB_PATH # export ccache to path
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 60 $(if [ -z "${BACKEND##*cpp*}" ]; then echo " --slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION"; fi)
+ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 60 $ALTERNATIVE_ARGS
export CC="gcc"
if [ -z "${BACKEND##*cpp*}" ]; then
sudo update-alternatives --set g++ /usr/bin/g++-$GCC_VERSION
export CXX="g++"
fi
-fi
-if [ "${OS_NAME##macos*}" == "" ]; then
+elif [ "${OSTYPE##darwin*}" == "" ]; then
+ echo "Setting up macos compiler"
export CC="clang -Wno-deprecated-declarations"
export CXX="clang++ -stdlib=libc++ -Wno-deprecated-declarations"
+else
+ echo "No setup specified for $OSTYPE"
fi
# Set up miniconda
@@ -35,11 +43,13 @@ if [ "$STACKLESS" == "true" ]; then
conda install --quiet --yes stackless || exit 1
fi
+PYTHON_SYS_VERSION=$(python -c 'import sys; print(sys.version)')
+
# Log versions in use
echo "===================="
echo "|VERSIONS INSTALLED|"
echo "===================="
-python -c 'import sys; print("Python %s" % (sys.version,))'
+echo "Python $PYTHON_SYS_VERSION"
if [ "$CC" ]; then
which ${CC%% *}
${CC%% *} --version
@@ -61,7 +71,7 @@ elif [ -z "${PYTHON_VERSION##3.[45]*}" ]; then
else
python -m pip install -U pip setuptools wheel || exit 1
- if [ -n "${PYTHON_VERSION##*-dev}" ]; then
+ if [ -n "${PYTHON_VERSION##*-dev}" -o "$COVERAGE" == "1" ]; then
python -m pip install -r test-requirements.txt || exit 1
if [ "${PYTHON_VERSION##pypy*}" -a "${PYTHON_VERSION##3.[4789]*}" ]; then
@@ -74,7 +84,7 @@ if [ "$TEST_CODE_STYLE" == "1" ]; then
STYLE_ARGS="--no-unit --no-doctest --no-file --no-pyregr --no-examples";
python -m pip install -r doc-requirements.txt || exit 1
else
- STYLE_ARGS="--no-code-style";
+ STYLE_ARGS="--no-code-style"
# Install more requirements
if [ -n "${PYTHON_VERSION##*-dev}" ]; then
@@ -83,24 +93,45 @@ else
# python -m pip install pythran==0.9.5 || exit 1
fi
- if [ "$BACKEND" != "cpp" -a -n "${PYTHON_VERSION##pypy*}" -a -n "${PYTHON_VERSION##2*}" -a -n "${PYTHON_VERSION##*3.4}" ]; then
+ if [ "$BACKEND" != "cpp" -a -n "${PYTHON_VERSION##pypy*}" -a
+ -n "${PYTHON_VERSION##2*}" -a -n "${PYTHON_VERSION##3.4*}" ]; then
python -m pip install mypy || exit 1
fi
fi
fi
# Run tests
+echo "==== Running tests ===="
ccache -s 2>/dev/null || true
export PATH="/usr/lib/ccache:$PATH"
+# Most modern compilers allow the last conflicting option
+# to override the previous ones, so '-O0 -O3' == '-O3'
+# This is true for the latest msvc, gcc and clang
+CFLAGS="-O0 -ggdb -Wall -Wextra"
+
if [ "$NO_CYTHON_COMPILE" != "1" -a -n "${PYTHON_VERSION##pypy*}" ]; then
- CFLAGS="-O2 -ggdb -Wall -Wextra $(python -c 'import sys; print("-fno-strict-aliasing" if sys.version_info[0] == 2 else "")')" \
- python setup.py build_ext -i \
- $(if [ "$COVERAGE" == "1" ]; then echo " --cython-coverage"; fi) \
- $(if [ "$CYTHON_COMPILE_ALL" == "1" ]; then echo " --cython-compile-all"; fi) \
- $(python -c 'import sys; print("-j5" if sys.version_info >= (3,5) else "")') \
- || exit 1
- if [ -z "$COVERAGE" -a -z "$STACKLESS" -a -z "$LIMITED_API" -a -z "$CYTHON_COMPILE_ALL" -a -z "$EXTRA_CFLAGS" -a -n "${BACKEND//*cpp*}" ]; then
+
+ BUILD_CFLAGS="$CFLAGS -O2"
+ if [[ $PYTHON_SYS_VERSION == "2"* ]]; then
+ BUILD_CFLAGS="$BUILD_CFLAGS -fno-strict-aliasing"
+ fi
+
+ SETUP_ARGS=""
+ if [ "$COVERAGE" == "1" ]; then
+ SETUP_ARGS="$SETUP_ARGS --cython-coverage"
+ fi
+ if [ "$CYTHON_COMPILE_ALL" == "1" ]; then
+ SETUP_ARGS="$SETUP_ARGS --cython-compile-all"
+ fi
+ SETUP_ARGS="$SETUP_ARGS
+ $(python -c 'import sys; print("-j5" if sys.version_info >= (3,5) else "")')"
+
+ CFLAGS=$BUILD_CFLAGS \
+ python setup.py build_ext -i $SETUP_ARGS || exit 1
+
+ if [ -z "$COVERAGE" -a -z "$STACKLESS" -a -n "${BACKEND//*cpp*}" -a
+ -z "$LIMITED_API" -a -z "$CYTHON_COMPILE_ALL" -a -z "$EXTRA_CFLAGS" ]; then
python setup.py bdist_wheel || exit 1
fi
fi
@@ -108,20 +139,32 @@ fi
if [ "$TEST_CODE_STYLE" == "1" ]; then
make -C docs html || exit 1
elif [ -n "${PYTHON_VERSION##pypy*}" ]; then
- # Run the debugger tests in python-dbg if available (but don't fail, because they currently do fail)
- PYTHON_DBG="python$( python -c 'import sys; print("%d.%d" % sys.version_info[:2])' )-dbg"
- if $PYTHON_DBG -V >&2; then CFLAGS="-O0 -ggdb" $PYTHON_DBG runtests.py -vv --no-code-style Debugger --backends=$BACKEND; fi;
+ # Run the debugger tests in python-dbg if available
+ # (but don't fail, because they currently do fail)
+ PYTHON_DBG=$(python -c 'import sys; print("%d.%d" % sys.version_info[:2])')
+ PYTHON_DBG="python$PYTHON_DBG-dbg"
+ if $PYTHON_DBG -V >&2; then
+ CFLAGS=$CFLAGS $PYTHON_DBG \
+ runtests.py -vv --no-code-style Debugger --backends=$BACKEND
+ fi
+fi
+
+RUNTESTS_ARGS=""
+if [ "$COVERAGE" == "1" ]; then
+ RUNTESTS_ARGS="$RUNTESTS_ARGS --coverage --coverage-html --cython-only"
+fi
+if [ -z "$TEST_CODE_STYLE" ]; then
+ RUNTESTS_ARGS="$RUNTESTS_ARGS -j7"
fi
-export CFLAGS="-O0 -ggdb -Wall -Wextra $EXTRA_CFLAGS"
+export CFLAGS="$CFLAGS $EXTRA_CFLAGS"
python runtests.py \
-vv $STYLE_ARGS \
-x Debugger \
--backends=$BACKEND \
- $LIMITED_API \
- $EXCLUDE \
- $(if [ "$COVERAGE" == "1" ]; then echo " --coverage --coverage-html --cython-only"; fi) \
- $(if [ -z "$TEST_CODE_STYLE" ]; then echo " -j7 "; fi)
+ $LIMITED_API \
+ $EXCLUDE \
+ $RUNTESTS_ARGS
EXIT_CODE=$?