Commit d50afd86 authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Refactor ci-support around a single central file of functions

parent a531734d
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-py-project-within-miniconda.sh
source build-py-project-within-miniconda.sh
#! /bin/bash

curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/ci-support.sh
source ci-support.sh

build_py_project_in_conda_env

# Can't use v0.3 because https://github.com/airspeed-velocity/asv/pull/721 is needed
# Can't use v0.4 because of https://github.com/airspeed-velocity/asv/issues/822
+4 −36
Original line number Diff line number Diff line
@@ -3,40 +3,8 @@
set -e
set -x

curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-py-project-within-miniconda.sh
source build-py-project-within-miniconda.sh
curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/ci-support.sh
source ci-support.sh

PY_EXE=python

TESTABLES=""
if [ -d test ]; then
  cd test

  if ! [ -f .not-actually-ci-tests ]; then
    TESTABLES="$TESTABLES ."
  fi

  if [ -z "$NO_DOCTESTS" ]; then
    vRST_SHS=(../doc/*.rst)

    if [ -e "${RST_SHS[0]}" ]; then
      TESTABLES="$TESTABLES ${RST_FILES[*]}"
    fi
  fi

  rm -Rf 
  if ! test -z "$TESTABLES"; then
    echo "TESTABLES: $TESTABLES"

    # Core dumps? Sure, we'll take them.
    ulimit -c unlimited

    # 10 GiB should be enough for just about anyone
    ulimit -m $(python -c 'print(1024*1024*10)')

    ${PY_EXE} -m pytest -rw --durations=10 --tb=native  --junitxml=pytest.xml -rxs $PYTEST_FLAGS $TESTABLES

    # Avoid https://github.com/pytest-dev/pytest/issues/754:
    # add --tb=native
  fi
fi
build_py_project_in_conda_env
test_py_project
+4 −58
Original line number Diff line number Diff line
#! /bin/bash

set -e
curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/ci-support.sh
source ci-support.sh

function get_proj_name()
{
  if [ -n "$CI_PROJECT_NAME" ]; then
    echo "$CI_PROJECT_NAME"
  else
    basename "$GITHUB_REPOSITORY"
  fi
}
build_py_project_in_venv
test_py_project
AK_PROJ_NAME="$(get_proj_name)"

if [ "$PY_EXE" == "" ]; then
  PY_EXE=python${py_version}
fi

curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-py-project.sh
source build-py-project.sh

TESTABLES=""
if [ -d test ]; then
  cd test

  if ! [ -f .not-actually-ci-tests ]; then
    TESTABLES="$TESTABLES ."
  fi

  if [ -z "$NO_DOCTESTS" ]; then
    RST_FILES=(../doc/*.rst)

    if [ -e "${RST_FILES[0]}" ]; then
      TESTABLES="$TESTABLES ${RST_FILES[*]}"
    fi

    # macOS bash is too old for mapfile: Oh well, no doctests on mac.
    if [ "$(uname)" != "Darwin" ]; then
      mapfile -t DOCTEST_MODULES < <( git grep -l doctest -- ":(glob,top)$AK_PROJ_NAME/**/*.py" )
      TESTABLES="$TESTABLES ${DOCTEST_MODULES[@]}"
    fi
  fi

  if [[ -n "$TESTABLES" ]]; then
    echo "TESTABLES: $TESTABLES"

    # Core dumps? Sure, we'll take them.
    ulimit -c unlimited

    # 10 GiB should be enough for just about anyone
    ulimit -m $(python -c 'print(1024*1024*10)')

    ${PY_EXE} -m pytest \
      --durations=10 \
      --tb=native  \
      --junitxml=pytest.xml \
      --doctest-modules \
      -rxsw \
      $PYTEST_FLAGS $TESTABLES
  fi
fi
+3 −58
Original line number Diff line number Diff line
#! /bin/bash

set -e
curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/ci-support.sh
source ci-support.sh

PY_EXE=python3

echo "-----------------------------------------------"
echo "Current directory: $(pwd)"
echo "Python executable: ${PY_EXE}"
echo "-----------------------------------------------"

# {{{ clean up

rm -Rf .env
rm -Rf build
find . -name '*.pyc' -delete

rm -Rf env
git clean -fdx -e siteconf.py -e boost-numeric-bindings -e local_settings.py

if test `find "siteconf.py" -mmin +1`; then
  echo "siteconf.py older than a minute, assumed stale, deleted"
  rm -f siteconf.py
fi

# }}}

git submodule update --init --recursive

# {{{ virtualenv

${PY_EXE} -m venv .env
. .env/bin/activate

${PY_EXE} -m ensurepip

# https://github.com/pypa/pip/issues/5345#issuecomment-386443351
export XDG_CACHE_HOME=$HOME/.cache/$CI_RUNNER_ID

# Avoid UnicodeDecodeError: https://github.com/pypa/pip/issues/4825
pip install --upgrade pip

# }}}

if test "$EXTRA_INSTALL" != ""; then
  for i in $EXTRA_INSTALL ; do
    $PY_EXE -m pip install $i
  done
fi

if test "$REQUIREMENTS_TXT" == ""; then
  REQUIREMENTS_TXT="requirements.txt"
fi

if test -f $REQUIREMENTS_TXT; then
  $PY_EXE -m pip install -r $REQUIREMENTS_TXT
fi

$PY_EXE -m pip install docutils sphinx

${PY_EXE} setup.py install
build_py_project_in_venv

cd doc

+4 −17
Original line number Diff line number Diff line
#! /bin/bash

set -e
curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/ci-support.sh
source ci-support.sh

if [ "$PY_EXE" == "" ]; then
  PY_EXE=python${py_version}
fi

ci_support="https://gitlab.tiker.net/inducer/ci-support/raw/master"

if test "$USE_CONDA_BUILD" == "1"; then
  curl -L -O -k "${ci_support}/build-py-project-within-miniconda.sh"
  source build-py-project-within-miniconda.sh
else
  curl -L -O -k "${ci_support}/build-py-project.sh"
  source build-py-project.sh
fi

curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/run-examples.sh
source run-examples.sh
build_py_project
run_examples
Loading