-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
120 lines (111 loc) · 2.74 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
stages:
- build
- tests
- publish
# Global parameters for all jobs, cache everything we install.
variables:
PIP_CACHE_DIR: "${CI_PROJECT_DIR}/.pip_cache"
.pip-cache: &pip_cache
key: $CI_COMMIT_REF_SLUG
paths:
- .pip_cache/
policy: pull-push
python3-package:
image: ${CI_REGISTRY}/dockers/ci/python-build:3.12-alpine
stage: build
cache:
<<: *pip_cache
script:
- python -m build --sdist --wheel
artifacts:
name: "blacknet-${CI_COMMIT_REF_NAME}"
expire_in: 7 days
paths:
- dist/
python3-linter:
image: ${CI_REGISTRY}/dockers/ci/python-build:3.12-alpine
stage: tests
cache:
<<: *pip_cache
needs: []
before_script:
- python -m venv venv
- source venv/bin/activate
- make install-linting
script:
- ruff check --exit-zero --output-format=gitlab -o gl-code-quality-report.json
- ruff format --check --diff
- ruff check
artifacts:
expire_in: 7 days
reports:
codequality: gl-code-quality-report.json
when: always
allow_failure: true
python3-mypy:
image: ${CI_REGISTRY}/dockers/ci/python-build:3.12-alpine
stage: tests
cache:
<<: *pip_cache
needs: []
before_script:
- python -m venv venv
- source venv/bin/activate
- make install-blacknet
- make install-linting
script:
- mypy --junit-xml gl-typing-mypy-report.xml
artifacts:
reports:
junit: gl-typing-mypy-report.xml
when: always
allow_failure: true
python3-tests:
image: ${CI_REGISTRY}/dockers/ci/python-build:3.12-alpine
stage: tests
needs: []
variables:
MARIADB_USER: "blacknet"
MARIADB_PASSWORD: "blacknet"
MARIADB_ROOT_PASSWORD: "blacknet"
services:
- name: "mariadb:10.4"
alias: database
cache:
<<: *pip_cache
before_script:
- apk --no-cache add mariadb-client
- python -m venv venv
- source venv/bin/activate
- make install-testing
script:
- sh tests/db-setup.sh database blacknet blacknet blacknet blacknet
- sed -i 's/host = localhost/host = database/' tests/blacknet.cfg
- coverage run runtests.py
- coverage report
- coverage xml
coverage: '/TOTAL.+ ([0-9]{1,3}[.][0-9]{2}%)/'
artifacts:
name: "tests-${CI_COMMIT_REF_NAME}"
expire_in: 7 days
paths:
- tests/generated/
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
when: always
allow_failure: true
python3-publish:
image: ${CI_REGISTRY}/dockers/ci/python-build:3.12-alpine
stage: publish
variables:
TWINE_REPOSITORY_URL: ${CI_SERVER_URL}/api/v4/projects/${CI_PROJECT_ID}/packages/pypi
TWINE_USERNAME: gitlab-ci-token
TWINE_PASSWORD: ${CI_JOB_TOKEN}
only:
- tags
needs:
- python3-package
script:
- twine upload dist/blacknet-*.whl