Commit a7700eae authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Added CI setup files. Added rules to Makefile. Added test requirements.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent fed8695e
......@@ -45,13 +45,17 @@ clean-pyc: ## remove Python file artifacts
find . -name '__pycache__' -exec rm -fr {} +
clean-test: ## remove test and coverage artifacts
coverage erase
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache
rm -fr nosetests.html
rm -fr nosetests.xml
lint: ## check style with flake8
flake8 pyrsr tests
flake8 --max-line-length=120 pyrsr tests > ./tests/linting/flake8.log
pycodestyle pyrsr --exclude="*.ipynb,*.ipynb*" --max-line-length=120 > ./tests/linting/pycodestyle.log
-pydocstyle pyrsr > ./tests/linting/pydocstyle.log
test: ## run tests quickly with the default Python
python setup.py test
......@@ -60,10 +64,18 @@ test-all: ## run tests on every Python version with tox
tox
coverage: ## check code coverage quickly with the default Python
coverage run --source pyrsr setup.py test
coverage run --source pyrsr --source bin setup.py test
coverage combine # must be called in order to make coverage work in multiprocessing
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html
# $(BROWSER) htmlcov/index.html
nosetests: clean-test ## Runs nosetests with coverage, xUnit and nose-html-output
## - puts the coverage results in the folder 'htmlcov'
## - generates 'nosetests.html' (--with-html)
## - generates 'nosetests.xml' (--with-xunit) which is currently not visualizable by GitLab
nosetests -vv --with-coverage --cover-package=pyrsr --cover-package=bin --cover-erase --cover-html \
--cover-html-dir=htmlcov --with-html --with-xunit --rednose --force-color
docs: ## generate Sphinx HTML documentation, including API docs
rm -f docs/pyrsr.rst
......@@ -85,4 +97,8 @@ dist: clean ## builds source and wheel package
ls -l dist
install: clean ## install the package to the active Python's site-packages
pip install -r requirements.txt
python setup.py install
gitlab_CI_docker: ## Build a docker image for CI use within gitlab
cd ./tests/CI_docker/; bash ./build_testsuite_image.sh
......@@ -41,7 +41,7 @@ requirements = ['numpy', 'pandas', 'matplotlib', 'scipy']
setup_requirements = []
test_requirements = []
test_requirements = ['coverage', 'nose', 'nose-htmloutput', 'rednose']
setup(
author="Daniel Scheffler",
......
#!/usr/bin/env bash
context_dir="./context"
dockerfile="pyrsr_ci.docker"
tag="spechomo_ci:0.0.1"
gitlab_runner="spechomo_gitlab_CI_runner"
echo "#### Build runner docker image"
sudo docker rmi ${tag}
sudo docker build -f ${context_dir}/${dockerfile} -m 20G -t ${tag} ${context_dir}
# sudo docker build -f ./context/pyrsr_ci.docker -m 20G -t spechomo_ci:0.7.0 ./context --no-cache
echo "#### Create gitlab-runner (daemon) container with tag; ${tag}"
sudo docker stop ${gitlab_runner}
sudo docker rm ${gitlab_runner}
sudo docker run -d --name ${gitlab_runner} --restart always \
-v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest
echo "#### Register container at gitlab, get token here https://gitext.gfz-potsdam.de/geomultisens/spechomo/settings/ci_cd"
read -p "Please enter gitlab token: " token
echo ""
read -p "Please enter gitlab runner name: " runner_name
echo "New gitlab runner image will named ${gitlab_runner}"
sudo docker exec -it ${gitlab_runner} /bin/bash -c "export RUNNER_EXECUTOR=docker && gitlab-ci-multi-runner register -n \
--url 'https://gitext.gfz-potsdam.de/ci' \
--registration-token '${token}' \
--run-untagged=true \
--locked=true \
--tag-list spechomo_client \
--description '${runner_name}' \
--docker-image '${tag}' "
name: pyrsr
channels: &id1
- http://conda.anaconda.org/conda-forge
dependencies:
- python=3.*.*
- matplotlib
- numpy
- pandas
- pip:
- scipy
# test and doc dependencies
- coverage
- flake8
- nose
- nose2
- nose-htmloutput
- pycodestyle
- pylint
- pydocstyle
- rednose
- sphinx-argparse
FROM gms_base_centos:0.2
# copy some needed stuff to /root
COPY *.yml /root/
# update the ci_env environment (that already contains all packages installed via 'docker_pyenvs' repo)
RUN /bin/bash -i -c "\
source /root/miniconda3/bin/activate ; \
source activate ci_env; \
conda env update -n ci_env -f /root/environment_pyrsr.yml"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment