summaryrefslogtreecommitdiff
path: root/tools/ci-run.sh
blob: 38f95547c1dd757a4d286a33db6a9f79ada4aa8d (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
#!/usr/bin/bash

GCC_VERSION=${GCC_VERSION:=8}

# Set up compilers
if [ -z "${OS_NAME##ubuntu*}" ]; then
  echo "Installing requirements [apt]"
  sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
  sudo apt-get update -y -q
  sudo apt-get install -y -q ccache gcc-$GCC_VERSION "libxml2=2.9.4*" "libxml2-dev=2.9.4*" libxslt1.1 libxslt1-dev || exit 1
  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

  export CC="gcc"
  export PATH="/usr/lib/ccache:$PATH"

elif [ -z "${OS_NAME##macos*}" ]; then
  export CC="clang -Wno-deprecated-declarations"
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
pkg-config --modversion libxml-2.0 libxslt
echo "===================="

ccache -s || true

# Install python requirements
echo "Installing requirements [python]"
python -m pip install -U pip setuptools wheel
if [ -z "${PYTHON_VERSION##*-dev}" ];
  then python -m pip install --install-option=--no-cython-compile https://github.com/cython/cython/archive/master.zip;
  else python -m pip install -r requirements.txt;
fi
python -m pip install -U beautifulsoup4 cssselect html5lib rnc2rng ${EXTRA_DEPS} || exit 1
if [ "$COVERAGE" == "true" ]; then
  python -m pip install coverage || exit 1
  python -m pip install --pre 'Cython>=3.0a0' || exit 1
fi

# Build
CFLAGS="-Og -g -fPIC -Wall -Wextra" python -u setup.py build_ext --inplace \
      $(if [ -n "${PYTHON_VERSION##2.*}" ]; then echo -n " -j7 "; fi ) \
      $(if [ "$COVERAGE" == "true" ]; then echo -n " --with-coverage"; fi ) \
      || exit 1

ccache -s || true

# Run tests
CFLAGS="-Og -g -fPIC" PYTHONUNBUFFERED=x make test || exit 1

python setup.py install || exit 1
python -c "from lxml import etree" || exit 1

CFLAGS="-O3 -g1 -march=generic -fPIC -flto" \
  LDFLAGS="-flto" \
  make clean bdist_wheel || exit 1

ccache -s || true