-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
127 lines (115 loc) · 3.1 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
stages:
- test
- build
- release
- badge
.py-with-cache:
tags: [ gitlab-build-01 ]
image: python:3.10
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
key: $CI_COMMIT_REF_SLUG
paths:
- .cache/pip
script:
# install poetry
- curl -sSL https://install.python-poetry.org | python3 -
# add poetry to path because it uses a weird installation path
- export PATH=/root/.local/bin:$PATH
# do not create a project specific virtualenv
- poetry config virtualenvs.create false --local
# install all dependencies
- poetry install --all-extras --without docs
.poetry-with-docs:
tags: [ gitlab-build-01 ]
image: python:3.10
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
key: $CI_COMMIT_REF_SLUG
paths:
- .cache/pip
script:
# install pandoc
- apt-get update && apt-get install -y pandoc
# install poetry
- curl -sSL https://install.python-poetry.org | python3 -
# add poetry to path because it uses a weird installation path
- export PATH=/root/.local/bin:$PATH
# do not create a project specific virtualenv
- poetry config virtualenvs.create false --local
# install all dependencies
- poetry install --all-extras --with docs,test
.push-changes-to-origin:
image: registry.gitlab.com/wuxi-nextcode/sdev/gitlab-tools:6.0.1
stage: build
tags:
- gitlab-build-01
variables:
GITLAB_TOKEN: $COMMON_WORKFLOW_GITLAB_API_TOKEN
test:
extends:
- .py-with-cache
stage: test
script:
- !reference [.py-with-cache, script]
- python3 -m pytest tests/ --cov=nextcode/ --disable-warnings --junitxml=test-results/pytest.xml --cov-report=xml
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
build:
extends:
- .py-with-cache
stage: build
script:
- !reference [.py-with-cache, script]
- poetry build
release:
extends:
- .py-with-cache
stage: release
when: on_success
script:
- !reference [.py-with-cache, script]
- poetry publish --build
only:
- tags
except:
- branches
badge:
image: python:3.7-stretch
stage: badge
when: on_success
script:
- pip install anybadge
- commits=$(git rev-list --all --count)
- anybadge -l "version" -v `git describe --abbrev=0 --tag` -f version.svg -c orange
artifacts:
paths:
- version.svg
only:
- tags
except:
- branches
pages:
extends:
- .poetry-with-docs
script:
- !reference [.poetry-with-docs, script]
# generate html docs and place in public folder
- sphinx-build -b html doc public
artifacts:
paths:
# The folder that contains the files to be exposed at the Page URL
- public
rules:
# This ensures that only pushes to the default branch will trigger
# a pages deploy
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
include:
- template: Jobs/Code-Quality.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Jobs/Code-Quality.gitlab-ci.yml
- template: SAST.gitlab-ci.yml
- template: Dependency-Scanning.gitlab-ci.yml