add cicd and precommit

This commit is contained in:
2025-03-01 18:23:56 +01:00
parent 3713325a87
commit 2839757cf8
5 changed files with 231 additions and 1 deletions

66
.gitlab-ci.yaml Normal file
View File

@@ -0,0 +1,66 @@
image: python:3.13
stages:
- lint
- test
- build
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.pip-cache"
UV_CACHE_DIR: "$CI_PROJECT_DIR/.uv-cache"
# Cache dependencies between jobs
cache:
paths:
- .pip-cache/
- .uv-cache/
- .venv/
before_script:
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH="$HOME/.cargo/bin:$PATH"
- uv venv .venv
- source .venv/bin/activate
- uv pip install -r requirements.txt
lint:
stage: lint
script:
- uv pip install ruff
- ruff check .
- ruff format --check .
test:
stage: test
script:
- uv pip install pytest pytest-cov
- pytest --cov=./ --cov-report=xml
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
dependency-check:
stage: lint
script:
- uv pip install pip-audit
- pip-audit
allow_failure: true
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG
build:
stage: build
script:
- uv pip install build
- python -m build
artifacts:
paths:
- dist/
rules:
- if: $CI_COMMIT_TAG