-
Notifications
You must be signed in to change notification settings - Fork 15
/
.gitlab-ci.yml
172 lines (145 loc) · 4.3 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
variables:
TZ: "America/New_York"
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
APT_CACHE_DIR: "$CI_PROJECT_DIR/apt-cache"
POSTGRES_DB: custom_db
POSTGRES_USER: custom_user
POSTGRES_PASSWORD: custom_pass
FARADAY_USER: custom_user
FARADAY_PASSWORD: custom_pass
FARADAY_EMAIL: [email protected]
FARADAY_URL: http://localhost:5985/
DEFAULT_FARADAY_REF: white/dev
workflow:
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- when: always
cache:
paths:
- "$CI_PROJECT_DIR/.cache/pip"
- "$CI_PROJECT_DIR/apt-cache"
before_script:
- mkdir -pv $APT_CACHE_DIR
stages:
- testing
- publish
- deploy
services:
- postgres:latest
flake8:
image: python:3
stage: .pre
script:
- pip install .[dev]
- flake8 --max-line-length=120 --exclude hooks .
black:
image: python:3
stage: .pre
script:
- pip install .[dev]
- black --line-length=79 --check .
.generate_license: &generate_license
- mkdir -p ~/.faraday/doc
- base64 -d $FARADAY_LICENSE_TAR_GZ > license.tgz
- tar xzvf license.tgz -C ~/.faraday/doc
.unit_tests_base:
stage: testing
coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
script:
- if [ $FARADAY_REF ]; then :; else export FARADAY_REF=$DEFAULT_FARADAY_REF; fi; echo FARADAY_REF=$FARADAY_REF
- export LC_ALL=C.UTF-8
- export LANG=C.UTF-8
- pip3 install virtualenv
- *generate_license
- apt-get update -y
- apt-get install pandoc libsasl2-dev python3-dev libldap2-dev libssl-dev -y
- virtualenv faraday_venv
- source faraday_venv/bin/activate
- pip install pip -U
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/faradaysec/faraday.git
- cd faraday && git checkout $FARADAY_REF
- echo FARADAY_COMMIT=$(git rev-parse HEAD)
- pip install --upgrade -r requirements.txt
- pip install $PIP_INSTALL_FLAGS .
- pip install --upgrade responses pytest-xdist pytest-cov
- pip install --upgrade -r requirements_dev.txt
- pip install pyyaml
- mkdir -p ~/.faraday/config
- mkdir -p ~/.faraday/doc
- mkdir -p ~/.faraday/logs
- cp tests/data/server.ini ~/.faraday/config
- python3 ../tests/config/psql_config.py
- pip install 'importlib-metadata<5.0'
- faraday-manage create-tables
- faraday-manage create-superuser --username $FARADAY_USER --password $FARADAY_PASSWORD --email $FARADAY_EMAIL
- faraday-server &
- deactivate
- cd ..
- virtualenv faraday_cli_venv
- source faraday_cli_venv/bin/activate
- git clone https://github.com/python-cmd2/cmd2.git
- cd cmd2/plugins/ext_test
- pip install .
- cd ../../..
- pip install $PIP_INSTALL_FLAGS .[test]
- mkdir run_from
- cd run_from && mkdir logs && pytest ../tests --capture=sys -v --cov=../faraday_cli --color=yes --disable-warnings --junitxml=../report.xml
after_script:
- cp ~/.faraday/logs/*.log run_from/logs/
artifacts:
reports:
junit: report.xml
paths:
- dist/*
- run_from/logs/*
expire_in: 7 days
rules:
- when: on_success
tags:
- faradaytests
.latest_unit_test_base:
extends: .unit_tests_base
before_script:
.alpha_unit_test_base:
extends: .unit_tests_base
variables:
PIP_INSTALL_FLAGS: --pre
allow_failure: true
rules:
- if: '$CI_COMMIT_REF_NAME =~ /^(dev|master)$/'
when: on_success
- if: '$TEST_ALPHA'
when: on_success
unit_test 3.7:
extends: .latest_unit_test_base
image: python:3.7
unit_test 3.8:
extends: .latest_unit_test_base
image: python:3.8
unit_test 3.9:
extends: .latest_unit_test_base
image: python:3.9-rc
allow_failure: true
alpha_unit_test 3.7:
extends: .alpha_unit_test_base
image: python:3.7
alpha_unit_test 3.8:
extends: .alpha_unit_test_base
image: python:3.8
alpha_unit_test 3.9:
extends: .alpha_unit_test_base
image: python:3.9-rc
publish_pypi:
image: python:3
stage: publish
script:
- apt-get update -qy
- apt-get install twine -y
- python setup.py sdist bdist_wheel
- twine upload -u $PYPI_USER -p $PYPI_PASS dist/* --verbose
rules:
- if: '$CI_COMMIT_TAG'
when: on_success
include:
- local: docs/.gitlab-ci.yml