-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
170 lines (160 loc) · 3.38 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
stages:
- dependency cache
- code quality
- test
- build
- deploy
build-venv:
image: python:$PYVER
stage: dependency cache
variables:
CC: ccache gcc
CCACHE_DIR: $CI_PROJECT_DIR/.ccache
script:
- apt-get update
- apt-get -y install ccache
- ccache -z
- python -m venv --copies .venv
- source .venv/bin/activate
- pip install --upgrade pip
- pip install "poetry==1.5.1"
- poetry install --no-root
- poetry run python build.py
- ccache -s
parallel:
matrix:
- PYVER: ["3.8", "3.9", "3.10", "3.11"]
cache:
key:
files:
- poetry.lock
- src/libjpeg/jversion.h
prefix: ${PYVER}
paths:
- .venv/
- src/libjpeg
- $CI_PROJECT_DIR/.ccache
rules:
- when: always
# Code quality
.cq-base:
image: python:3.11
stage: code quality
before_script:
- source .venv/bin/activate
needs:
- build-venv
cache:
key:
files:
- poetry.lock
- src/libjpeg/jversion.h
prefix: "3.11"
paths:
- .venv/
- src/libjpeg
policy: pull
rules:
- when: always
lint:
extends: .cq-base
script:
- poetry install
- poetry run pylint torchjpeg
- poetry run pylint test
- poetry run pylint examples
- poetry run pylint ./*.py
type-check:
extends: .cq-base
script:
- poetry run mypy src/torchjpeg
- poetry run mypy test
- poetry run mypy examples
- poetry run mypy ./*.py
imports-sorted:
extends: .cq-base
script:
- poetry run isort . --check
style:
extends: .cq-base
script:
- poetry run black . --check
dco:
extends: .cq-base
script:
- poetry run invoke dco
# Tests
test:
image: python:$PYVER
stage: test
parallel:
matrix:
- PYVER: ["3.8", "3.9", "3.10", "3.11"]
before_script:
- source .venv/bin/activate
- poetry install
script:
- poetry run pytest test/import --junitxml=import.xml --cov-report xml
- poetry run pytest test/unit --junitxml=unit.xml --cov-report xml
#- poetry run pytest test/e2e
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
junit:
- import.xml
- unit.xml
needs:
- build-venv
cache:
key:
files:
- poetry.lock
- src/libjpeg/jversion.h
prefix: ${PYVER}
paths:
- .venv/
- src/libjpeg
policy: pull
coverage: '/^TOTAL.+?(\d+\%)$/'
rules:
- when: always
# Build wheels
build-wheel:
image: quay.io/pypa/manylinux_2_28_x86_64
stage: build
variables:
PYBIN: /opt/python/$PYVER/bin
parallel:
matrix:
- PYVER: [cp38-cp38, cp39-cp39, cp310-cp310, cp311-cp311]
script:
- yum install util-linux
- ${PYBIN}/pip install poetry==1.5.1
- ${PYBIN}/poetry run pip install "dunamai==1.15.0" "torch==2.0.0"
- ${PYBIN}/poetry version $(${PYBIN}/poetry run python version.py)
- ${PYBIN}/poetry build
- rename manylinux_2_28 manylinux2014 dist/*
needs: []
dependencies: []
artifacts:
paths:
- dist/
- pyproject.toml
rules:
- when: always
# Deploy
pypi:
stage: deploy
image: python:3.11
script:
- pip install "poetry==1.5.1"
- poetry publish --username __token__ --password ${pypi_push_key}
rules:
- if: "$CI_COMMIT_TAG"
when: on_success
- if: "$BUILD_OFFICIAL"
when: on_success
dependencies:
- build-wheel