-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
executable file
·113 lines (108 loc) · 3.75 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
variables:
# relative namespace of project
REL_NAMESPACE: "/lbsntransform/"
stages:
- test
- mkdocs
- deploy
test:
image: registry.gitlab.vgiscience.org/tud_ifk/miniconda-cidefault
before_script:
# initialize conda shell
- conda init bash
- source ~/.bashrc
# activate default ci_env from registry image
# contains anybadge
- conda activate ci_env
- conda env create -f environment_dev.yml
# activate tagmaps env
# with --stack environments
- conda activate lbsntransform --stack
# install additional packages
# needed in lbsntransform ci job
- pip install git+https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.vgiscience.de/tud_ifk/argdown.git
- conda install pylint bitarray
- pip install pdoc3 pylint-exit
stage: test
script:
# test dev install
- pip install -e . --no-dependencies
# copy changelog
- cp CHANGELOG.md docs/changelog.md
# argparse to markdown conversion
# for mkdocs args page
- python docs/argparse/argparse_doc.py
- argdown --truncate-help parse_args.py > docs/argparse/args.md
- python docs/argparse/argparse_after_doc.py
# to enable all warnings during ci doc generation
# - export PYTHONWARNINGS='error::UserWarning'
- python -c "import nltk;nltk.download('stopwords')"
- pdoc --config show_type_annotations=True --template-dir docs/apidoc/ --html --output-dir docs/api/ lbsntransform
# create badges
- pylint --output-format=text lbsntransform | tee pylint.txt || pylint-exit $?
- score=$(sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' pylint.txt)
- echo "Pylint score was $score"
- anybadge -l pylint --value=$score --file=pylint.svg 2=red 4=orange 9=yellow 10=green
- anybadge -l pipeline --value=passing --file=pipeline.svg passing=green failing=red
- version_var=$(sed -n "s#__version__ =\s*'\(.*\)'#\1#p" lbsntransform/version.py)
- echo "Version for badges $version_var"
- anybadge -l version --value="${version_var}" --file=pypi.svg --color=green
- anybadge -l mkdocs --value="Documentation" --file=documentation.svg --color=green
artifacts:
paths:
# quote because * is a
# special character in YAML
- '*.svg'
- docs/argparse/args.md
- docs/api/
- docs/changelog.md
rules:
# always execute on master or ci-test
- if:
$CI_COMMIT_BRANCH == "master" ||
$CI_COMMIT_BRANCH == "ci-test"
pages:
stage: mkdocs
image: registry.gitlab.vgiscience.org/tud_ifk/alpine-mkdocs
script:
- mkdir -p "public/${REL_NAMESPACE}"
- cp *.svg "public/${REL_NAMESPACE}"
# build docs
- mkdocs build
- mv site "public/${REL_NAMESPACE}"
# copy pdoc3 compiled API ref
- mv docs/api/lbsntransform/* "public/${REL_NAMESPACE}/site/api/"
- mv public/lbsntransform/site "public/${REL_NAMESPACE}/docs"
artifacts:
name: pages
paths:
- public
rules:
# always execute on master or ci-test
- if:
$CI_COMMIT_BRANCH == "master" ||
$CI_COMMIT_BRANCH == "ci-test"
docker-image-branch:
stage: deploy
image: docker:latest
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull --tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" -f docker/Dockerfile .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
rules:
- if: $CI_COMMIT_BRANCH != "master"
docker-image:
stage: deploy
image: docker:latest
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull --tag "$CI_REGISTRY_IMAGE" -f docker/Dockerfile .
- docker push "$CI_REGISTRY_IMAGE"
rules:
- if: $CI_COMMIT_BRANCH == "master"