summaryrefslogtreecommitdiff
path: root/Tools/ci-run.sh
blob: e4f39eba9859f5b2f930294f8e5b17c5deabb784 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/bash

GCC_VERSION=${GCC_VERSION:=8}

# Set up compilers
if [ "${OS_NAME##ubuntu*}" == "" -a "$TEST_CODE_STYLE" != "1" ]; then
  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
  if [ -z "${BACKEND##*cpp*}" ]; then
    sudo apt install -y -q g++-$GCC_VERSION || exit 1
  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)

  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
  export CC="clang -Wno-deprecated-declarations"
  export CXX="clang++ -stdlib=libc++ -Wno-deprecated-declarations"
fi

# Set up miniconda
if [ "$STACKLESS" == "true" ]; then
  echo "Installing stackless python"
  #conda install --quiet --yes nomkl --file=test-requirements.txt --file=test-requirements-cpython.txt
  conda config --add channels stackless
  conda install --quiet --yes stackless || exit 1
fi

# Log versions in use
echo "===================="
echo "|VERSIONS INSTALLED|"
echo "===================="
python -c 'import sys; print("Python %s" % (sys.version,))'
if [ "$CC" ]; then
  which ${CC%% *}
  ${CC%% *} --version
fi
if [ "$CXX" ]; then
  which ${CXX%% *}
  ${CXX%% *} --version
fi
echo "===================="

# Install python requirements
echo "Installing requirements [python]"
if [ -z "${PYTHON_VERSION##2.7}" ]; then
  pip install wheel || exit 1
  pip install -r test-requirements-27.txt || exit 1
elif [ -z "${PYTHON_VERSION##3.[45]*}" ]; then
  python -m pip install wheel || exit 1
  python -m pip install -r test-requirements-34.txt || exit 1
else
  python -m pip install -U pip setuptools wheel || exit 1

  if [ -n "${PYTHON_VERSION##*-dev}" ]; then
    python -m pip install -r test-requirements.txt || exit 1

    if [ "${PYTHON_VERSION##pypy*}" -a "${PYTHON_VERSION##3.[4789]*}" ]; then
      python -m pip install -r test-requirements-cpython.txt || exit 1
    fi
  fi
fi

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";

  # Install more requirements
  if [ -n "${PYTHON_VERSION##*-dev}" ]; then
    if [ -z "${BACKEND##*cpp*}" ]; then
      echo "WARNING: Currently not installing pythran due to compatibility issues"
      # 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
      python -m pip install mypy || exit 1
    fi
  fi
fi

# Run tests
ccache -s 2>/dev/null || true
export PATH="/usr/lib/ccache:$PATH"

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
    python setup.py bdist_wheel || exit 1
  fi
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;
fi

export CFLAGS="-O0 -ggdb -Wall -Wextra $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)

EXIT_CODE=$?

ccache -s 2>/dev/null || true

exit $EXIT_CODE