-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
119 lines (110 loc) · 3.91 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
##
## Copyright (c) 2021 CS Group.
##
## This file is part of EOTile.
## See https://github.com/CS-SI/eotile for further info.
##
## 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
##
## http://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.
##
# EOTile CI
stages:
- test
- verify
- deploy
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
image: python:latest
# 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/reference/pip_install/#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/
before_script:
- python -V # Print out python version for debugging
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
test:
stage: test
image: python:3.7-slim
before_script:
- pip install ".[test]"
- mkdir -p reports
- rm -f reports/coverage*.xml
- rm -f reports/xunit*.xml
- coverage erase
script:
- coverage run -m unittest discover
- coverage xml -o public/coverage.xml
artifacts:
paths:
- public
pylint:
stage: test
image: python:3.7-slim
before_script:
- mkdir -p public/badges public/lint
- echo undefined > public/badges/$CI_JOB_NAME.score
- pip install pylint-gitlab
script:
- pylint --exit-zero --output-format=text $(find -type f -name "*.py" ! -path "**/venv/**") | tee /tmp/pylint.txt
- sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' /tmp/pylint.txt > public/badges/$CI_JOB_NAME.score
- pylint --exit-zero --output-format=pylint_gitlab.GitlabCodeClimateReporter $(find -type f -name "*.py" ! -path "**/venv/**") > codeclimate.json
- pylint --exit-zero --output-format=pylint_gitlab.GitlabPagesHtmlReporter $(find -type f -name "*.py" ! -path "**/venv/**") > public/lint/index.html
- pylint --exit-zero --output-format=parseable $(find -type f -name "*.py" ! -path "**/venv/**") > public/lint/parseable
after_script:
- anybadge --overwrite --label $CI_JOB_NAME --value=$(cat public/badges/$CI_JOB_NAME.score) --file=public/badges/$CI_JOB_NAME.svg 4=red 6=orange 8=yellow 10=green
- |
echo "Your score is: $(cat public/badges/$CI_JOB_NAME.score)"
artifacts:
paths:
- public
reports:
codequality: codeclimate.json
when: always
sonar:
stage: verify
image:
name: sonarsource/sonar-scanner-cli:latest
# Disable native entrypoint
entrypoint: [""]
before_script:
# Set branch's name except on master -> no option mean default branch on SonarQube
- test ${CI_COMMIT_REF_NAME} = master || SONAR_BRANCH_OPTION="-Dsonar.branch.name=${CI_COMMIT_REF_NAME}"
script:
- sonar-scanner -Dsonar.host.url=$SONAR_HOST -Dsonar.login=$SONAR_TOKEN ${SONAR_BRANCH_OPTION}
upload:
stage: deploy
script:
- pip install twine
- python setup.py sdist bdist_wheel
- TWINE_PASSWORD=${GITLAB_DEPLOY_TOKEN} TWINE_USERNAME=${GITLAB_DEPLOY_USERNAME} python -m twine upload --repository-url ${CI_SERVER_URL}/api/v4/projects/${CI_PROJECT_ID}/packages/pypi --verbose dist/*
only:
- master
# Building doc
pages:
script:
- pip install sphinx recommonmark
- sphinx-apidoc -f -o doc/rst eotile
- sphinx-build -b html doc public
artifacts:
paths:
- public