22default :
33 image : mcr.microsoft.com/devcontainers/python:1-3.12-bookworm
44
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+
522stages :
623 - build
724 - test
825 - deploy
926
10- include :
11- - template : Jobs/Code-Quality.gitlab-ci.yml
12-
1327build-python-package :
1428 stage : build
1529 before_script :
16- - pipenv install --system --dev
17- - pip install packaging
30+ - pip install uv
1831 script :
19- - echo "Building the project..."
20- - python -m build --wheel
32+ - tools/build-package.sh
2133 artifacts :
2234 paths :
23- - dist
35+ - ' dist/*.whl '
2436 expire_in : 1 week
2537
2638build-documentation :
2739 stage : build
2840 before_script :
29- - pipenv install --system --dev
30- - pip install -e .
31- - pip install packaging
32- - pip install tomli
33- - pip install certifi
41+ - pip install uv
3442 script :
35- - cd docs
36- - pipenv run make html
37-
38- code_quality :
39- when : manual
43+ - tools/build-docs.sh
44+ artifacts :
45+ paths :
46+ - build/html/
4047
4148test-python-package :
4249 stage : test
4350 before_script :
44- - pipenv install --system --dev
45- - pip install -e .
51+ - pip install uv
4652 script :
47- - echo "Running unit tests"
48- - pytest
53+ - tools/test-package.sh
4954 coverage : ' /TOTAL.*\s+(\d+%)$/'
5055 artifacts :
5156 reports :
@@ -54,10 +59,49 @@ test-python-package:
5459 coverage_format : cobertura
5560 path : coverage.xml
5661
62+ lint-python-package :
63+ stage : test
64+ before_script :
65+ # TODO: Add flake8-gl-codeclimate as dependency
66+ - pip install flake8-gl-codeclimate
67+ - pip install uv
68+ script :
69+ - uv run --all-extras flake8 src/python_training_project --format gl-codeclimate --output-file gl-code-quality-report.json
70+ artifacts :
71+ reports :
72+ codequality : gl-code-quality-report.json
73+
74+ additional-mr-checks :
75+ stage : test
76+ script :
77+ - echo "Additional checks for merge requests"
78+ rules :
79+ - if : $CI_PIPELINE_SOURCE == "merge_request_event"
80+
5781deploy-python-package :
5882 stage : deploy
5983 before_script :
60- - pip install build twine
84+ - pip install uv
85+ variables :
86+ UV_PUBLISH_URL : ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi
87+ UV_PUBLISH_USERNAME : gitlab-ci-token
88+ UV_PUBLISH_PASSWORD : ${CI_JOB_TOKEN}
89+
90+ script :
91+ - tools/deploy-package.sh
92+
93+ pages :
94+ stage : deploy
95+ script :
96+ - mv build/html/ public/
97+ artifacts :
98+ paths :
99+ - public/
100+
101+ job-for-tags :
102+ stage : deploy
61103 script :
62- - echo "Deploying the package..."
63- - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
104+ - echo "Tag pipeline"
105+ rules :
106+ - if : $CI_COMMIT_TAG
107+
0 commit comments