File: .gitlab-ci.yml

package info (click to toggle)
silkaj 0.11.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 1,164 kB
  • sloc: python: 6,901; sh: 68; makefile: 30
file content (242 lines) | stat: -rw-r--r-- 4,858 bytes parent folder | download
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
stages:
  - checks
  - tests
  - package
  - coverage

variables:
  DOCKER_IMAGE: "registry.duniter.org/docker/python3/poetry"
  PYTHON_VERSION: "3.11"

image: $DOCKER_IMAGE/$PYTHON_VERSION:latest

.code_changes:
  rules:
    - changes:
      - silkaj/**/*.py
      - tests/**/*.py
      - .pre-commit-config.yaml

.doc_changes:
  rules:
    - changes:
      - silkaj/**/*.py
      - tests/**/*.py
      - doc/*.md
      - README.md
      - CONTRIBUTING.md
      - .pre-commit-config.yaml

.changes:
  rules:
    - changes:
      - silkaj/**/*.py
      - tests/**/*.py
      - .gitlab-ci.yml
      - pyproject.toml

build:
  extends: .changes
  stage: checks
  script:
    - poetry build

.pre-commit:
  variables:
    PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
  cache:
    paths:
      - ${PRE_COMMIT_HOME}

autoflake:
  extends:
    - .code_changes
    - .pre-commit
  stage: checks
  script:
    - pre-commit run -a autoflake

format:
  extends:
    - .code_changes
    - .pre-commit
  stage: checks
  script:
    - pre-commit run -a black

isort:
  extends:
    - .code_changes
    - .pre-commit
  stage: checks
  script:
    - pre-commit run -a isort

mypy:
  extends:
    - .code_changes
    - .pre-commit
  stage: checks
  script:
    - pre-commit run -a mypy

pylint:
  extends:
    - .code_changes
    - .pre-commit
  stage: checks
  script:
    - pre-commit run -a pylint

pyupgrade:
  extends:
    - .code_changes
    - .pre-commit
  stage: checks
  script:
    - pre-commit run -a pyupgrade

pre-commit:hooks:
  extends:
    - .doc_changes
    - .pre-commit
  stage: checks
  script:
    - pre-commit run -a check-ast
    - pre-commit run -a check-merge-conflict
    - pre-commit run -a check-toml
    - pre-commit run -a debug-statements
    - pre-commit run -a end-of-file-fixer
    - pre-commit run -a mixed-line-ending
    - pre-commit run -a trailing-whitespace
    - pre-commit run -a insert-license
    - pre-commit run -a mdformat

.tests:
  extends: .changes
  stage: tests
  image: $DOCKER_IMAGE/$PYTHON_VERSION:latest
  script:
    - poetry install
    - poetry run pytest tests/unit

tests:3.7:
  extends: .tests
  variables:
    PYTHON_VERSION: "3.7"

tests:3.8:
  extends: .tests
  variables:
    PYTHON_VERSION: "3.8"

tests:3.9:
  extends: .tests
  variables:
    PYTHON_VERSION: "3.9"

tests:3.10:
  extends: .tests
  variables:
    PYTHON_VERSION: "3.10"

tests:3.11:cov:
  extends: .tests
  coverage: '/(?i)total.*\s+(\d+%)/'
  script:
    - poetry install
    - poetry run pytest --cov silkaj --cov-report html:cov_html --cov-report xml --cov-report term
  artifacts:
    paths:
      - cov_html
      - coverage.xml
    expire_in: 2 days
    reports:
      coverage_report:
        coverage_format: cobertura
        path: coverage.xml

.image:
  stage: package
  tags: [docker]
  image: docker:latest
  services:
    - docker:dind
  variables:
    PYTHON_VERSION: "3.11"
  script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    - docker build --pull -t "$CI_REGISTRY_IMAGE/$CHANNEL/$ENV:$CI_COMMIT_SHORT_SHA" -f image/$ENV --build-arg PYTHON_VERS=$PYTHON_VERSION .
    - docker push "$CI_REGISTRY_IMAGE/$CHANNEL/$ENV:$CI_COMMIT_SHORT_SHA"
    - docker tag "$CI_REGISTRY_IMAGE/$CHANNEL/$ENV:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY_IMAGE/$CHANNEL/$ENV:latest"
    - docker push "$CI_REGISTRY_IMAGE/$CHANNEL/$ENV:latest"

.image:release:
  extends: .image
  variables:
    CHANNEL: "release"
  after_script:
    - docker tag "$CI_REGISTRY_IMAGE/$CHANNEL/$ENV:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY_IMAGE/$CHANNEL/$ENV:$CI_COMMIT_TAG"
    - docker push "$CI_REGISTRY_IMAGE/$CHANNEL/$ENV:$CI_COMMIT_TAG"
  rules:
    - if: $CI_COMMIT_TAG
      when: manual

image:release:poetry:
  extends: .image:release
  variables:
    ENV: "poetry"

image:release:pip:
  extends: .image:release
  variables:
    ENV: "pip"

.image:branch:
  extends: .image
  allow_failure: true
  variables:
    CHANNEL: $CI_COMMIT_BRANCH
  rules:
    - if: $CI_COMMIT_TAG
      when: never
    - when: manual

image:branch:poetry:
  extends: .image:branch
  variables:
    ENV: "poetry"

image:branch:pip:
  extends: .image:branch
  variables:
    ENV: "pip"

pypi_test:
  stage: package
  rules:
    - if: $CI_COMMIT_TAG
      when: manual
  script:
    - poetry config repositories.pypi_test https://test.pypi.org/legacy/
    - poetry publish --build --username $PYPI_TEST_LOGIN --password $PYPI_TEST_PASSWORD --repository pypi_test

pypi:
  stage: package
  rules:
    - if: $CI_COMMIT_TAG
      when: manual
  script:
    - poetry publish --build --username $PYPI_LOGIN --password $PYPI_PASSWORD

pages:
  extends: .changes
  needs: ["tests:3.11:cov"]
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
  stage: coverage
  script: mv cov_html/ public/
  artifacts:
    paths:
      - public
    expire_in: 2 days