forked from infobyte/faraday_plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
84 lines (73 loc) · 2.14 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
stages:
- pre_testing
- testing
- post_testing
- publish
before_script:
- apt-get update -qy
- pip install pip -U
workflow:
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- when: always
.install_faraday_venv: &install_faraday_venv
- pip3 install virtualenv
- virtualenv -p python3 faraday_venv
- source faraday_venv/bin/activate
- pip3 install pytest pytest-xdist pytest-cov
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/faradaysec/faraday.git
- cd faraday
- pip3 install $PIP_FLAGS .
- pip uninstall faraday-plugins -y # we need to install fardaysec for marshmallow schemas, we remove plugins from pypi
- cd ..
.clone_reports: &clone_reports
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/faradaysec/support/report-collection.git
- cd report-collection
- (git branch -a | grep $CI_COMMIT_BRANCH) && export REPORT_REF=$CI_COMMIT_BRANCH || export REPORT_REF=master
- git checkout $REPORT_REF
- cd ..
flake8:
image: python:3
stage: pre_testing
before_script:
- pip install flake8
# Help flake8 to find the Python files without .py extension.
- find . -name '*.py' >> files.txt
- sort -u files.txt | tee files.processed
script:
- python -m flake8 --statistics --count $(cat files.processed) --verbose
after_script:
- wc -l files.processed
.test_base:
stage: testing
coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
script:
- *clone_reports
- *install_faraday_venv
- pip3 install $PIP_FLAGS .
- pytest tests --capture=sys -v --cov=faraday_plugins --color=yes --disable-warnings $PYTEST_FLAGS
tests:
extends: .test_base
image: python:3
test_performance:
extends: .test_base
image: python:3
stage: post_testing
allow_failure: true
variables:
PYTEST_FLAGS: --performance
rules:
- if: '$CI_COMMIT_BRANCH == "dev"'
when: on_success
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