forked from wmglab-duke/ascent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
128 lines (111 loc) · 3.78 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
# 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/
default:
image: python:3.7
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_REF_PROTECTED
# 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.
stages: # List of stages for jobs, and their order of execution
- lint
- test
- deploy
cache:
paths:
- .cache/pip
- venv/
before_script:
- python --version # For debugging
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
isort:
stage: lint
script:
- pip install isort
- isort --check-only config docs examples scripts src run tests
black:
stage: lint
script:
- pip install black
- black --check config docs examples scripts src run tests
flake8:
stage: lint
script:
- pip install flake8 flake8-eradicate flake8-simplify flake8-bugbear flake8-builtins flake8-comprehensions flake8-blind-except flake8-use-fstring
- flake8 --extend-ignore=T100,T101,T102 config docs examples scripts src run tests
docstring_check:
stage: lint
script:
- pip install flake8 flake8-docstrings flake8-rst-docstrings darglint
- flake8 --select=D,DAR,RST config docs examples scripts src run
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
#Here should check that no DevelopmentError is thrown in repo
dev_check:
stage: lint
script:
- ( ! grep "raise DevelopmentError" --include \*.py -r . )
- pip install flake8 flake8-fixme
- flake8 --select=T100,T101,T102 config docs examples scripts src run tests
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
#Run tests
pytest:
stage: test
script:
- pip install -r requirements.txt
- pip install pytest pytest-cov
- apt-get update && apt-get -y install libgl1
- pytest --cov=src/ tests/
- coverage xml
test_docs:
stage: test
script:
- pip install -U sphinx mock sphinx-rtd-theme
- pip install -Ur docs/rtd_requirements.txt
- cd docs/source; sphinx-build -W -b html . ../../public
except:
- master
compile_java:
before_script:
- java -version
stage: test
image: openjdk:8-jdk
script:
- mkdir bin
- mkdir comsolplugins
- wget -q -O bin/json-20190722.jar https://repo1.maven.org/maven2/org/json/json/20190722/json-20190722.jar
- wget -qO- --header "PRIVATE-TOKEN:$COMSOL_JARS_TOKEN" "https://gitlab.oit.duke.edu/api/v4/projects/27633/repository/archive" | tar -xvz --strip-components 1 -C comsolplugins
- javac -classpath bin/json-20190722.jar:comsolplugins/* src/model/*.java -d bin
artifacts:
untracked: true
pages:
stage: deploy
script:
- pip install -U sphinx mock sphinx-rtd-theme
- pip install -Ur docs/rtd_requirements.txt
- cd docs/source; sphinx-build -W -b html . ../../public
artifacts:
paths:
- public
only:
- master