-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
188 lines (175 loc) · 4.29 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
stages:
- lint
- test
- dependencies
- build
- deploy
python_code_quality:
stage: lint
image: python:3.9
before_script:
- cd backend
- export PYTHONPATH=$(pwd)
- export http_proxy="$HTTP_PROXY"
- export https_proxy="$HTTPS_PROXY"
- export no_proxy="$NO_PROXY"
- pip3 install pylint
script:
- pylint --fail-under=1 proxmox_api/*.py > code_quality.txt
- cat code_quality.txt
artifacts:
paths:
- backend/code_quality.txt
expire_in: 2 days
when: always
allow_failure: true
angular_code_quality:
stage: lint
image: node
before_script:
- cd frontend
- NG_CLI_ANALYTICS=ci
- npm install -g @angular/cli
script:
- ng add @angular-eslint/schematics --skip-confirmation
- ng lint --force > code_quality.txt
- cat code_quality.txt
artifacts:
paths:
- frontend/code_quality.txt
expire_in: 2 days
when: always
allow_failure: true
test_backend:
stage: test
image: python:3.9
needs :
- python_code_quality
before_script:
- export http_proxy="$HTTP_PROXY"
- export https_proxy="$HTTPS_PROXY"
- export no_proxy="$NO_PROXY"
- apt update
- apt install sqlite3
- export ENVIRONMENT='TEST'
- export KEYRING_DNS_SECRET=$KEYRING_DNS_SECRET
- export PROXMOX_API_KEY_NAME=$PROXMOX_API_KEY_NAME
- export PROXMOX_API_KEY=$PROXMOX_API_KEY
- export PROXMOX_BACK_DB_DEV=$PROXMOX_BACK_DB_DEV
- export ADH6_API_KEY=$ADH6_API_KEY
- cd backend/
- export PYTHONPATH=$(pwd)
- pip3 install -r requirements.txt
- pip3 install -r test-requirements.txt
script :
- pytest --cov=proxmox_api --cov-report term-missing --cov-report xml:./coverage_out_report.xml --junitxml=report.xml
coverage: '/TOTAL.*\s+(\d+%)$/'
artifacts:
when: always
paths:
- backend/report.xml
reports:
junit: backend/report.xml
angular_build:
stage: build
image: node
needs:
- angular_code_quality
before_script:
- npm cache clean --force
- npm config rm proxy
- npm config rm https-proxy
- npm config set proxy "$HTTP_PROXY"
- npm config set https-proxy "$HTTP_PROXY"
- npm cache clear --force
- cd frontend
- NG_CLI_ANALYTICS=ci
- export NODE_OPTIONS=--openssl-legacy-provider
script:
- npm ci --prefer-offline --no-audit
- npm install -g @angular/cli
- yarn ng build
artifacts:
paths:
- frontend/dist
expire_in: 2 days
deploy_backend:
stage: deploy
needs :
- angular_build
- test_backend
before_script:
- export http_proxy="$HTTP_PROXY"
- export https_proxy="$HTTPS_PROXY"
- export no_proxy="$NO_PROXY"
- cd backend
- pip3 install -r requirements.txt
- sudo /bin/systemctl stop proxmox_api
- rm -rf /var/www/proxmox_api
script:
- cp -r proxmox_api /var/www/proxmox_api
- cd /var/www/proxmox_api
- sudo /bin/systemctl start proxmox_api
tags:
- hosting-proxmox
environment:
name: production
url: https://hosting.minet.net/
only:
- master
deploy_frontend:
stage: deploy
needs:
- angular_build
- test_backend
script:
- export no_proxy="$NO_PROXY"
- rm -rf /var/www/proxmox_dashboard
- cp -r frontend/dist/hosting /var/www/proxmox_dashboard
tags:
- hosting-proxmox
environment:
name: production
url: https://hosting.minet.net/
only:
- master
deploy_backend_dev:
stage: deploy
needs:
- angular_build
- test_backend
before_script:
- export http_proxy="$HTTP_PROXY"
- export https_proxy="$HTTPS_PROXY"
- export no_proxy="$NO_PROXY"
- cd backend
- pip3 install -r requirements.txt
- sudo /bin/systemctl stop proxmox_api
- rm -rf /var/www/proxmox_api
script:
- cp -r proxmox_api /var/www/proxmox_api
- cd /var/www/proxmox_api
- sudo /bin/systemctl start proxmox_api
tags:
- hosting-dev
environment:
name: development
url: https://hosting-dev.minet.net/
only:
- development
deploy_frontend_dev:
stage: deploy
needs:
- angular_build
- test_backend
script:
- export no_proxy="$NO_PROXY"
- rm -rf /var/www/proxmox_dashboard
- cp -r frontend/dist/hosting /var/www/proxmox_dashboard
environment:
name: development
url: https://hosting-dev.minet.net/
tags:
- hosting-dev
only:
- development