-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
172 lines (157 loc) · 3.65 KB
/
.gitlab-ci.yml
File metadata and controls
172 lines (157 loc) · 3.65 KB
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
stages:
- build
- package
- test
- lint
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- frontend/.npm/
- .cache/pip
eslint:
stage: lint
image: node:latest
needs: []
script:
- cd frontend
- npm ci --cache .npm --prefer-offline
- npx eslint --format=junit src > ../eslint.xml
artifacts:
reports:
junit: eslint.xml
pylint:
stage: lint
image: python:latest
needs: []
script:
- apt-get update
- apt-get install -y gcc libldap-common libldap2-dev libsasl2-dev
- cd backend
- pip3 install -r requirements-dev.txt
- pylint --exit-zero --output-format=junit shrunk tests/*.py > pylint.xml
artifacts:
reports:
junit: backend/pylint.xml
mypy:
# stage: lint
when: manual
image: python:latest
needs: []
script:
- cd backend
- pip3 install -r requirements-dev.txt
- mypy --junit-xml=./mypy.xml .
artifacts:
reports:
junit: mypy.xml
flake8:
stage: lint
image: python:3.13
needs: []
script:
- cd backend
- pip3 install -r requirements-dev.txt
- flake8 --format=pylint --exit-zero --format=junit-xml shrunk backend/tests > flake8.xml
artifacts:
reports:
junit: backend/flake8.xml
black:
stage: lint
image: python:latest
needs: []
script:
- cd backend
- pip3 install black==25.1.0 # TODO: Move to ruff after updating to a newer version of Python.
- black --check .
prettier:
stage: lint
image: node:latest
needs: []
script:
- cd frontend
- npm ci --cache .npm --prefer-offline
- npx prettier --check .
artifacts:
reports:
junit: eslint.xml
frontend:
stage: build
image: node:20
needs: []
script:
- cd frontend
- npm ci --cache .npm --prefer-offline
- npm install
- npm run build
artifacts:
paths:
- frontend/dist/*
expire_in: '1 day'
backend:
stage: build
image: python:3.6
needs: []
script:
- cd backend
- pip3 install -r requirements-build.txt
- apt-get update
- apt-get install -y libsasl2-dev libldap2-dev libssl-dev
- poetry config virtualenvs.create false
- poetry install
- poetry build
artifacts:
paths:
- backend/dist/shrunk-*.whl
expire_in: '1 day'
package:
stage: package
image: alpine:latest
needs:
- job: frontend
- job: backend
script:
- mkdir -p shrunk
- mkdir -p shrunk/frontend
- mkdir -p shrunk/backend
- cp -r frontend/dist/* shrunk/frontend
- cp -r backend/dist/* shrunk/backend
artifacts:
paths:
- shrunk/
expose_as: 'shrunk'
backend-test:
stage: test
image: python:3.6
needs: [backend]
dependencies:
- backend
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip_centos"
CRYPTOGRAPHY_DONT_BUILD_RUST: 1
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .cache/pip_centos
services:
- mongo
script:
- apt-get update
- apt-get install -y libldap2-dev libsasl2-dev
- pip3 install backend/dist/shrunk-*.whl
- mkdir /usr/share/GeoIP
- cp backend/GeoLite2-City.mmdb /usr/share/GeoIP/GeoLite2-City.mmdb
- curl -fsS https://dotenvx.sh | sh
- cp .env.example test.env
- dotenvx set SHRUNK_DB_HOST mongo -f test.env
- dotenvx set SHRUNK_DB_NAME shrunk_test -f test.env
- dotenvx set SHRUNK_FLASK_TESTING 1 -f test.env
- dotenvx set SHRUNK_GOOGLE_SAFEBROWSE_ENABLED 1 -f test.env
- dotenvx set SHRUNK_GOOGLE_SAFEBROWSE_API_KEY "$GOOGLE_SAFE_BROWSING_API" -f test.env
- cd backend
- pip install pytest
- dotenvx run -f ../test.env -- pytest --junitxml=../pytest.xml tests
artifacts:
reports:
junit: pytest.xml