-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.gitlab-ci.yml
265 lines (248 loc) · 9.36 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
variables:
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_TEST_IMAGE_JFROG: psono-docker.jfrog.io/psono/psono-fileserver:$CI_COMMIT_REF_NAME
CONTAINER_LATEST_IMAGE_JFROG: psono-docker.jfrog.io/psono/psono-fileserver:latest
stages:
- build
- test
- release
- deploy
build-container-alpine:
except:
- schedules
stage: build
image: psono-docker.jfrog.io/ubuntu:22.04
services:
- name: docker:25-dind
alias: docker
command: ["--tls=false"]
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/
DOCKER_TLS_CERTDIR: ""
script:
- sh ./var/update_version.sh
- apt-get update && apt-get install -y curl ca-certificates iptables libdevmapper1.02.1
- curl -fSL "https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/containerd.io_1.6.28-1_amd64.deb" -o containerd.deb && echo "3fcc3e44e6d507c346ae05bbaef8f4bb04dfa8da9f04af658537f7e373c91340 containerd.deb" | sha256sum -c -
- curl -fSL "https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-buildx-plugin_0.12.1-1~ubuntu.22.04~jammy_amd64.deb" -o docker-buildx-plugin.deb && echo "3fb7cd11fd9bf7c31d81c1afa96c023519d9e6e17422192aa4d0aa2767ed0776 docker-buildx-plugin.deb" | sha256sum -c -
- curl -fSL "https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce-cli_25.0.3-1~ubuntu.22.04~jammy_amd64.deb" -o docker-ce-cli.deb && echo "624abe860a3d9dd190c278263b3ae115d54ce1135774a79f84026a6ec6ebafd1 docker-ce-cli.deb" | sha256sum -c -
- curl -fSL "https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce_25.0.3-1~ubuntu.22.04~jammy_amd64.deb" -o docker-ce.deb && echo "63c7703814558a829ab3cc37c8018c050c9dad56f99c261090500f6c87821fd1 docker-ce.deb" | sha256sum -c -
- dpkg -i ./containerd.deb ./docker-ce.deb ./docker-ce-cli.deb ./docker-buildx-plugin.deb
- docker info
- echo $CI_JOB_TOKEN | docker login --username=gitlab-ci-token --password-stdin registry.gitlab.com
- docker context create builder
- docker buildx create builder --use
- docker buildx build --platform linux/amd64,linux/arm64 -f DockerfileAlpine -t $CONTAINER_TEST_IMAGE --push --pull .
only:
- branches@psono/psono-fileserver
- tags@psono/psono-fileserver
run-unittests-ubuntu:
except:
- schedules
stage: test
image: psono-docker.jfrog.io/docker:25.0.3-git
services:
- name: docker:25-dind
alias: docker
command: ["--tls=false"]
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/
DOCKER_TLS_CERTDIR: ""
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
PSONO_SECRET_KEY: RQTKawYQv4w6KkuphcLzLu7r5ap7xE5DSDu5SkKXjMnWBQ93mcMKjdZfeZkY2Y7C
script:
- docker info
- sh ./var/update_version.sh
- docker build -f DockerfileUbuntu -t ubu-testimage --pull .
- docker run -d -e POSTGRES_HOST_AUTH_METHOD=trust --name db postgres:15.5-alpine
- sleep 20
- docker run --link db:postgres ubu-testimage bash -c "apt-get update && apt-get install -y python3-pip && pip3 install -r requirements-dev.txt && python3 ./psono/manage.py migrate && coverage3 run --source='.' ./psono/manage.py test restapi.tests cron.tests && coverage3 report --omit=psono/restapi/migrations/*,psono/administration/tests*,psono/administration/migrations/*,psono/restapi/tests*"
run-unittests-alpine:
except:
- schedules
stage: test
image: psono-docker.jfrog.io/docker:25.0.3-git
services:
- name: docker:25-dind
alias: docker
command: ["--tls=false"]
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/
DOCKER_TLS_CERTDIR: ""
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
PSONO_SECRET_KEY: RQTKawYQv4w6KkuphcLzLu7r5ap7xE5DSDu5SkKXjMnWBQ93mcMKjdZfeZkY2Y7C
script:
- docker info
- echo $CI_JOB_TOKEN | docker login --username=gitlab-ci-token --password-stdin registry.gitlab.com
- docker pull $CONTAINER_TEST_IMAGE
- docker run -d -e POSTGRES_HOST_AUTH_METHOD=trust --name db postgres:15.5-alpine
- sleep 20
- docker run --link db:postgres $CONTAINER_TEST_IMAGE /bin/sh -c "pip3 install -r requirements-dev.txt && python3 ./psono/manage.py migrate && python3 ./psono/manage.py test --parallel=8 restapi.tests cron.tests"
only:
- branches@psono/psono-fileserver
- tags@psono/psono-fileserver
run-unittests-alpine-arm64:
except:
- schedules
stage: test
image: psono-docker.jfrog.io/docker:25.0.3-git
tags:
- arm64
services:
- name: docker:25-dind
alias: docker
command: ["--tls=false"]
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/
DOCKER_TLS_CERTDIR: ""
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
PSONO_SECRET_KEY: RQTKawYQv4w6KkuphcLzLu7r5ap7xE5DSDu5SkKXjMnWBQ93mcMKjdZfeZkY2Y7C
script:
- docker info
- echo $CI_JOB_TOKEN | docker login --username=gitlab-ci-token --password-stdin registry.gitlab.com
- docker pull $CONTAINER_TEST_IMAGE
- docker run -d -e POSTGRES_HOST_AUTH_METHOD=trust --name db postgres:15.5-alpine
- sleep 20
- docker run --link db:postgres $CONTAINER_TEST_IMAGE /bin/sh -c "pip3 install -r requirements-dev.txt && python3 ./psono/manage.py migrate && python3 ./psono/manage.py test --parallel=8 restapi.tests cron.tests"
only:
- branches@psono/psono-fileserver
- tags@psono/psono-fileserver
run-vulnerability-python-dependencies:
except:
- schedules
stage: test
image: python:3.11-buster
script:
- pip3 install pip-audit
- pip-audit -r ./requirements.txt
allow_failure: true
run-vulnerability-scan:
except:
- schedules
stage: test
image: psono-docker.jfrog.io/docker:25.0.3-git
services:
- name: docker:25-dind
alias: docker
command: ["--tls=false"]
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/
DOCKER_TLS_CERTDIR: ""
script:
- docker info
- echo $CI_JOB_TOKEN | docker login --username=gitlab-ci-token --password-stdin registry.gitlab.com
- docker pull $CONTAINER_TEST_IMAGE
- docker run -e "LANG=C.UTF-8" $CONTAINER_TEST_IMAGE sh -c "pip3 install bandit && bandit -r /root -x /root/psono/restapi/tests,/root/psono/administration/tests"
allow_failure: true
only:
- branches@psono/psono-fileserver
- tags@psono/psono-fileserver
release-docker-jfrog:
except:
- schedules
stage: release
image: psono-docker.jfrog.io/docker:25.0.3-git
services:
- name: docker:25-dind
alias: docker
command: ["--tls=false"]
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/
DOCKER_TLS_CERTDIR: ""
script:
- apk add skopeo
- docker info
- echo $CI_JOB_TOKEN | docker login --username=gitlab-ci-token --password-stdin registry.gitlab.com
- echo $artifactory_credentials | docker login --username=gitlab --password-stdin psono-docker.jfrog.io
- skopeo copy --all docker://$CONTAINER_TEST_IMAGE docker://$CONTAINER_TEST_IMAGE_JFROG
only:
- /^v[0-9]*\.[0-9]*\.[0-9]*$/
release-docker:
except:
- schedules
stage: release
image: psono-docker.jfrog.io/docker:25.0.3-git
services:
- name: docker:25-dind
alias: docker
command: ["--tls=false"]
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/
DOCKER_TLS_CERTDIR: ""
script:
- apk add skopeo
- docker info
- echo $CI_JOB_TOKEN | docker login --username=gitlab-ci-token --password-stdin registry.gitlab.com
- echo $artifactory_credentials | docker login --username=gitlab --password-stdin psono-docker.jfrog.io
- skopeo copy --all docker://$CONTAINER_TEST_IMAGE docker://$CONTAINER_LATEST_IMAGE_JFROG
only:
- /^v[0-9]*\.[0-9]*\.[0-9]*$/
release-version-bump:
except:
- schedules
stage: release
image: psono-docker.jfrog.io/docker:25.0.3-git
script:
- mkdir -p /root/.ssh
- echo "$github_deploy_key" > /root/.ssh/id_rsa
- chmod 600 /root/.ssh/id_rsa
- ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts
- git remote set-url --push origin "[email protected]:${CI_PROJECT_PATH}.git"
- git config --global user.email "[email protected]"
- git config --global user.name "Build Server"
- git checkout master
- git pull
- sh ./var/update_version.sh
- git add psono/VERSION.txt
- git add psono/SHA.txt
- git commit -m "Bump version [skip ci]"
- git push
only:
- /^v[0-9]*\.[0-9]*\.[0-9]*$/
deploy-docker:
except:
- schedules
stage: deploy
image: psono-docker.jfrog.io/docker:25.0.3-git
services:
- name: docker:25-dind
alias: docker
command: ["--tls=false"]
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/
DOCKER_TLS_CERTDIR: ""
script:
- docker info
- echo $CI_JOB_TOKEN | docker login --username=gitlab-ci-token --password-stdin registry.gitlab.com
- echo $docker_hub_credentials | docker login --username=psonogitlab --password-stdin
- sh ./var/deploy-docker.sh
environment:
name: production
url: https://psono.pw
only:
- /^v[0-9]*\.[0-9]*\.[0-9]*$/
deploy-changelog:
except:
- schedules
stage: deploy
image: psono-docker.jfrog.io/ubuntu:22.04
script:
- sh ./var/deploy_changelog.sh
environment:
name: static.psono.com
url: https://static.psono.com/gitlab.com/psono/psono-fileserver/changelog.json
only:
- /^v[0-9]*\.[0-9]*\.[0-9]*$/