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

4
5
6
7
8
9
10
11
12

# Advise GitLab that these environment vars should be loaded from the Variables config.
variables:
    PYPI_USER: SECURE
    PYPI_PASSWORD: SECURE


stages:
  - test
13
  - deploy
14
15
16
  - cleanup


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


35
36
37
test_styles:
  stage: test
  script:
38
    - source /root/miniconda3/bin/activate
39
40
    - source activate py3
    - export GDAL_DATA=/root/miniconda3/envs/py3/share/gdal
41
42
43
44
45
46
47
48
49
50
    - 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


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

72

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


deploy_pypi:
104
  stage: deploy
105
106
107
  dependencies:
    - test_py_tools_ds
  script:   # Configure the PyPI credentials, then push the package, and cleanup the creds.
108
    - source /root/miniconda3/bin/activate
109
110
111
112
113
114
115
116
    - 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)
117
118
  except:
    - dev
119
120
121
122
123
124
125


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.