.gitlab-ci.yml 2.85 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:
Daniel Scheffler's avatar
Daniel Scheffler committed
22
    - source /root/mambaforge/bin/activate ci_env
23

Daniel Scheffler's avatar
Daniel Scheffler committed
24
25
    # TODO remove as soon as CI runner is rebuilt
    - mamba install pandas
26
    - pip install pytest pytest-cov pytest-reporter-html1
Daniel Scheffler's avatar
Daniel Scheffler committed
27

28
    - make pytest
Daniel Scheffler's avatar
Daniel Scheffler committed
29
30
31
32
    - make docs
  artifacts:
    paths:
    - htmlcov/
33
    - report.html
Daniel Scheffler's avatar
Daniel Scheffler committed
34
    - docs/_build/html/
35
36
    reports:
      cobertura: coverage.xml
Daniel Scheffler's avatar
Daniel Scheffler committed
37
      junit: report.xml
38
    expire_in: 30 days
39
    when: always
Daniel Scheffler's avatar
Daniel Scheffler committed
40

41

42
43
44
test_styles:
  stage: test
  script:
Daniel Scheffler's avatar
Daniel Scheffler committed
45
    - source /root/mambaforge/bin/activate ci_env
46
47
48
49
50
51
52
53
54
    - 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
55
56
57
test_urls:
  stage: test
  script:
Daniel Scheffler's avatar
Daniel Scheffler committed
58
    - source /root/mambaforge/bin/activate ci_env
59
60
    - pip install -U urlchecker
    - make urlcheck
Daniel Scheffler's avatar
Daniel Scheffler committed
61
62
63
  when: always


64
65
66
test_py_tools_ds_install:
  stage: test
  script:
Daniel Scheffler's avatar
Daniel Scheffler committed
67
    - source /root/mambaforge/bin/activate
68
    - mamba update -n base -c conda-forge --all
69

70
71
72
    # create py_tools_ds environment from environment_py_tools_ds.yml
    - mamba env create --name py_tools_ds_test -f tests/CI_docker/context/environment_py_tools_ds.yml
    - conda activate py_tools_ds_test
73

74
75
    # install py_tools_ds
    - pip install -e .
76
77
78
    - cd ..
    - pwd
    - ls
79
80

    # test if its importable
81
82
    - python -c "import py_tools_ds; print(py_tools_ds)"
    - python -c "from py_tools_ds.geo.vector.geometry import boxObj"
83
84
  only:
    - master
Daniel Scheffler's avatar
Daniel Scheffler committed
85

86

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

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

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

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

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


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