-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
85 lines (78 loc) · 2.18 KB
/
.gitlab-ci.yml
File metadata and controls
85 lines (78 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
variables:
PYTHON_VERSION: 3.11
UV_VERSION: 0.7.2
IMAGE_PYTHON: python:${PYTHON_VERSION}-slim
IMAGE_UV: ghcr.io/astral-sh/uv:${UV_VERSION}-python${PYTHON_VERSION}-bookworm-slim
UV_LINK_MODE: copy
ENV: ci
POSTGRES_DB: test
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_HOST_AUTH_METHOD: trust
stages:
- lint
- typecheck
- test
- build
.uv_job: &uv_job
image: $IMAGE_UV
interruptible: true
allow_failure: true
cache:
- key:
files:
- uv.lock
paths:
- $UV_CACHE_DIR
variables:
GIT_STRATEGY: clone
before_script:
- export PATH="${PATH}:/root/.local/bin"
- uv tool install go-task-bin
ruff:
<<: *uv_job
stage: lint
needs: []
script:
- RUNNER="uv run" task lint
mypy:
<<: *uv_job
stage: typecheck
needs: []
script:
- RUNNER="uv run" task typecheck
pytest:
<<: *uv_job
stage: test
needs: []
services:
- postgres
script:
- RUNNER="uv run" task test-ci
build-image:
stage: build
image: docker
needs: []
script:
- echo "Installing uv ${UV_VERSION}"
- apk add --update curl && rm -rf /var/cache/apk/*
- curl -LsSf https://astral.sh/uv/${UV_VERSION}/install.sh | sh
- source $HOME/.local/bin/env
- export LATEST_TAG=$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version)
- echo "Publishing version ${LATEST_TAG}"
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH || true
- docker build . --cache-from $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:$LATEST_TAG
- docker push $CI_REGISTRY_IMAGE:$LATEST_TAG
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: always
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
when: manual
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY