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

4
5
6
7
8

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

13
14
15
16


stages:
  - test
17
  - deploy
18
19
20
  - cleanup


Daniel Scheffler's avatar
Daniel Scheffler committed
21
test_py_tools_ds:
22
  stage: test
Daniel Scheffler's avatar
Daniel Scheffler committed
23
  script:
24
    - source /root/miniconda3/bin/activate
25
    - export GDAL_DATA=/root/miniconda3/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
    - export GDAL_DATA=/root/miniconda3/share/gdal
43
44
45
46
47
48
49
50
51
52
    - 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


53
54
55
test_py_tools_ds_install:
  stage: test
  script:
56
    - source /root/miniconda3/bin/activate
57
    - export GDAL_DATA=/root/miniconda3/share/gdal
58
    - conda create -y -q --name py_tools_ds python=3
59
60
    - source activate py_tools_ds
     # resolve some requirements with conda
61
    - conda install --yes -q -c conda-forge numpy gdal scikit-image pyproj rasterio shapely geopandas
62
    # run installer
63
    - python setup.py install
64
    # test if its importable
65
66
67
68
69
    - cd ..
    - pwd
    - ls
    - python -c "import py_tools_ds; print(py_tools_ds)"
    - python -c "from py_tools_ds.geo.vector.geometry import boxObj"
70
71
  only:
    - master
Daniel Scheffler's avatar
Daniel Scheffler committed
72

73

74
pages:  # this job must be called 'pages' to advise GitLab to upload content to GitLab Pages
75
  stage: deploy
Daniel Scheffler's avatar
Daniel Scheffler committed
76
77
78
  dependencies:
    - test_py_tools_ds
  script:
79
80
81
      # Create the public directory
    - rm -rf public
    - mkdir public
Daniel Scheffler's avatar
Daniel Scheffler committed
82
83
    - mkdir -p public/doc
    - mkdir -p public/coverage
84
    - mkdir -p public/nosetests_reports
85
    # Copy over the docs
Daniel Scheffler's avatar
Daniel Scheffler committed
86
    - cp -r docs/_build/html/* public/doc/
87
88
89
90
91
92
93
    # 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
94
95
    - ls -al public/coverage
    - ls -al public/nosetests_reports
Daniel Scheffler's avatar
Daniel Scheffler committed
96
97
98
99
100
101
  artifacts:
    paths:
      - public
    expire_in: 30 days
  only:
    - master
102
103
104


deploy_pypi:
105
  stage: deploy
106
107
108
  dependencies:
    - test_py_tools_ds
  script:   # Configure the PyPI credentials, then push the package, and cleanup the creds.
109
    - source /root/miniconda3/bin/activate
110
111
112
113
114
115
116
117
118
119
120
121
    - printf "[distutils]\nindex-servers =\n    pypi\n\n" >> ~/.pypirc
    - printf "[pypi]\n""repository:"" https://upload.pypi.org/legacy/\n" >> ~/.pypirc
    - printf "username= ${PYPI_USER}\n" >> ~/.pypirc
    - printf "password= ${PYPI_PASSWORD}\n" >> ~/.pypirc
    - python setup.py check sdist upload -r pypi  # This will fail if your creds are bad.
    - echo "" > ~/.pypirc && rm ~/.pypirc  # If the above fails, this won't run.
  only:
    - /^v\d+\.\d+\.\d+([abc]\d*)?$/  # PEP-440 compliant version (tags)
  except:
    - dev


122
123
124
125
126
127
128
deploy_anaconda:
  stage: deploy
  dependencies:
    - test_py_tools_ds
    #- deploy_pypi
  script:
    - source /root/anaconda3/bin/activate
Daniel Scheffler's avatar
Fix.    
Daniel Scheffler committed
129
    - conda install -y -q conda-build
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
134
    #- anaconda logout
    #- anaconda login --username ${ANACONDA_USER} --password ${ANACONDA_PASSWORD}
135
136
137
    - conda build -c conda-forge -c defaults --token ${ANACONDA_TOKEN} --py=3.6 conda_recipe/meta.yaml
    - conda build -c conda-forge -c defaults --token ${ANACONDA_TOKEN} --py=2.7 conda_recipe/meta.yaml
    # - conda build -c conda-forge --token ${ANACONDA_TOKEN} public/conda.recipe/py_tools_ds  # --output returns package name
138
    # - conda build -c conda-forge --token ${ANACONDA_TOKEN} --python 3.6 --python 3.5 --python 3.4 --python 2.7 public/conda.recipe/py_tools_ds  # --output returns package name
139
140
141
142
143
144
145
146
147
148
    #- conda convert --platform all /home/jsmith/miniconda/conda-bld/linux-64/pyinstrument-0.13.1-py27_0.tar.bz2
    #-o outputdir/
    - anaconda logout
  only:
    - feature/conda_deployment
    #- /^v\d+\.\d+\.\d+([abc]\d*)?$/  # PEP-440 compliant version (tags)
  except:
    - dev


149
150
151
152
153
cleanup_pypirc:
   stage: cleanup
   when: always   # this is important; run even if preceding stages failed.
   script:
    - rm -vf ~/.pypirc  # we don't want to leave these around, but GitLab may clean up anyway.