-
Notifications
You must be signed in to change notification settings - Fork 10
136 lines (114 loc) · 4.79 KB
/
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
name: CI
on:
push:
branches: [ "ci" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 ampalibe --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Install ampalibe locally without container
run: |
pip install -r requirements.txt
python setup.py install --force --user
- name: Unit test for ampalibe CLI
run: |
bash tests/test_cli.sh
- name: Unit test for messenger api
run: SENDER_ID=${{secrets.USER_ID}} AMP_ACCESS_TOKEN=${{secrets.ACCESS_TOKEN}} pytest
- name: Build the Docker image
run: bash tests/deploy.sh
- name: Test du serveur web
run: |
sudo lsof -i:4555
if [ $? -eq 0 ]; then
echo "Server Web Running"
else
echo "Server Web Not Runing"
docker logs amp
exit 1
fi
- name: Envoie du Challenge Webhook
run: |
response=$(curl -X GET "http://127.0.0.1:4555/?hub.verify_token=AMPALIBE&hub.challenge=CHALLENGE_ACCEPTED&hub.mode=subscribe")
if [ $response = "CHALLENGE_ACCEPTED" ]; then
echo "OK! : $response"
else
echo KO
exit 1
fi
- name: "Test du reception de l'evenement text"
run: |
response=$(curl -H "Content-Type: application/json" -X POST "http://127.0.0.1:4555/?testmode=1" -d '{"object": "page", "entry": [{"messaging": [ {"sender": {"id": "test_user"}, "message": {"text":"TEST_MESSAGE"} }]}]}')
if [ "$response" = '"Hello Ampalibe"' ]; then
echo "Message: OK"
else
echo KO
exit 1
fi
- name: "Test du reception de l'evenement postback"
run: |
response=$(curl -H "Content-Type: application/json" -X POST "http://127.0.0.1:4555/?testmode=1" -d '{"object": "page", "entry": [{"messaging": [ {"sender": {"id": "test_user"}, "postback": {"title": "TITLE-FOR-THE-CTA", "payload": "USER-DEFINED-PAYLOAD"} }]}]}')
if [ "$response" = '"Hello Ampalibe"' ]; then
echo "Postback: OK"
else
echo KO!
exit 1
fi
- name: "Test du reception de l'evenement read"
run: |
response=$(curl -H "Content-Type: application/json" -X POST "http://127.0.0.1:4555/?testmode=1" -d '{"object": "page", "entry": [{"messaging": [ {"sender": {"id": "test_user"}, "read":{"watermark":1458668856253} }]}]}')
if [ "$response" = '{"status":"ok"}' ]; then
echo "Read: OK"
else
echo KO!
exit 1
fi
- name: "Test du reception de l'evenement delivery"
run: |
response=$(curl -H "Content-Type: application/json" -X POST "http://127.0.0.1:4555/?testmode=1" -d '{"object": "page", "entry": [{"messaging": [ {"sender": {"id": "test_user"}, "delivery":{"watermark":1458668856253} }]}]}')
if [ "$response" = '{"status":"ok"}' ]; then
echo "Delivré: OK"
else
echo KO!
exit 1
fi
- name: "Test du reception de l'evenement reaction"
run: |
response=$(curl -H "Content-Type: application/json" -X POST "http://127.0.0.1:4555/?testmode=1" -d '{"object": "page", "entry": [{"messaging": [ {"sender": {"id": "test_user"}, "reaction":{"reaction": "love", "action": "react"} }]}]}')
if [ "$response" = '{"status":"ok"}' ]; then
echo "REACTION: OK"
else
echo KO!
exit 1
fi
- name: "Test du reception d'un attachment"
run: |
response=$(curl -H "Content-Type: application/json" -X POST "http://127.0.0.1:4555/?testmode=1" -d '{"object": "page", "entry": [{"messaging": [ {"sender": {"id": "test_user"}, "message": {"attachments":[{"payload":{"url": "https://i.imgflip.com/6b45bi.jpg"}}]} }]}]}')
if [ "$response" = '"Hello Ampalibe"' ]; then
echo "Message: OK"
else
echo KO
exit 1
fi
- name: "Test du reception de l'evenement optin avec type one_time_notif_req"
run: |
response=$(curl -H "Content-Type: application/json" -X POST "http://127.0.0.1:4555/?testmode=1" -d '{"object": "page", "entry": [{"messaging": [ {"sender": {"id": "test_user"}, "optin":{"payload": "/receive_optin_webhook", "type": "one_time_notif_req", "one_time_notif_token": "EXAMPLE_DE_TOKEN"} }]}]}')
if [ "$response" = '"Optin"' ]; then
echo "Optin one_notif: OK"
else
echo KO!
exit 1
fi
- name: "Run functionnal test"
run: bash tests/test.sh