.gitlab-ci.yml 3.28 KB
Newer Older
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


17
test_geoarray:
18
  stage: test
19
20
21
22
  script:
    - source /root/anaconda3/bin/activate
    - export GDAL_DATA=/root/anaconda3/share/gdal
    - export PYTHONPATH=$PYTHONPATH:/root  # /root <- directory needed later
23
    - export LD_LIBRARY_PATH=/root/anaconda3/lib:$LD_LIBRARY_PATH # /root <- directory needed later
24
    # update in-house dependencies
25
    - pip install py_tools_ds>=0.9.0
26
    # run tests
27
    - make nosetests
28
29
30
31
32
    - make docs
  artifacts:
    paths:
    - htmlcov/
    - docs/_build/html/
33
34
    - nosetests.html
    - nosetests.xml
35
36
37
    when: always


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
test_styles:
  stage: test
  script:
    - source /root/anaconda3/bin/activate
    - export GDAL_DATA=/root/anaconda3/share/gdal
    - 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
56
57
test_geoarray_install:
  stage: test
  script:
    - source /root/anaconda3/bin/activate
    - export GDAL_DATA=/root/anaconda3/share/gdal
58
    - conda create -y -q --name geoarray python=3
59
60
61
    - source activate geoarray
     # resolve some requirements with conda
    - conda install --yes -q -c conda-forge numpy gdal scikit-image matplotlib rasterio pyproj basemap shapely
62
    # install geoarray
63
    - python setup.py install
64
    # test if its importable
65
66
67
68
69
    - cd ..
    - pwd
    - ls
    - python -c "import geoarray; print(geoarray)"
    - python -c "from geoarray import GeoArray"
70
71
  only:
    - master
72

73

74
75
deploy_pages:
  stage: deploy
76
77
78
  dependencies:
    - test_geoarray
  script:
79
80
81
82
      # Create the public directory
    - rm -rf public
    - mkdir public
    - mkdir -p public/doc
83
    - mkdir -p public/coverage
84
    - mkdir -p public/nosetests_reports
85
    # Copy over the docs
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
94
95
96
97
98
99
  artifacts:
    paths:
      - public
    expire_in: 30 days
  only:
    - master
100
101
102


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


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.