-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (139 loc) · 6.14 KB
/
test.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
name: Test bot
on: pull_request
# Detect if this action is already running, and cancel it.
# This most likely happened because a second push has been made to a branch.
concurrency:
group: ${{github.repository_id}}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Deploying the test bot using the Supabase CLI,
# and simulating a Zulip JSON POST call to the bot.
# Checking if the bots response is as expected.
jobs:
test:
runs-on: ubuntu-latest
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: supabase/setup-cli@v1
- name: Deploying the testbot to Supabase
run: |
$(supabase functions delete testbot --project-ref $SUPABASE_PROJECT_ID) || true
supabase functions deploy testbot --project-ref $SUPABASE_PROJECT_ID --no-verify-jwt --legacy-bundle
- name: Simulating user asking to be deleted.
run: |
RESPONSE=$(curl -X POST "https://$SUPABASE_PROJECT_ID.functions.supabase.co/testbot" \
-H "Content-Type: application/json" \
-d '
{
"bot_email": "outgoing-bot@localhost",
"bot_full_name": "Outgoing webhook test",
"data": "@**Outgoing webhook test** delete",
"message": {
"avatar_url": "https://secure.gravatar.com/avatar/1f4f1575bf002ae562fea8fc4b861b09?d=identicon&version=1",
"content": "@**Outgoing webhook test** delete",
"display_recipient": "Verona",
"id": 112,
"is_me_message": false,
"reactions": [],
"recipient_id": 20,
"sender_email": "iago@zulip.com",
"sender_full_name": "Iago",
"sender_id": 5,
"sender_realm_str": "zulip",
"stream_id": 5,
"subject": "Verona2",
"submessages": [],
"timestamp": 1527876931,
"topic_links": [],
"type": "stream"
},
"token": "xvOzfurIutdRRVLzpXrIIHXJvNfaJLJ0",
"trigger": "mention"
}
')
echo "$RESPONSE"
if [[ $RESPONSE == '{"content":"\nDin samtykke er blevet opdateret, og vil blive respekteret i fremtidige beskeder.\r\n\nDu kan altid fjerne samtykke ved at skrive \"delete\" til mig.\r\n\nDu kan se hvad jeg husker om dig ved at skrive \"history\" til mig."}' ]]; then
echo "Test passed"
else
echo "Test failed"
exit 1
fi
- name: Simulating that the user has been prompted for consent.
run: |
RESPONSE=$(curl -X POST "https://$SUPABASE_PROJECT_ID.functions.supabase.co/testbot" \
-H "Content-Type: application/json" \
-d '
{
"bot_email": "outgoing-bot@localhost",
"bot_full_name": "Outgoing webhook test",
"data": "@**Outgoing webhook test** hello",
"message": {
"content": "@**Outgoing webhook test** hello",
"sender_email": "iago@zulip.com",
"sender_full_name": "Iago",
"sender_id": 5,
"stream_id": 5
}
}
')
echo "$RESPONSE"
if [[ $RESPONSE == '{"content":"\n Hej! Før du kan bruge mig, skal du acceptere at jeg sender dit navn, email og besked ud af EU (til Supabase og OpenAI).\r\n\n Du *KAN* vælge at jeg også gemmer en historik over dine beskeder, så jeg kan forbedre min respons i fremtiden.\r\n\n Denne data gemmes i klartekst, og er synlig for min maintainer (Benji).\r\n\nGiv venligst samtykke: \r\n\n- `ok` for at acceptere \r\n\n- `tjoh` for at acceptere basal brug UDEN at slå chat-historik til"}' ]]; then
echo "Test passed"
else
echo "Test failed"
exit 1
fi
- name: Simulating a consent approval from the user.
run: |
RESPONSE=$(curl -X POST "https://$SUPABASE_PROJECT_ID.functions.supabase.co/testbot" \
-H "Content-Type: application/json" \
-d '
{
"bot_email": "outgoing-bot@localhost",
"bot_full_name": "Outgoing webhook test",
"data": "@**Outgoing webhook test** ok",
"message": {
"content": "@**Outgoing webhook test** ok",
"sender_email": "iago@zulip.com",
"sender_full_name": "Iago",
"sender_id": 5,
"stream_id": 5
}
}
')
echo "$RESPONSE"
if [[ $RESPONSE == '{"content":"\nDin samtykke er blevet opdateret, og vil blive respekteret i fremtidige beskeder.\r\n\nDu kan altid fjerne samtykke ved at skrive \"delete\" til mig.\r\n\nDu kan se hvad jeg husker om dig ved at skrive \"history\" til mig."}' ]]; then
echo "Test passed"
else
echo "Test failed"
exit 1
fi
- name: Simulating a user prompt, to get a response from OpenAI.
run: |
RESPONSE=$(curl -X POST "https://$SUPABASE_PROJECT_ID.functions.supabase.co/testbot" \
-H "Content-Type: application/json" \
-d '
{
"bot_email": "outgoing-bot@localhost",
"bot_full_name": "Outgoing webhook test",
"data": "@**Outgoing webhook test** say ok",
"message": {
"content": "@**Outgoing webhook test** say ok",
"sender_email": "iago@zulip.com",
"sender_full_name": "Iago",
"sender_id": 5,
"stream_id": 5
}
}
')
echo "$RESPONSE"
if [[ $RESPONSE == *'"content":"ok'* ]]; then
echo "Test passed"
else
echo "Test failed"
exit 1
fi