-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
154 lines (140 loc) · 4.35 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
stages:
- build
- push
- test
- push_cov
- release
variables:
IMG_BASE: registry.gitlab.com/digonio/images/hostyourdocs-base:0dd4999e
IMG_KANIKO: gcr.io/kaniko-project/executor:v1.9.0-debug
CONTEXT_PATH: build_image/
MARIADB_ADDRESS: mariadb
MARIADB_DATABASE: hyd_db
MARIADB_USER: hyd_user
MARIADB_PASSWORD: ${DUMMY}
MARIADB_ROOT_PASSWORD: ${DUMMY}
SECRET_KEY: ${DUMMY}
####################################################################################################
### Build Stage
####################################################################################################
build_img:
stage: build
image:
name: ${IMG_KANIKO}
entrypoint: [""]
script:
# https://docs.gitlab.com/ee/ci/docker/using_kaniko.html
- sh script/build_base.sh
- >
/kaniko/executor
--context ${CONTEXT_PATH}
--destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}"
--tarPath image.tar
--no-push
--force
artifacts:
paths:
- image.tar
build_doc:
stage: build
image:
name: ${IMG_BASE}
script:
- pip install -r requirements-dev.txt
- pip install -e .
- python -m sphinx -b html doc/ doc/_build/html
- tar -C ./doc/_build/html -cpz . -f ./doc_build.tar.gz
artifacts:
paths:
- doc_build.tar.gz
only:
- master
- dev
####################################################################################################
### Push Stage
####################################################################################################
push_img:
stage: push
image:
name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""]
script:
- crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- crane push image.tar ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}
push_doc:
stage: push
image:
name: ${IMG_BASE}
script:
- >
curl -X 'POST'
'https://digon.io/hyd/api/v1/version/upload'
-H 'accept: application/json'
-H "Authorization: Bearer ${HYD_TOKEN}"
-H 'Content-Type: multipart/form-data'
-F 'file=@doc_build.tar.gz;type=application/gzip'
-F 'project_id=1'
-F "version=${CI_COMMIT_SHORT_SHA}"
- >
curl -X 'PATCH'
"https://digon.io/hyd/api/v1/tag/move?project_id=1&tag=${CI_COMMIT_BRANCH}&version=${CI_COMMIT_SHORT_SHA}"
-H 'accept: application/json'
-H "Authorization: Bearer ${HYD_TOKEN}"
only:
- master
- dev
####################################################################################################
### Test Stage
####################################################################################################
test_img:
stage: test
image: registry.gitlab.com/digonio/hostyourdocs:${CI_COMMIT_SHORT_SHA}
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
script:
- pip install -r requirements-dev.txt
- python -m pytest --cov=/usr/lib/python3.10/site-packages/hyd/backend test
- python -m coverage html
- tar -C ./htmlcov -cpz . -f ./cov_report.tar.gz
services:
- name: mariadb:10.10.1-rc-jammy
artifacts:
paths:
- cov_report.tar.gz
test_doc:
stage: test
image: "python:3.9.11-alpine3.15"
script:
- echo "Hello World"
allow_failure: true
####################################################################################################
### Push Coverage Report Stage
####################################################################################################
push_cov:
stage: push_cov
image:
name: ${IMG_BASE}
script:
- >
curl -X 'POST'
'https://digon.io/hyd/api/v1/version/upload'
-H 'accept: application/json'
-H "Authorization: Bearer ${HYD_TOKEN}"
-H 'Content-Type: multipart/form-data'
-F 'file=@cov_report.tar.gz;type=application/gzip'
-F 'project_id=1'
-F "version=${CI_COMMIT_SHORT_SHA}_coverage_report"
only:
- dev
####################################################################################################
### Release Stage
####################################################################################################
release_img:
stage: release
image:
name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""]
script:
- crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- crane push image.tar ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
only:
- tags