Skip to content

Commit 67328b4

Browse files
committed
Add GitLab CI
Signed-off-by: Thomas Keller <[email protected]>
1 parent 8064fed commit 67328b4

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

.gitlab-ci.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
default:
3+
image: mcr.microsoft.com/devcontainers/python:1-3.12-bookworm
4+
5+
workflow:
6+
name: '$CI_COMMIT_AUTHOR: $CI_COMMIT_TITLE'
7+
auto_cancel:
8+
on_new_commit: interruptible
9+
on_job_failure: all
10+
rules:
11+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
12+
variables:
13+
DEPLOY_ENV: "development"
14+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
15+
variables:
16+
DEPLOY_ENV: "staging"
17+
- if: $CI_COMMIT_BRANCH == $CI_COMMIT_TAG
18+
variables:
19+
DEPLOY_ENV: "production"
20+
- when: never
21+
22+
stages:
23+
- build
24+
- test
25+
- deploy
26+
27+
build-python-package:
28+
stage: build
29+
before_script:
30+
- pipx install uv
31+
script:
32+
- tools/build-package.sh
33+
artifacts:
34+
paths:
35+
- 'dist/*.whl'
36+
expire_in: 1 week
37+
38+
build-documentation:
39+
stage: build
40+
before_script:
41+
- pipx install uv
42+
script:
43+
- tools/build-docs.sh
44+
artifacts:
45+
paths:
46+
- build/html/
47+
48+
test-python-package:
49+
stage: test
50+
before_script:
51+
- pipx install uv
52+
script:
53+
- tools/test-package.sh
54+
coverage: '/TOTAL.*\s+(\d+%)$/'
55+
artifacts:
56+
reports:
57+
junit: report.xml
58+
coverage_report:
59+
coverage_format: cobertura
60+
path: coverage.xml
61+
62+
lint-python-package:
63+
stage: test
64+
before_script:
65+
- pipx install uv
66+
script:
67+
- uv run --all-extras flake8 src/python_training_project --format gl-codeclimate --output-file gl-code-quality-report.json
68+
artifacts:
69+
reports:
70+
codequality: gl-code-quality-report.json
71+
72+
additional-mr-checks:
73+
stage: test
74+
script:
75+
- echo "Additional checks for merge requests"
76+
rules:
77+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
78+
79+
deploy-python-package:
80+
stage: deploy
81+
before_script:
82+
- pipx install uv
83+
variables:
84+
UV_PUBLISH_URL: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi
85+
UV_PUBLISH_USERNAME: gitlab-ci-token
86+
UV_PUBLISH_PASSWORD: ${CI_JOB_TOKEN}
87+
88+
script:
89+
- tools/deploy-package.sh
90+
91+
pages:
92+
stage: deploy
93+
script:
94+
- mv build/html/ public/
95+
artifacts:
96+
paths:
97+
- public/
98+
99+
job-for-tags:
100+
stage: deploy
101+
script:
102+
- echo "Tag pipeline"
103+
rules:
104+
- if: $CI_COMMIT_TAG
105+

0 commit comments

Comments
 (0)