jgliss / pyplis

Python toolbox for the analysis of UV SO2 camera data
GNU General Public License v3.0
7 stars 5 forks source link

add .travis.yml #19

Closed johannjacobsohn closed 5 years ago

johannjacobsohn commented 5 years ago

It might be useful to add travisCI to automatically run tests and checks on new code and PRs. Needs to be tested, but this should do the trick:


sudo: false
language: python
python:
  - "2.7"
  - "3.5"
  - "3.6"
  - "3.7"
install:
  - sudo apt-get install geos
script:
  - tox
  - flake8
  - pydocstyle
solvejgdinger commented 5 years ago

Hi, I was looking for something like this just last week but I couldn't find one with a free subscription. That one is actually free, thanks for the tip. I can't set it up for pyplis since it is @jgliss repository. We can consider moving the repository to a github organization account, if we plan to develop more on the project. For the meantime, could you set it up, Jonas?

jgliss commented 5 years ago

Thanks! I will look into this and set it up soon. Have done so for geonum and it works smoothly.

jgliss commented 5 years ago

Travis CI is setup now (see here). @johannjacobsohn it was a little bit more tricky though to make it work:

language: python

os:
   - linux

python:
   - "2.7"
   - "3.5"
   - "3.6"

install:
  - sudo apt-get update
  # We do this conditionally because it saves us some downloading if the
  # version is the same.
  - if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
      wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
    else
      wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
    fi
  - bash miniconda.sh -b -p $HOME/miniconda
  - export PATH="$HOME/miniconda/bin:$PATH"
  - hash -r
  - conda config --set always_yes yes --set changeps1 no
  - conda update -q conda
  - conda config --add channels conda-forge 
  # Useful for debugging any issues with conda
  - conda info -a

  # Replace dep1 dep2 ... with your dependencies
  - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION numpy scipy pandas astropy matplotlib basemap opencv geonum pydoas six
  - source activate test-environment
  - python setup.py install

# set the operating systems to be tested

script:
   - py.test

I am closing this issue now.

johannjacobsohn commented 5 years ago

yes, travis is notoriously difficult to set up, imho. Is there are a particular reason for preferring conda over pip, and not using tox?

jgliss commented 5 years ago

I haven't tested tox, but this could be changed ofc, if everything works properly. As for the conda / pip question: in the past, we often ran into problems with pip (e.g. installing basemap or opencv, or scipy), mostly on Windows. This may have been solved or improved for some cases in the pip distributions, but however, my feeling is that the community trend currently prefers conda as package manager, and that the latter is better in identifiying version conflicts, 3rd party libs that are non-pure python, etc. So I decided to follow this trend. For the CI tests, I would like to closely resemble the pyplis conda-forge build as we also recommend this to be the standard way of installing in the README. Happy to discuss all of this and the general question of deployment / installation / QC / QA. Nothing is finalised here ;)

jgliss commented 5 years ago

I reopen this for now.

johannjacobsohn commented 5 years ago

Interesting... I have no real solution to this question. I ran into a lot of problems with conda when I tried to use it once to install pyplis. I actually bricked my machine and I had to reinstall my OS, which was pretty annoying. I run linux, and didn't really run into many problems using pip. Also, tox uses pip and runs all tests on all target python versions pretty smoothly. However, I agree that using one unified solution is the better approach, and if conda works for you guys I guess that might be the best way to go. Maybe I'll fork pyplis with just a different travis.yml file to CI pip/tox and ensure that is working as well.

In any case, I'd suggest moving the dependencies from the travis file into requirements.txt and also running lint test (flake8, pydocstyle etc)

jgliss commented 5 years ago

Thanks for your opinion. To be honest, I am surprised to hear that you had trouble with conda on linux. I work 90% of my time with linux too and have not experienced any issues or problems with the installation of conda or with using it. Neither has any of my colleagues / students, to my knowledge. Maybe you could try to give it a second chance. The nice thing with conda is that, whenever we release on conda-forge, all tests are run as well (against all target python versions), against the conda installation, in isolated docker builds. I agree that a more complete CI will be nice on to have on pyplis repo basis, but I really think these tests should mimic the standard installation via conda, in my opinion, since installing the pyplis dependencies can be tricky, especially on Windows, as we have learned from own experience as well as user feedback in the past. Regarding tox, at the moment, I do not really see what we need it for. It should be easy to add further tests (like flake8, pydocstyle) automatically to .travis.yml directly, but correct me if I am wrong here.

johannjacobsohn commented 5 years ago

I've switched to conda now as you suggested and added scripts, flake8 and pydocstyle to travis (#27)