forked from fabiobrill/RiesgosFloodDamage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
134 lines (119 loc) · 4.2 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
# 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
variables:
CPLUS_INCLUDE_PATH: "/usr/include/gdal"
C_INCLUDE_PATH: "/usr/include/gdal"
LC_ALL: "C.UTF-8"
LANG: "C.UTF-8"
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- .pip
.install_gdal_and_requirements: &install_gdal_and_requirements
- DEBIAN_FRONTEND=noninteractive apt-get update && apt-get upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install python3 git cython python3-scipy python3-numpy python3-gdal python3-pip libspatialindex-dev libgdal-dev zip -y
- pip3 install --cache-dir=.pip wheel
- export GDAL_VERSION=$(gdal-config --version)
- sed -i -e "s@GDAL==.*@GDAL==$GDAL_VERSION@" requirements.txt
- pip3 install --cache-dir=.pip -r requirements.txt
- pip3 uninstall -y GDAL
- pip3 install --cache-dir=.pip GDAL==${GDAL_VERSION} --global-option=build_ext --global-option="-I/usr/include/gdal"
verify_python:
image: ubuntu:18.04
stage: test
tags:
- group
before_script:
- *install_gdal_and_requirements
script:
- python3 -m compileall .
python_pycodestyle:
image: ubuntu:18.04
stage: test
tags:
- group
before_script:
- *install_gdal_and_requirements
- pip3 install --cache-dir=.pip pycodestyle
script:
- shopt -s globstar && pycodestyle showcase_ecuador/*.py
python_pylint:
image: ubuntu:18.04
stage: test
# TODO: fix code to get a better pylint rating
allow_failure: true
tags:
- group
before_script:
- *install_gdal_and_requirements
- pip3 install --cache-dir=.pip pylint
script:
- shopt -s globstar && pylint --fail-under=8 showcase_ecuador/*.py
python_black:
image: ubuntu:18.04
stage: test
tags:
- group
before_script:
- *install_gdal_and_requirements
- pip3 install --cache-dir=.pip black==21.4b2
script:
- black -l 79 --check .
verify_json:
stage: test
image: registry.gitlab.com/pipeline-components/jsonlint:0.12.0
cache: {}
script:
- 'cd showcase_ecuador && unzip data.zip'
- |
find . -not -path './.git/*' -name '*.geojson' -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 flooddamage:latest -f metadata/Dockerfile .
# push latest image to Docker Hub
- docker tag flooddamage:latest gfzriesgos/flooddamage:latest
- docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PASSWORD}
- docker push gfzriesgos/flooddamage:latest
# push latest image to GitLab Container Registry
- docker tag flooddamage:latest git.gfz-potsdam.de:5000/id2/riesgos/flooddamage:latest
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push git.gfz-potsdam.de:5000/id2/riesgos/flooddamage: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/flooddamage.json
- docker build -t flooddamage:${CI_COMMIT_TAG} -f metadata/Dockerfile .
# push image to Docker Hub
- docker tag flooddamage:${CI_COMMIT_TAG} gfzriesgos/flooddamage:${CI_COMMIT_TAG}
- docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PASSWORD}
- docker push gfzriesgos/flooddamage:${CI_COMMIT_TAG}
# push image to GitLab Container Registry
- docker tag flooddamage:${CI_COMMIT_TAG} git.gfz-potsdam.de:5000/id2/riesgos/flooddamage:${CI_COMMIT_TAG}
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push git.gfz-potsdam.de:5000/id2/riesgos/flooddamage:${CI_COMMIT_TAG}