forked from GFZ-Centre-for-Early-Warning/modelprop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
154 lines (137 loc) · 4.21 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
146
147
148
149
150
151
152
153
154
# Copyright © 2021 Helmholtz Centre Potsdam GFZ German Research Centre for Geosciences, Potsdam, Germany
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
stages:
- test
- build
- deploy
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- .pip
.install_requirements: &install_requirements
- DEBIAN_FRONTEND=noninteractive apt-get update && apt-get upgrade -y
- pip3 install --cache-dir=.pip -r requirements.txt
verify_python:
image: python:3.7-buster
stage: test
tags:
- group
before_script:
- *install_requirements
script:
- python3 -m compileall .
python_pycodestyle:
image: python:3.7-buster
stage: test
# TODO: fix code to fit with PEP8 guidelines
allow_failure: true
tags:
- group
before_script:
- *install_requirements
- pip3 install --cache-dir=.pip pycodestyle
script:
- shopt -s globstar && pycodestyle {,**/}*.py
python_pylint:
image: python:3.7-buster
stage: test
# TODO: fix code to get a better pylint rating
allow_failure: true
tags:
- group
before_script:
- *install_requirements
- pip3 install --cache-dir=.pip pylint
script:
- shopt -s globstar && pylint --fail-under=8 {,**/}*.py
python_black:
image: python:3.7-buster
stage: test
tags:
- group
before_script:
- *install_requirements
- pip3 install --cache-dir=.pip black==22.3.0
script:
- black -l 79 --check .
run_tests:
image: python:3.7-buster
stage: test
tags:
- group
before_script:
- *install_requirements
script:
- python3 test_all.py
run_notebook:
image: python:3.7-buster
stage: test
tags:
- group
before_script:
- *install_requirements
- pip3 install scipy jupyter nbconvert ipykernel matplotlib
script:
- jupyter nbconvert --to html --execute --ExecutePreprocessor.kernel_name=python3 --output output.ipynb service_test.ipynb
verify_json:
stage: test
image: registry.gitlab.com/pipeline-components/jsonlint:0.12.0
cache: {}
script:
- |
find . -not -path './.git/*' -name '*.json' -type f -print0 |
parallel --will-cite -k -0 -n1 jsonlint -q
dockerbuild_latest:
image: docker/compose:1.29.2
stage: build
cache: {}
tags:
- group
script:
- docker build -t modelprop:latest -f metadata/Dockerfile .
# push latest image to Docker Hub
- docker tag modelprop:latest gfzriesgos/modelprop:latest
- docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PASSWORD}
- docker push gfzriesgos/modelprop:latest
# push latest image to GitLab Container Registry
- docker tag modelprop:latest git.gfz-potsdam.de:5000/id2/riesgos/modelprop:latest
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push git.gfz-potsdam.de:5000/id2/riesgos/modelprop:latest
dockerbuild_tagged:
image: docker/compose:1.29.2
stage: build
cache: {}
tags:
- group
rules:
- if: $CI_COMMIT_TAG
script:
- sed -i -e "s@:latest@:${CI_COMMIT_TAG}@g" metadata/modelprop.json
- docker build -t modelprop:${CI_COMMIT_TAG} -f metadata/Dockerfile .
# push image to Docker Hub
- docker tag modelprop:${CI_COMMIT_TAG} gfzriesgos/modelprop:${CI_COMMIT_TAG}
- docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PASSWORD}
- docker push gfzriesgos/modelprop:${CI_COMMIT_TAG}
# push image to GitLab Container Registry
- docker tag modelprop:${CI_COMMIT_TAG} git.gfz-potsdam.de:5000/id2/riesgos/modelprop:${CI_COMMIT_TAG}
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push git.gfz-potsdam.de:5000/id2/riesgos/modelprop:${CI_COMMIT_TAG}
deploy_latest:
stage: deploy
variables:
DEPLOY_LATEST_IMAGES: "true"
trigger:
project: id2/riesgos/gfz-riesgos-wps-repository
branch: master
strategy: depend