Skip to content

Commit 32a7522

Browse files
authored
ENH: use docker within travis-ci (#18)
1 parent ae81364 commit 32a7522

File tree

4 files changed

+82
-19
lines changed

4 files changed

+82
-19
lines changed

.travis.yml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
# run on container-based infrastructure
2-
sudo: false
2+
sudo: required
33

4-
language: python
4+
language: generic
55

6-
addons:
7-
apt:
8-
packages:
9-
- gfortran
6+
services:
7+
- docker
108

11-
# build only master
129
branches:
1310
only:
1411
- master
@@ -22,23 +19,25 @@ env:
2219
matrix:
2320
include:
2421
- python: 3.6
22+
sudo: required
2523
env:
2624
- PYTHON_VERSION="3.6"
25+
- WRADLIB_DOCKER_TAG=full
2726

28-
install:
29-
- deactivate
30-
- source scripts/install.sh
27+
before_install:
28+
- docker pull wradlib/wradlib-docker:$WRADLIB_DOCKER_TAG
29+
- source scripts/docker_run.sh
3130

32-
before_script:
33-
- export GDAL_DATA=$HOME/miniconda/envs/wradlib/share/gdal
34-
- export WRADLIB_DATA=$HOME/wradlib-data
35-
- export WRADLIB_NOTEBOOKS=$NOTEBOOKS_BUILD_DIR/notebooks
36-
- export DISPLAY=:99
37-
- sh -e /etc/init.d/xvfb start
38-
- sleep 3
31+
install:
32+
- git clone https://github.com/wradlib/wradlib-data.git
33+
- git clone https://github.com/wradlib/wradlib.git
34+
- cd wradlib
35+
- export WRADLIB_TAG=`git name-rev --name-only --tags HEAD`
36+
- cd $NOTEBOOKS_BUILD_DIR
37+
- source scripts/install_docker.sh
3938

4039
script:
41-
- scripts/render_notebooks.sh
40+
- docker exec -i -u=$UID $WRADLIB_DOCKER_TAG /bin/bash -c "source activate wradlib; cd /home/build; scripts/render_notebooks.sh"
4241

4342
after_success:
4443
- cd $NOTEBOOKS_BUILD_DIR && scripts/push_notebooks.sh

scripts/docker_run.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
# Copyright (c) 2017-2018, wradlib developers.
3+
# Distributed under the MIT License. See LICENSE.txt for more info.
4+
5+
# print env vars
6+
echo "TRAVIS_PULL_REQUEST " $TRAVIS_PULL_REQUEST
7+
echo "TRAVIS_SECURE_ENV_VARS " $TRAVIS_SECURE_ENV_VARS
8+
echo "TRAVIS_TAG " $TRAVIS_TAG ${TRAVIS_TAG:1}
9+
echo "PYTHON_VERSION" $PYTHON_VERSION
10+
echo "WRADLIB_DOCKER_TAG" $WRADLIB_DOCKER_TAG
11+
12+
# run docker container
13+
docker run -d -ti \
14+
--name $WRADLIB_DOCKER_TAG \
15+
-v "${NOTEBOOKS_BUILD_DIR}":/home/build \
16+
-e LOCAL_USER_ID=$UID \
17+
-e NOTEBOOKS_BUILD_DIR=/home/build \
18+
-e WRADLIB_DATA=/home/build/wradlib-data \
19+
-e WRADLIB_NOTEBOOKS=/home/build/notebooks \
20+
-e PYTHON_VERSION=$PYTHON_VERSION \
21+
-e CI \
22+
-e TRAVIS \
23+
-e TRAVIS_PULL_REQUEST \
24+
-e TRAVIS_SECURE_ENV_VARS \
25+
-e TRAVIS_BRANCH \
26+
-e TRAVIS_TAG \
27+
-e TRAVIS_JOB_NUMBER \
28+
-e TRAVIS_JOB_ID \
29+
-e TRAVIS_REPO_SLUG \
30+
-e TRAVIS_COMMIT \
31+
-e TRAVIS_BUILD_DIR=/home/build/wradlib \
32+
-e TRAVIS_OS_NAME \
33+
-e TRAVIS_PYTHON_VERSION=$PYTHON_VERSION \
34+
wradlib/wradlib-docker:$WRADLIB_DOCKER_TAG /bin/bash

scripts/install_docker.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# Copyright (c) 2017-2018, wradlib developers.
3+
# Distributed under the MIT License. See LICENSE.txt for more info.
4+
5+
cat << EOF | docker exec -i $WRADLIB_DOCKER_TAG \
6+
/bin/bash
7+
8+
export PYTHONUNBUFFERED=1
9+
10+
conda config --set show_channel_urls True
11+
conda config --add channels conda-forge
12+
13+
source activate wradlib
14+
15+
cd /home/build/wradlib
16+
python -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv
17+
18+
# print version information
19+
python --version
20+
pip --version
21+
python -c "from osgeo import gdal; print('GDAL:', gdal.__version__)"
22+
python -c "import numpy; print('NUMPY:', numpy.__version__)"
23+
python -c "import scipy; print('SCIPY:', scipy.__version__)"
24+
python -c "import matplotlib; print('MATPLOTLIB:', matplotlib.__version__)"
25+
python -c "import netCDF4; print('NETCDF4:', netCDF4.__version__, netCDF4.getlibversion(), netCDF4.__hdf5libversion__)"
26+
python -c "import h5py; print('H5PY:', h5py.__version__, h5py.version.hdf5_version)"
27+
python -c "import xmltodict; print('XMLTODICT:', xmltodict.__version__)"
28+
# python -c "import wradlib; print('WRADLIB:', wradlib.__version__, wradlib.__git_revision__)"
29+
EOF

scripts/push_notebooks.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ if [ $TRAVIS_SECURE_ENV_VARS == 'true' ]; then
2020
git config --global user.email "[email protected]"
2121
git config --global user.name "wradlib-docs-bot"
2222
git checkout --orphan render
23-
rm -rf miniconda.sh
23+
rm -rf wradlib
24+
rm -rf wradlib-data
2425
git add --all .
2526
git commit -m "Rendering at commit $TRAVIS_COMMIT"
2627

0 commit comments

Comments
 (0)