-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
144 lines (124 loc) · 3.77 KB
/
.gitlab-ci.yml
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
---
stages:
- Build
- Static Analysis
- Tests
- Release
variables:
DEFAULT_PYTHON_VERSION: "3.12"
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
PYTHON_REQUIREMENTS_TARGET: "dev"
cache:
paths:
- .cache/pip
- .venv
default:
image: $CI_REGISTRY_IMAGE
interruptible: true
# ============================================================================ #
# Build #
# ============================================================================ #
docker:
stage: Build
image: gitlab/dind
services:
- docker:dind
rules:
- changes:
- container/Dockerfile
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE --no-cache container
- docker push $CI_REGISTRY_IMAGE
# ============================================================================ #
# Static Analysis #
# ============================================================================ #
.static-analysis-job:
stage: Static Analysis
allow_failure: true
before_script:
- just --set PY_T $PYTHON_REQUIREMENTS_TARGET --set PY_V $DEFAULT_PYTHON_VERSION _install-ci
- .venv/bin/python --version
parallel:
matrix:
- DIR: [src, tests]
rules:
- exists:
- "$DIR/**/*.py"
bandit:
extends: .static-analysis-job
script:
- just _lint bandit "$DIR" -r -c pyproject.toml
black:
extends: .static-analysis-job
script:
- just _lint black "$DIR" --check
flake8:
extends: .static-analysis-job
script:
- just _lint flake8 "$DIR"
isort:
extends: .static-analysis-job
script:
- just _lint isort "$DIR" --check-only
mypy:
extends: .static-analysis-job
script:
- just _lint mypy "$DIR"
pylint:
extends: .static-analysis-job
script:
- just _lint pylint "$DIR"
commitlint:
stage: Static Analysis
image: node:latest
before_script:
- npm install --save-dev @commitlint/cli @commitlint/config-conventional
script:
- npx commitlint --from ${CI_MERGE_REQUEST_TARGET_BRANCH_SHA} --to HEAD --verbose
# ============================================================================ #
# Test #
# ============================================================================ #
.test-job:
stage: Tests
needs:
- job: docker
optional: true
rules:
- exists:
- tests/**/*.py
tests:
extends: .test-job
parallel:
matrix:
- VERSION: ["3.8", "3.9", "3.10", "3.11", "3.12"]
before_script:
- just --set PY_T $PYTHON_REQUIREMENTS_TARGET --set PY_V $DEFAULT_PYTHON_VERSION _reset-ci
- .venv/bin/python --version
script:
- just _cov-ci
coverage: '/TOTAL.*\s+(\d+%)$/'
artifacts:
when: always
expire_in: 1 month
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
junit: report.xml
# ============================================================================ #
# Release #
# ============================================================================ #
semantic-release:
stage: Release
image: node:latest
before_script:
- npm install --save-dev conventional-changelog-conventionalcommits semantic-release @semantic-release/changelog @semantic-release/exec @semantic-release/git @semantic-release/gitlab-config
# https://gitlab.com/gitlab-org/gitlab-runner/-/issues/2245
- curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
- apt update
- apt install git-lfs
- git lfs pull
- rm .git/hooks/post-checkout || true
script:
- npx semantic-release