.gitlab-ci.yml 4.19 KB
Newer Older
Daniel Scheffler's avatar
Daniel Scheffler committed
1
2
3
before_script:
  - git lfs pull

4
5
6

# Advise GitLab that these environment vars should be loaded from the Variables config.
variables:
Daniel Scheffler's avatar
Fix.    
Daniel Scheffler committed
7
8
    ANACONDA_USER: SECURE
    ANACONDA_PASSWORD: SECURE
Daniel Scheffler's avatar
Daniel Scheffler committed
9
    ANACONDA_TOKEN: SECURE
Daniel Scheffler's avatar
Fix.    
Daniel Scheffler committed
10

11
12
13

stages:
  - test
Daniel Scheffler's avatar
Fix.    
Daniel Scheffler committed
14
  - deploy_pages
15
16
  - deploy_pypi
  - deploy_conda
17
18
19
  - cleanup


Daniel Scheffler's avatar
Daniel Scheffler committed
20
test_py_tools_ds:
21
  stage: test
Daniel Scheffler's avatar
Daniel Scheffler committed
22
  script:
23
    - source /root/miniconda3/bin/activate
24
25
    - source activate ci_env
    - export GDAL_DATA=/root/miniconda3/envs/ci_env/share/gdal
Daniel Scheffler's avatar
Daniel Scheffler committed
26
    - export PYTHONPATH=$PYTHONPATH:/root  # /root <- directory needed later
27
    - make nosetests
Daniel Scheffler's avatar
Daniel Scheffler committed
28
29
30
31
32
    - make docs
  artifacts:
    paths:
    - htmlcov/
    - docs/_build/html/
33
34
35
    - nosetests.html
    - nosetests.xml
    when: always
Daniel Scheffler's avatar
Daniel Scheffler committed
36

37

38
39
40
test_styles:
  stage: test
  script:
41
    - source /root/miniconda3/bin/activate
42
43
    - source activate ci_env
    - export GDAL_DATA=/root/miniconda3/envs/ci_env/share/gdal
44
45
46
47
48
49
50
51
52
53
    - export PYTHONPATH=$PYTHONPATH:/root  # /root <- directory needed later
    - make lint
  artifacts:
    paths:
    - tests/linting/flake8.log
    - tests/linting/pycodestyle.log
    - tests/linting/pydocstyle.log
    when: always


54
55
56
test_py_tools_ds_install:
  stage: test
  script:
57
    - source /root/miniconda3/bin/activate
58
59
    - conda create -y -q --name py_tools_ds_testinstall python=3
    - source activate py_tools_ds_testinstall
Daniel Scheffler's avatar
Daniel Scheffler committed
60
    # resolve some requirements with conda
61
    - conda install --yes -q -c conda-forge numpy gdal scikit-image pyproj rasterio shapely geopandas pyresample>=1.11.0
62
63
    - conda install --yes -q -c conda-forge libgdal ncurses # Fix for libgdal installed from defaults channel causing libkea.so.1.4.7: cannot open shared object file: No such file or directory
#    - conda install --yes -q -c conda-forge kealib  # fix for libkea.so.1.4.7: cannot open shared object file: No such file or directory
64
    # run installer
65
    - python setup.py install
66
    # test if its importable
67
68
69
70
71
    - cd ..
    - pwd
    - ls
    - python -c "import py_tools_ds; print(py_tools_ds)"
    - python -c "from py_tools_ds.geo.vector.geometry import boxObj"
72
73
  only:
    - master
Daniel Scheffler's avatar
Daniel Scheffler committed
74

75

76
pages:  # this job must be called 'pages' to advise GitLab to upload content to GitLab Pages
Daniel Scheffler's avatar
Fix.    
Daniel Scheffler committed
77
  stage: deploy_pages
Daniel Scheffler's avatar
Daniel Scheffler committed
78
79
80
  dependencies:
    - test_py_tools_ds
  script:
81
82
83
      # Create the public directory
    - rm -rf public
    - mkdir public
Daniel Scheffler's avatar
Daniel Scheffler committed
84
85
    - mkdir -p public/doc
    - mkdir -p public/coverage
86
    - mkdir -p public/nosetests_reports
87
    # Copy over the docs
Daniel Scheffler's avatar
Daniel Scheffler committed
88
    - cp -r docs/_build/html/* public/doc/
89
90
91
92
93
94
95
    # Copy over the coverage reports
    - cp -r htmlcov/* public/coverage/
    # Copy over the nosetests reports
    - cp nosetests.* public/nosetests_reports/
    # Check if everything is working great
    - ls -al public
    - ls -al public/doc
Daniel Scheffler's avatar
Daniel Scheffler committed
96
97
    - ls -al public/coverage
    - ls -al public/nosetests_reports
Daniel Scheffler's avatar
Daniel Scheffler committed
98
99
100
101
102
103
  artifacts:
    paths:
      - public
    expire_in: 30 days
  only:
    - master
104
105
106


deploy_pypi:
107
  stage: deploy_pypi
108
109
  dependencies:
    - test_py_tools_ds
110
  script:
111
    - source /root/miniconda3/bin/activate
112
113
114
115
    - source activate ci_env
    - pip install -U twine
    - python setup.py sdist
    - twine upload dist/*  # requires creds as environment variables
116
117
118
119
120
121
  only:
    - /^v\d+\.\d+\.\d+([abc]\d*)?$/  # PEP-440 compliant version (tags)
  except:
    - dev


122
deploy_anaconda:
123
  stage: deploy_conda
124
  dependencies:
125
    - test_py_tools_ds
126
  script:
Daniel Scheffler's avatar
Bugfix.    
Daniel Scheffler committed
127
    - source /root/miniconda3/bin/activate
128
    - source activate ci_env
129
    - conda install -y -q conda-build anaconda-client
Daniel Scheffler's avatar
Fix.    
Daniel Scheffler committed
130
    - yum install -y patch # https://stackoverflow.com/questions/40392161/building-conda-skeleton-from-pypi-package-throws-error
131
    # - conda skeleton pypi py_tools_ds --output-dir public/conda.recipe/py_tools_ds # create recipe
132
    - conda config --set anaconda_upload yes  # enable auto-upload to anaconda
Daniel Scheffler's avatar
Daniel Scheffler committed
133
    # - anaconda login --username ${ANACONDA_USER} --password ${ANACONDA_PASSWORD}
134
135
136
    - conda build -c conda-forge -c defaults --token ${ANACONDA_TOKEN} conda_recipe/meta.yaml  # --output returns package name
    # - conda convert --platform all /home/jsmith/miniconda/conda-bld/linux-64/pyinstrument-0.13.1-py27_0.tar.bz2
    # -o outputdir/
137
138
    - anaconda logout
  only:
139
140
    # - feature/conda_deployment
    - /^v\d+\.\d+\.\d+([abc]\d*)?$/  # PEP-440 compliant version (tags)
141
142
  except:
    - dev