-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.drone.yml
110 lines (110 loc) · 3.36 KB
/
.drone.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
kind: pipeline
type: docker
name: Push Pipeline
steps:
- name: Prepare
image: planet:python3
volumes:
- name: pip_cache
path: /root/.cache/pip
- name: venv
path: /root/venv
commands:
- cd $DRONE_WORKSPACE_BASE
- mkdir logs
- virtualenv -p python3 /root/venv
# The following line fixes a weired pip bug by reinstalling newest pip in the venv
- wget https://bootstrap.pypa.io/get-pip.py && /root/venv/bin/python3 get-pip.py
- /root/venv/bin/pip install -U pip setuptools
- /root/venv/bin/pip install -r requirements.txt
- /root/venv/bin/python setup.py install
- /root/venv/bin/pip install flake8 pytest pytest-timeout pytest-xdist
- name: Lint check
image: planet:python3
volumes:
- name: pip_cache
path: /root/.cache/pip
- name: venv
path: /root/venv
commands:
- cd $DRONE_WORKSPACE_BASE
- /root/venv/bin/flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- /root/venv/bin/flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: test
image: planet:python3
volumes:
- name: pip_cache
path: /root/.cache/pip
- name: venv
path: /root/venv
commands:
- cd $DRONE_WORKSPACE_BASE
- . /root/venv/bin/activate
- pytest -n 4 --timeout 300 --verbose
- name: notify
image: planet:python3
volumes:
- name: pip_cache
path: /root/.cache/pip
- name: venv
path: /root/venv
commands:
- cd $DRONE_WORKSPACE_BASE
- export PYTHONPATH=$PWD
- git clone --depth=1 -b devel https://gitea.planet-ai.de/pai/cicd
- echo "The repository $DRONE_REPO_NAME/$DRONE_BRANCH has been changed and contains
errors." > message.txt
- echo "" >> message.txt
- echo "Failed stages:" $DRONE_FAILED_STAGES >> message.txt
- echo "Failed steps:" $DRONE_FAILED_STEPS >> message.txt
- echo "" >> message.txt
- echo "Please check the links for more information." >> message.txt
- echo "Errors and changes leading to failure:" >> message.txt
- echo " $CI_BUILD_LINK" >> message.txt
- echo " $DRONE_BUILD_LINK" >> message.txt
- echo "getting username of last committers"
- USERNAME=$(python3 cicd/noarch/getLastCommitter.py -repo $DRONE_REPO_NAME -auth_key
$GIT_AUTH_KEY)
- echo "found username - $USERNAME"
- cat message.txt
- if [ "$USERNAME" ] ; then
- python3 cicd/noarch/getContacts.py -a $ADMIN_EMAIL -r $DRONE_REPO_NAME -u $USERNAME
-o cicd/maintainer.lst -c cicd/contact.lst -f mailto > recipients.txt
- else
- python3 cicd/noarch/getContacts.py -a $ADMIN_EMAIL -r $DRONE_REPO_NAME -o cicd/maintainer.lst
-c cicd/contact.lst -f mailto > recipients.txt
- fi
- echo "Sending notification to:"
- cat recipients.txt
- python3 cicd/noarch/e_mail.py -u $EMAIL_USERNAME -p $EMAIL_PASSWORD -f $FROM -t
`cat recipients.txt` -s "DRONE:$DRONE_REPO/$DRONE_BRANCH changed" -m message.txt
environment:
SUBJECT: Changes/Errors:$DRONE_REPO
ADMIN_EMAIL:
from_secret: DRONE_ADMIN_EMAIL
FROM:
from_secret: DRONE_EMAIL
EMAIL_USERNAME:
from_secret: DRONE_EMAIL_USERNAME
EMAIL_PASSWORD:
from_secret: DRONE_EMAIL_PASSWORD
GIT_AUTH_KEY:
from_secret: DRONE_MACHINE_USER_GITEA_KEY
when:
status:
- failure
volumes:
- name: docker
host:
path: /var/run/docker.sock
- name: pip_cache
host:
path: /root/.cache/pip
- name: venv
temp: {}
trigger:
event:
- push
- pull_request
concurrency:
limit: 2