Skip to content

Commit 9e85f00

Browse files
Add .gitlab-ci.yml
1 parent ee756b6 commit 9e85f00

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

.gitlab-ci.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Note: This GitLab CI configuration is used for internal testing, users can ignore it.
2+
3+
# Global --------------------------
4+
5+
image: python:3.10
6+
7+
variables:
8+
PIP_CACHE_DIR: "${CI_PROJECT_DIR}/.cache/pip"
9+
10+
cache:
11+
key:
12+
prefix: ${CI_JOB_IMAGE}
13+
files:
14+
- pyproject.toml
15+
- poetry.lock
16+
paths:
17+
- .cache/pip
18+
- .venv
19+
20+
stages:
21+
- check
22+
- build
23+
- test
24+
- publish
25+
26+
before_script:
27+
- pip install poetry
28+
- poetry --version
29+
- poetry config virtualenvs.in-project true
30+
- poetry install -vv
31+
32+
# stage: check ----------------------
33+
34+
formatting:
35+
stage: check
36+
script: poetry run black --check .
37+
38+
# stage: build ----------------------
39+
40+
package:
41+
stage: build
42+
script:
43+
- poetry build --verbose --no-interaction
44+
artifacts:
45+
paths:
46+
- dist/
47+
48+
# stage: test -------------------------
49+
50+
.use-test-server-template: &use_test_server_template
51+
secrets:
52+
DEEPL_AUTH_KEY:
53+
vault: jenkins/client_libraries/test_auth_key@backend
54+
file: false
55+
DEEPL_SERVER_URL:
56+
vault: jenkins/client_libraries/test_server_url@backend
57+
file: false
58+
59+
test:
60+
<<: *use_test_server_template
61+
stage: test
62+
parallel:
63+
matrix:
64+
- DOCKER_IMAGE: "python:3.6"
65+
- DOCKER_IMAGE: "python:3.7"
66+
- DOCKER_IMAGE: "python:3.8"
67+
- DOCKER_IMAGE: "python:3.9"
68+
- DOCKER_IMAGE: "python:3.10"
69+
- DOCKER_IMAGE: "python:3.6"
70+
EXTRA_POETRY_ADD_ARGUMENT: "[email protected]"
71+
- DOCKER_IMAGE: "python:3.9"
72+
EXTRA_POETRY_ADD_ARGUMENT: "[email protected]"
73+
image: ${DOCKER_IMAGE}
74+
script:
75+
- >
76+
if [[ ! -z "${EXTRA_POETRY_ADD_ARGUMENT}" ]]; then
77+
echo "Running poetry add ${EXTRA_POETRY_ADD_ARGUMENT}"
78+
poetry add ${EXTRA_POETRY_ADD_ARGUMENT}
79+
fi
80+
- poetry run coverage run -m pytest --junit-xml test_report.xml
81+
- poetry run coverage report
82+
- poetry run coverage xml
83+
artifacts:
84+
reports:
85+
cobertura:
86+
- coverage.xml
87+
junit:
88+
- test_report.xml
89+
when: always
90+
91+
# stage: publish -------------------------
92+
93+
pypi upload:
94+
stage: publish
95+
dependencies:
96+
- package
97+
rules:
98+
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
99+
script:
100+
- poetry publish --verbose --no-interaction --username $PYPI_USERNAME --password $PYPI_PASSWORD
101+
secrets:
102+
PYPI_USERNAME:
103+
vault: jenkins/client_libraries/pypi_username@backend
104+
file: false
105+
PYPI_PASSWORD:
106+
vault: jenkins/client_libraries/pypi_password@backend
107+
file: false
108+

0 commit comments

Comments
 (0)