65 lines
1 KiB
YAML
65 lines
1 KiB
YAML
image: python:3.10
|
|
|
|
stages:
|
|
- build
|
|
- linter
|
|
- tests
|
|
|
|
variables:
|
|
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
|
|
|
# Trigger only if python file changes
|
|
.py_changes: &py_changes
|
|
only:
|
|
refs:
|
|
- merge_requests
|
|
- branches
|
|
- tags
|
|
changes:
|
|
- .gitlab-ci.yml
|
|
- "**/*.py"
|
|
|
|
.poetry: &poetry
|
|
<<: *py_changes
|
|
before_script:
|
|
- python -m pip install poetry>=1.7
|
|
- poetry config virtualenvs.in-project true
|
|
- poetry install
|
|
|
|
# Build
|
|
Poetry install:
|
|
stage: build
|
|
<<: *poetry
|
|
script:
|
|
- poetry version
|
|
|
|
# Linter
|
|
Ruff check:
|
|
stage: linter
|
|
<<: *poetry
|
|
script:
|
|
- poetry run ruff check .
|
|
|
|
Ruff format:
|
|
stage: linter
|
|
<<: *poetry
|
|
script:
|
|
- poetry run ruff format
|
|
|
|
|
|
# Tests
|
|
Pytest:
|
|
stage: tests
|
|
<<: *poetry
|
|
script:
|
|
- poetry run pytest
|
|
--cov-report xml:coverage.xml
|
|
--junitxml=report.xml
|
|
coverage: '/^TOTAL\s+\d+\s+\d+\s+(\d+\%)$/'
|
|
artifacts:
|
|
expire_in: 1 day
|
|
reports:
|
|
junit: report.xml
|
|
coverage_report:
|
|
coverage_format: cobertura
|
|
path: coverage.xml
|