Код: Выделить всё
# This file is a template, and might need editing before it works on your project.
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
image: python:3.11
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/topics/caching/
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- /root/.cache/pypoetry
- .cache/pip
- venv/
before_script:
#- ubuntu-drivers install --gpgpu nvidia:555 -y
- apt-get update && apt-get install software-properties-common python3-launchpadlib -y
- apt-get update && add-apt-repository main contrib non-free non-free-firmware # ppa:graphics-drivers/ppa
- echo "deb http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware" >> /etc/apt/sources.list
- cat /etc/apt/sources.list
#- deb http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
- apt-get update && apt-get install ffmpeg libsm6 libxext6 libegl-dev -y #nvidia-driver firmware-misc-nonfree -y -o Dpkg::Options::="--force-overwrite" # nvidia-dkms nvidia-utils -y
- nvidia-smi # For debugging
- python --version # For debugging
- pip install --upgrade pip
- pip install poetry
- poetry install --with dev
- source `poetry env info --path`/bin/activate
stages:
- test
- wheel_build
- doc_build
- nuitka_windows
- nuitka_linux
- release
test_job:
image: "python:$VERSION"
stage: test
script:
- poetry run pytest ./tests/
parallel:
matrix:
- VERSION: ["3.9", "3.10", "3.11", "3.12"]
artifacts:
when: always
reports:
junit: /builds/my_python_project/junit_report.xml
coverage_report:
coverage_format: cobertura
path: /builds/my_python_project/coverage.xml
coverage: '/TOTAL.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
wheel_build_job:
stage: wheel_build
needs: [test_job]
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- poetry build
- pwd
artifacts:
paths:
- /builds/my_python_project/dist/*.whl
doc_build_job:
stage: doc_build
needs: [test_job]
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- cd docs
- poetry run sphinx-apidoc -o ./source/ ../my_python_project/
- poetry run sphinx-build -M html ./source/ ./build/
- mv build/html/ ../public/
artifacts:
paths:
- /builds/my_python_project/public
nuitka_job_windows:
stage: nuitka_windows
tags: [windows]
needs: [wheel_build_job]
rules:
- if: '($CI_COMMIT_TAG != null) && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
script:
- echo "Hello World from Windows"
nuitka_job_linux:
stage: nuitka_linux
tags: [linux]
needs: [wheel_build_job]
rules:
- if: '($CI_COMMIT_TAG != null) && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
script:
- echo "Hello World from Linux"
release_job:
stage: release
needs:
- job: wheel_build_job
optional: false
- job: doc_build_job
optional: false
- job: nuitka_job_linux
optional: true
- job: nuitka_job_windows
optional: true
rules:
- if: '($CI_COMMIT_TAG != null) && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'# Run this job when a tag is created
script:
- echo "running release_job"
- echo "Current commit tag is $CI_COMMIT_TAG"
- curl --location --output /usr/local/bin/release-cli "https://gitlab.com/api/v4/projects/gitlab-org%2Frelease-cli/packages/generic/release-cli/latest/release-cli-linux-amd64"
- chmod +x /usr/local/bin/release-cli
- release-cli -v
release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
tag_name: "$CI_COMMIT_TAG"
description: "$CI_COMMIT_DESCRIPTION"
Это вообще правильный подход или есть другие, лучшие реализации моих намерений? Я искал возможные учебные пособия, но пока не нашел ничего полезного.
Подробнее здесь: https://stackoverflow.com/questions/789 ... d-pipeline