-
Notifications
You must be signed in to change notification settings - Fork 6
/
.gitlab-ci.yml
176 lines (165 loc) · 4.83 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
---
include:
- template: Security/Secret-Detection.gitlab-ci.yml
stages:
- container build
- build
- test
- qa
- security
- deploy
secret_detection:
stage: security
interruptible: true
needs: []
container build:
stage: container build
needs: []
image:
name: moby/buildkit:latest
entrypoint: [""]
before_script:
- mkdir ~/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > ~/.docker/config.json
script:
- |
buildctl-daemonless.sh build --progress=plain \
--frontend=dockerfile.v0 \
--local context=. \
--local dockerfile=. \
--opt build-arg:PYTHON_IMAGE=$PYTHON_IMAGE \
--opt build-arg:PYTHON_VERSION=$PYTHON_VERSION \
--output type=image,\"name=$CI_REGISTRY_IMAGE/$PYTHON_IMAGE-$PYTHON_VERSION/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA\",push=true \
--import-cache type=registry,ref=$CI_REGISTRY_IMAGE:buildcache-$PYTHON_IMAGE-$PYTHON_VERSION \
--export-cache type=registry,ref=$CI_REGISTRY_IMAGE:buildcache-$PYTHON_IMAGE-$PYTHON_VERSION,mode=max
parallel:
matrix:
- PYTHON_IMAGE: python
PYTHON_VERSION:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- PYTHON_IMAGE: pypy
PYTHON_VERSION:
- "3.10"
container build ci:
stage: container build
needs: []
image:
name: moby/buildkit:latest
entrypoint: [""]
before_script:
- mkdir ~/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > ~/.docker/config.json
script:
- |
buildctl-daemonless.sh build --progress=plain \
--frontend=dockerfile.v0 \
--local context=. \
--local dockerfile=. \
--opt build-arg:INCLUDE_DEV_DEPS=true \
--output type=image,\"name=$CI_REGISTRY_IMAGE/ci/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA\",push=true \
--import-cache type=registry,ref=$CI_REGISTRY_IMAGE:buildcache-ci \
--export-cache type=registry,ref=$CI_REGISTRY_IMAGE:buildcache-ci,mode=max
build:
stage: build
needs:
- container build ci
image: $CI_REGISTRY_IMAGE/ci/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
artifacts:
paths:
- dist/*
script:
- poetry build -n -v
compile:
stage: test
image: $CI_REGISTRY_IMAGE/ci/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
needs:
- container build ci
- build
dependencies:
- build
before_script:
- pip3 install dist/iorgen-*.whl
script:
- ./test/test.py --no_missing
- env LC_ALL=fr_FR.UTF8 ./test/test.py --no_missing
test:
stage: test
image: $CI_REGISTRY_IMAGE/$PYTHON_IMAGE-$PYTHON_VERSION/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
needs:
- container build
- build
dependencies:
- build
before_script:
- pip3 install dist/iorgen-*.whl
script:
- ./test/test.py --no_compilation
parallel:
matrix:
- PYTHON_IMAGE: python
PYTHON_VERSION:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- PYTHON_IMAGE: pypy
PYTHON_VERSION:
- "3.10"
lint:
stage: qa
image: $CI_REGISTRY_IMAGE/ci/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
needs:
- container build ci
- build
dependencies:
- build
before_script:
- pip3 install dist/iorgen-*.whl
script:
- pre-commit run --all-files
variables:
PRE_COMMIT_HOME: $CI_PROJECT_DIR/.pre-commit-cache
cache:
key: $CI_JOB_NAME
paths:
- .pre-commit-cache
when: always
deploy:
stage: deploy
image: $CI_REGISTRY_IMAGE/ci/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
dependencies:
- build
rules:
- if: $CI_COMMIT_TAG
variables:
POETRY_HTTP_BASIC_GITLAB_USERNAME: "${PACKAGE_REGISTRY_USERNAME}"
POETRY_HTTP_BASIC_GITLAB_PASSWORD: "${PACKAGE_REGISTRY_PASSWORD}"
before_script:
- poetry config repositories.gitlab ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi
script:
- poetry publish --verbose --no-interaction -r gitlab
deploy container:
stage: deploy
image:
name: moby/buildkit:latest
entrypoint: [""]
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
before_script:
- mkdir ~/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > ~/.docker/config.json
script:
- |
buildctl-daemonless.sh build --progress=plain \
--frontend=dockerfile.v0 \
--local context=. \
--local dockerfile=. \
--output type=image,\"name=$CI_REGISTRY_IMAGE:${CI_COMMIT_TAG:-latest}\",push=true \
--import-cache type=registry,ref=$CI_REGISTRY_IMAGE:buildcache-python-3.10 \
--export-cache type=registry,ref=$CI_REGISTRY_IMAGE:buildcache-python-3.10,mode=max