.gitlab-ci.yml 2.99 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
  - deploy_pypi
16
17
18
  - cleanup


Daniel Scheffler's avatar
Daniel Scheffler committed
19
test_py_tools_ds:
20
  stage: test
Daniel Scheffler's avatar
Daniel Scheffler committed
21
  script:
22
    - source /root/miniconda3/bin/activate ci_env
23
    - make nosetests
Daniel Scheffler's avatar
Daniel Scheffler committed
24
25
26
27
28
    - make docs
  artifacts:
    paths:
    - htmlcov/
    - docs/_build/html/
29
30
31
    - nosetests.html
    - nosetests.xml
    when: always
Daniel Scheffler's avatar
Daniel Scheffler committed
32

33

34
35
36
test_styles:
  stage: test
  script:
37
    - source /root/miniconda3/bin/activate ci_env
38
39
40
41
42
43
44
45
46
    - make lint
  artifacts:
    paths:
    - tests/linting/flake8.log
    - tests/linting/pycodestyle.log
    - tests/linting/pydocstyle.log
    when: always


Daniel Scheffler's avatar
Daniel Scheffler committed
47
48
49
50
51
52
53
54
55
test_urls:
  stage: test
  script:
    - source /root/miniconda3/bin/activate ci_env
    - pip install urlchecker
    - urlchecker check . --file-types .py,.rst,.md,.json
  when: always


56
57
58
test_py_tools_ds_install:
  stage: test
  script:
59
    - source /root/miniconda3/bin/activate
60
    - conda create -y -q -c conda-forge --name py_tools_ds_testinstall python=3
61
    - conda activate py_tools_ds_testinstall
62

63
    # update conda and python
64
    - conda update -n base -c conda-forge conda
65
    # - conda update -c conda-forge python
66

67
    # avoid package incompatibilities due to usage of wrong channels
68
    # - conda config --set channel_priority strict  # otherwise gdal or libgdal may be installed from defaults channel
69

Daniel Scheffler's avatar
Daniel Scheffler committed
70
    # resolve some requirements with conda
71
    - conda install --yes -q -c conda-forge numpy gdal 'pyproj>=2.1.0' shapely geopandas
72

73
    # run installer
74
    - python setup.py install
75

76
    # test if its importable
77
78
79
80
81
    - cd ..
    - pwd
    - ls
    - python -c "import py_tools_ds; print(py_tools_ds)"
    - python -c "from py_tools_ds.geo.vector.geometry import boxObj"
82
83
  only:
    - master
Daniel Scheffler's avatar
Daniel Scheffler committed
84

85

86
pages:  # this job must be called 'pages' to advise GitLab to upload content to GitLab Pages
Daniel Scheffler's avatar
Fix.    
Daniel Scheffler committed
87
  stage: deploy_pages
Daniel Scheffler's avatar
Daniel Scheffler committed
88
89
90
  dependencies:
    - test_py_tools_ds
  script:
91
92
93
      # Create the public directory
    - rm -rf public
    - mkdir public
Daniel Scheffler's avatar
Daniel Scheffler committed
94
95
    - mkdir -p public/doc
    - mkdir -p public/coverage
96
    - mkdir -p public/nosetests_reports
97

98
    # Copy over the docs
Daniel Scheffler's avatar
Daniel Scheffler committed
99
    - cp -r docs/_build/html/* public/doc/
100

101
102
    # Copy over the coverage reports
    - cp -r htmlcov/* public/coverage/
103

104
105
    # Copy over the nosetests reports
    - cp nosetests.* public/nosetests_reports/
106

107
108
109
    # Check if everything is working great
    - ls -al public
    - ls -al public/doc
Daniel Scheffler's avatar
Daniel Scheffler committed
110
111
    - ls -al public/coverage
    - ls -al public/nosetests_reports
Daniel Scheffler's avatar
Daniel Scheffler committed
112
113
114
115
116
117
  artifacts:
    paths:
      - public
    expire_in: 30 days
  only:
    - master
118
119
120


deploy_pypi:
121
  stage: deploy_pypi
122
123
  dependencies:
    - test_py_tools_ds
124
  script:
125
    - source /root/miniconda3/bin/activate ci_env
126
127
128
    - pip install -U twine
    - python setup.py sdist
    - twine upload dist/*  # requires creds as environment variables
129
130
131
132
  only:
    - /^v\d+\.\d+\.\d+([abc]\d*)?$/  # PEP-440 compliant version (tags)
  except:
    - dev