-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
145 lines (134 loc) · 3.99 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# This file is a template, and might need editing before it works on your project.
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
image: python:3.11.8
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/topics/caching/
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
- venv/
default:
before_script:
- apt-get update -qq
- apt-get install gfortran -qq -y
- python --version # For debugging
# - pip install virtualenv
# - virtualenv venv
# - source venv/bin/activate
# - apt update
#this is a a rule that always passes for branches without jobs being run - otherwise some branches cannot be merged
pass:
inherit:
default: false
script:
- 'echo passed'
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # all MR
# flake8 ignore rules:
# E501 = Line too long
# W503 = Line break occurred before a binary operator
linting:
stage: test
tags:
- coverage
script:
- pip install flake8
- flake8 scanpro setup.py tests --ignore=E501,W503 --extend-exclude=scanpro/__init__.py # exclude __init__ due to version import
allow_failure: false
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # all MR
changes:
- setup.py
- tests/*.py
- scanpro/*.py
tests:
stage: test
tags:
- coverage
coverage: '/TOTAL.*\s(\d*.\d*\%)/'
script:
- pip install pytest
- pip install pytest-cov
- pip install pytest-html
- pip install . # install package
- cd tests/ # move to prevent pytest from loading local modules
- pytest --import-mode=importlib --cov-report=term --cov=scanpro . --junitxml=../pytest.xml --cov-report html:../htmlcov
artifacts:
when: always
paths:
- pytest.xml
- htmlcov
reports:
junit: pytest.xml
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # all MR
changes:
- tests/*.py
- scanpro/*.py
# -------- Sphinx documentation -------- #
build-pages:
script:
- apt-get update -qq && apt-get install -qq -y pandoc
- pip install sphinx sphinxcontrib-images sphinx-rtd-theme==1.2.0 # sphinx-rtd-theme==1.2.1 has an issue with wide tables
- pip install nbsphinx
- pip install nbsphinx_link
- pip freeze | grep sphinx
- pip install . # install package
- cd docs
- make html
artifacts:
paths:
- docs/build/html/
rules:
- if: $CI_COMMIT_BRANCH == "main" # after accepted MR to main
- when: manual # otherwise manual
allow_failure: True # manual is not required
# Deploy pages to test docs for branch
deploy-pages-MR:
needs:
- job: build-pages
artifacts: True
inherit:
default: false
environment:
name: pages/$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
url: "https://loosolab.pages.gwdg.de/-/software/pypropeller/-/jobs/$CI_JOB_ID/artifacts/docs/build/html/index.html"
artifacts:
paths:
- docs/build/html/
script:
- ls -l docs/
- echo "deploy"
artifacts:
paths:
- docs/build/html/
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
allow_failure: True
# Deploy documentation to public pages if it was the main branch
pages:
stage: deploy
needs:
- job: build-pages
artifacts: True
inherit:
default: false
script:
- mv docs/build/html/ public/
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == "main" # after accepted MR to main