-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
188 lines (163 loc) · 4.69 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# pattern: jobs are generally named according to '{emoji} {function}:{object}[:{category}]'
# pattern: jobs are generally ordered by execution stage; properties are ordered alphabetically
# ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
variables:
POETRY_VIRTUALENVS_CREATE: "false"
PYSPRY_BRANCH_TAG: $CI_COMMIT_REF_SLUG
PYSPRY_IMAGE: $CI_REGISTRY_IMAGE/dev:$PYSPRY_TAG
PYSPRY_TAG: $CI_COMMIT_SHORT_SHA
stages:
- build
- lint
- test
- docs
- deploy
.dev image: &dev-image
image: $PYSPRY_IMAGE
include:
# ref https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Jobs/Container-Scanning.gitlab-ci.yml
- template: Jobs/Container-Scanning.gitlab-ci.yml
# ref https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Jobs/Dependency-Scanning.gitlab-ci.yml
- template: Jobs/Dependency-Scanning.gitlab-ci.yml
# ref https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Jobs/SAST.gitlab-ci.yml
- template: Jobs/SAST.gitlab-ci.yml
- local: .gitlab/docker-build.yml
inputs:
docker-version: "24"
platforms: '["linux/amd64", "linux/arm64"]'
service: dev
- file: build.yml
inputs: *dev-image
project: poetry-tools/ci-cd
ref: main
- file: check.yml
inputs: *dev-image
project: poetry-tools/ci-cd
ref: main
- file: poethepoet.yml
inputs:
<<: *dev-image
poetry-install: "false"
before-script: |-
pre-commit install --install-hooks || {
rm -rf $PRE_COMMIT_HOME
pre-commit install --install-hooks
}
stage: lint
task: lint
project: poetry-tools/ci-cd
ref: main
- file: poethepoet.yml
inputs:
<<: *dev-image
POETRY_VIRTUALENVS_CREATE: "false"
before-script: poetry install --only-root
poetry-install: "false"
stage: test
task: test
project: poetry-tools/ci-cd
ref: main
- file: poethepoet.yml
inputs:
<<: *dev-image
POETRY_VIRTUALENVS_CREATE: "false"
poetry-install: "false"
stage: docs
task: build-docs
project: poetry-tools/ci-cd
ref: main
- file: publish.yml
inputs: *dev-image
project: poetry-tools/ci-cd
ref: main
- file: publish.yml
inputs:
<<: *dev-image
env-tier: testing
env-url: https://test.pypi.org/project/$CI_PROJECT_NAME/
pypi-name: testpypi
pypi-password: $TESTPYPI_PASSWORD
pypi-url: https://test.pypi.org/legacy/
pypi-username: $TESTPYPI_USERNAME
project: poetry-tools/ci-cd
ref: main
- file: publish.yml
inputs:
<<: *dev-image
env-tier: production
env-url: https://pypi.org/project/$CI_PROJECT_NAME/
pypi-name: pypi
pypi-password: $PYPI_PASSWORD
pypi-url: https://upload.pypi.org/legacy/
pypi-username: $PYPI_USERNAME
project: poetry-tools/ci-cd
ref: main
semgrep-sast:
needs: []
container_scanning:
needs: [🏗 docker buildx bake]
variables:
GIT_STRATEGY: fetch
gemnasium-python-dependency_scanning:
needs: [🏗 docker buildx bake]
🏗️ poetry build: &needs_docker-buildx-bake
needs: [🏗 docker buildx bake]
✔️ poetry check: *needs_docker-buildx-bake
🪶 poe lint:
<<: *needs_docker-buildx-bake
artifacts:
paths: [docs]
reports:
codequality: [docs/reports/pylint-gitlab.json]
untracked: true
when: always
🪶 poe test:
<<: *needs_docker-buildx-bake
artifacts:
paths: [docs]
reports:
coverage_report:
coverage_format: cobertura
path: docs/reports/coverage.xml
junit: [docs/reports/pytest.xml]
untracked: true
when: always
coverage: '/Total coverage.*\s+(\d+(?:\.\d+)?)%/'
🪶 poe build-docs:
artifacts:
untracked: true
when: on_success
needs:
- job: 🪶 poe lint
artifacts: true
- job: 🪶 poe test
artifacts: true
variables:
GIT_DEPTH: "0"
GIT_STRATEGY: "clone"
🌐 poetry publish gitlab:
needs: &poetry-publish-needs
- ✔️ poetry check
- job: 🏗️ poetry build
artifacts: true
- 🪶 poe lint
- 🪶 poe test
rules:
- if: $CI_COMMIT_REF_PROTECTED == "true"
pages:
artifacts:
paths: [public]
needs:
- 🌐 poetry publish gitlab
- job: 🪶 poe build-docs
artifacts: true
rules: [if: $CI_COMMIT_REF_PROTECTED == "true"]
script: mv ./docs ./public
stage: deploy
🌐 poetry publish testpypi:
needs: *poetry-publish-needs
rules: &only-protected-tags
- if: $CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG
🌐 poetry publish pypi:
needs: [🌐 poetry publish testpypi]
rules: *only-protected-tags