This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
266 lines (205 loc) · 5.68 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
266
stages:
- examine
- deploy
image: debian:stable
default:
before_script:
- apt update -y
- apt dist-upgrade -y
- apt install -y python3-pip git
- pip3 install --user -U virtualenv pip
- export PATH=~/.local/bin:$PATH
- virtualenv ~/venv
- source ~/venv/bin/activate
- pip install -U pip
- mkdir -p ~/.pip
test-fs:
stage: examine
script:
- pip install .
- export RFSTOOLS_CONNECTION_TYPE=FS
# - ./tests/generic-tests
test-sftp:
stage: examine
script:
- pip install .
- apt install -y openssh-server
- ssh-keygen -f ~/.ssh/id_rsa -N ''
- cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
- chmod og-wx ~/.ssh/authorized_keys
- mkdir -p /run/sshd
- /usr/sbin/sshd
- export RFSTOOLS_CONNECTION_TYPE=SFTP
- export RFSTOOLS_HOST=localhost
- export RFSTOOLS_USERNAME=root
- export RFSTOOLS_NO_HOST_KEY_CHECKING=TRUE
# - ./tests/generic-tests
test-ftp:
stage: examine
script:
- pip install .
- apt install -y vsftpd net-tools
- cat < $TEST_VSFTPD_CONFIG > /etc/vsftpd.conf
- mkdir -p /var/run/vsftpd/empty
- vsftpd /etc/vsftpd.conf &
- sleep 5
- netstat -l
- export RFSTOOLS_CONNECTION_TYPE=FTP
- export RFSTOOLS_HOST=127.0.0.1
- export RFSTOOLS_USERNAME=anonymous
- export RFSTOOLS_PASSWORD=anonymous@profinit.lan
# - ./tests/generic-tests
test-smb12:
stage: examine
script:
- pip install .
- apt install -y samba
- mkdir -p /samba/tmp
- chmod 1777 /samba/tmp
- cat < $TEST_SMB_CONFIG > /etc/samba/smb.conf
- testparm /etc/samba/smb.conf
- smbd -D
- nmbd -D
- sleep 10
- smbstatus
- export RFSTOOLS_CONNECTION_TYPE=SMB12
- export RFSTOOLS_HOST=127.0.0.1
- export RFSTOOLS_USERNAME=testing
- export RFSTOOLS_PASSWORD=testing
- export RFSTOOLS_PORT=445
- export RFSTOOLS_SERVICE_NAME=share
- export RFSTOOLS_USE_DIRECT_TCP=true
# - ./tests/generic-tests
test-smb23:
stage: examine
script:
- pip install .
- apt install -y samba
- mkdir -p /samba/tmp
- chmod 1777 /samba/tmp
- cat < $TEST_SMB_CONFIG > /etc/samba/smb.conf
- testparm /etc/samba/smb.conf
- smbd -D
- nmbd -D
- sleep 10
- smbstatus
- |
smbpasswd -a root -s <<EOF
testing
testing
EOF
- export RFSTOOLS_CONNECTION_TYPE=SMB23
- export RFSTOOLS_HOST=127.0.0.1
- export RFSTOOLS_USERNAME=root
- export RFSTOOLS_PASSWORD=testing
- export RFSTOOLS_SERVICE_NAME=share
- export RFSTOOLS_DISABLE_SECURE_NEGOTIATE=True
- export RFSTOOLS_DEBUG=False
- export RFSTOOLS_VERBOSE=True
# - ./tests/generic-tests
# test:
# script:
# - python setup.py test
# - pip install tox flake8 # you can also use tox
# - tox -e py36,flake8
build:
stage: examine
script:
- python setup.py sdist bdist_wheel
# an alternative approach is to install and run:
- pip install dist/*.tar.gz
# run the command here
artifacts:
paths:
- dist/*.whl
- dist/*.tar.gz
expire_in: 4 weeks
deploy:
stage: deploy
environment: deploy
rules:
- if: $CI_COMMIT_TAG
script:
- pip install twine
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url https://git.profinit.eu/api/v4/projects/${CI_PROJECT_ID}/packages/pypi dist/*
backup-dependencies:
stage: deploy
rules:
- if: $CI_COMMIT_TAG
script:
- mkdir dependencies
- |
apt install -y pandoc ghc rustc
pip download -d ./dependencies -r requirements.txt --no-binary :all:
artifacts:
paths:
- dependencies
expire_in: never
deploy-doc:
stage: deploy
rules:
- if: $CI_COMMIT_TAG
- if: $CI_DOCS_ACCESS_TOKEN
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- |
apt install -y texlive-latex-recommended latexmk texlive-fonts-recommended texlive-latex-extra
export doc_repo=/tmp/rfslib-docs
./docs/generate-docs.sh
[ -n "$CI_COMMIT_TAG" ] && {
echo Sleeping for 30 seconds to prevent race condition.
sleep 30
}
pushd /tmp
git clone https://oauth2:${CI_DOCS_ACCESS_TOKEN}@gitlab.com/rfs4/rfslib-docs
popd
pushd $doc_repo
rm -fr ./commands ./rfslib-dev-doc.pdf 2>/dev/null || :
popd
cp docs/_build/latex/rfslib.pdf $doc_repo/rfslib-dev-doc.pdf
cp docs/_build/README.md $doc_repo
cd $doc_repo
git config --global user.email "$GITLAB_USER_EMAIL"
git config --global user.name "$GITLAB_USER_NAME"
git add -A
git commit -m "$CI_COMMIT_MESSAGE" || :
[ -n "$CI_COMMIT_TAG" ] && git tag "$CI_COMMIT_TAG"
git push
git push --tags
artifacts:
paths:
- /builds/rfs/rfslib/doc
expire_in: 4 weeks
include:
- template: Security/SAST.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
- template: Security/Dependency-Scanning.gitlab-ci.yml
- template: Security/License-Scanning.gitlab-ci.yml
license_scanning:
stage: examine
before_script: []
sast:
stage: examine
before_script: []
secret_detection:
stage: examine
before_script: []
dependency_scanning:
stage: examine
before_script:
- pip3 install --user .
sonarcloud-check:
stage: examine
before_script: []
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task