.gitlab-ci.yml 3.81 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 ci_env
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
    - nosetests.html
    - nosetests.xml
    when: always
Daniel Scheffler's avatar
Daniel Scheffler committed
33

34

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


48
49
50
test_py_tools_ds_install:
  stage: test
  script:
51
    - source /root/miniconda3/bin/activate
52
    - conda create -y -q -c conda-forge --name py_tools_ds_testinstall python=3
53
    - source activate py_tools_ds_testinstall
54

55
    # update conda and python
56
    - conda update -n base -c conda-forge conda
57
    # - conda update -c conda-forge python
58

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

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

65
    # run installer
66
    - python setup.py install
67

68
    # test if its importable
69
70
71
72
73
    - cd ..
    - pwd
    - ls
    - python -c "import py_tools_ds; print(py_tools_ds)"
    - python -c "from py_tools_ds.geo.vector.geometry import boxObj"
74
75
  only:
    - master
Daniel Scheffler's avatar
Daniel Scheffler committed
76

77

78
pages:  # this job must be called 'pages' to advise GitLab to upload content to GitLab Pages
Daniel Scheffler's avatar
Fix.    
Daniel Scheffler committed
79
  stage: deploy_pages
Daniel Scheffler's avatar
Daniel Scheffler committed
80
81
82
  dependencies:
    - test_py_tools_ds
  script:
83
84
85
      # Create the public directory
    - rm -rf public
    - mkdir public
Daniel Scheffler's avatar
Daniel Scheffler committed
86
87
    - mkdir -p public/doc
    - mkdir -p public/coverage
88
    - mkdir -p public/nosetests_reports
89

90
    # Copy over the docs
Daniel Scheffler's avatar
Daniel Scheffler committed
91
    - cp -r docs/_build/html/* public/doc/
92

93
94
    # Copy over the coverage reports
    - cp -r htmlcov/* public/coverage/
95

96
97
    # Copy over the nosetests reports
    - cp nosetests.* public/nosetests_reports/
98

99
100
101
    # Check if everything is working great
    - ls -al public
    - ls -al public/doc
Daniel Scheffler's avatar
Daniel Scheffler committed
102
103
    - ls -al public/coverage
    - ls -al public/nosetests_reports
Daniel Scheffler's avatar
Daniel Scheffler committed
104
105
106
107
108
109
  artifacts:
    paths:
      - public
    expire_in: 30 days
  only:
    - master
110
111
112


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


127
deploy_anaconda:
128
  stage: deploy_conda
129
  dependencies:
130
    - test_py_tools_ds
131
  script:
132
    - source /root/miniconda3/bin/activate ci_env
133
    - conda install -y -q conda-build conda-build-all anaconda-client
Daniel Scheffler's avatar
Fix.    
Daniel Scheffler committed
134
    - yum install -y patch # https://stackoverflow.com/questions/40392161/building-conda-skeleton-from-pypi-package-throws-error
135
    # - conda skeleton pypi py_tools_ds --output-dir public/conda.recipe/py_tools_ds # create recipe
136
    - conda config --set anaconda_upload yes  # enable auto-upload to anaconda
Daniel Scheffler's avatar
Daniel Scheffler committed
137
    # - anaconda login --username ${ANACONDA_USER} --password ${ANACONDA_PASSWORD}
138
139
140
    - 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/
141
142
    - anaconda logout
  only:
143
144
    # - feature/conda_deployment
    - /^v\d+\.\d+\.\d+([abc]\d*)?$/  # PEP-440 compliant version (tags)
145
146
  except:
    - dev