-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:bots-garden/capsule
fighting with go.work.sum
- Loading branch information
Showing
29 changed files
with
198 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
CapsCtl v0.4.0 🌶️ [chili pepper] | ||
CapsCtl v0.4.1 🫑 [pepper] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[CLI] v0.4.0 🌶️ [chili pepper] | ||
[CLI] v0.4.1 🫑 [pepper] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
Summary: | ||
Total: 0.0696 secs | ||
Slowest: 0.0432 secs | ||
Fastest: 0.0006 secs | ||
Average: 0.0170 secs | ||
Requests/sec: 4312.2929 | ||
|
||
Total data: 15900 bytes | ||
Size/request: 53 bytes | ||
|
||
Response time histogram: | ||
0.001 [1] | | ||
0.005 [16] |■■■■■■■ | ||
0.009 [94] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ | ||
0.013 [56] |■■■■■■■■■■■■■■■■■■■■■■■■ | ||
0.018 [16] |■■■■■■■ | ||
0.022 [16] |■■■■■■■ | ||
0.026 [25] |■■■■■■■■■■■ | ||
0.030 [33] |■■■■■■■■■■■■■■ | ||
0.035 [11] |■■■■■ | ||
0.039 [19] |■■■■■■■■ | ||
0.043 [13] |■■■■■■ | ||
|
||
|
||
Latency distribution: | ||
10% in 0.0075 secs | ||
25% in 0.0086 secs | ||
50% in 0.0112 secs | ||
75% in 0.0264 secs | ||
90% in 0.0352 secs | ||
95% in 0.0378 secs | ||
99% in 0.0427 secs | ||
|
||
Details (average, fastest, slowest): | ||
DNS+dialup: 0.0001 secs, 0.0006 secs, 0.0432 secs | ||
DNS-lookup: 0.0047 secs, 0.0000 secs, 0.0221 secs | ||
req write: 0.0013 secs, 0.0000 secs, 0.0171 secs | ||
resp wait: 0.0081 secs, 0.0002 secs, 0.0225 secs | ||
resp read: 0.0011 secs, 0.0000 secs, 0.0243 secs | ||
|
||
Status code distribution: | ||
[200] 300 responses | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,78 @@ | ||
# Use the GitLab WebHook sample | ||
|
||
This sample is a [webhook for a GitLab project](https://docs.gitlab.com/ee/user/project/integrations/webhooks.html) created with Capsule HTTP. For my tests, I use [Ngrok](https://ngrok.com/), so, I can host locally the webhook. | ||
|
||
This webhook is listening for the [issue events](https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#issue-events) and [notes events](https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#comment-events) of GitLab, and post an answer when it is triggered. | ||
|
||
## Compile the webhook | ||
|
||
```bash | ||
tinygo build -o glwebhook.wasm \ | ||
-scheduler=none \ | ||
--no-debug \ | ||
-target wasi ./main.go | ||
``` | ||
|
||
## Start the webhook | ||
|
||
To start this webhook, you need: | ||
|
||
- The latest version of Capsule HTTP | ||
- A Ngrok account (with a [AuthToken](https://dashboard.ngrok.com/get-started/your-authtoken)) | ||
- A GitLab account (with a [personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html)) | ||
- A GitLab project (the GitLab account need to be a member of this project) | ||
|
||
If you use a **Ngrok domain** (with a paid account: it means that you can provide a fixed url), start the webhook like this: | ||
|
||
```bash | ||
WEBHOOK_TOKEN="ilovepanda" \ | ||
GITLAB_API_URL="https://gitlab.com/api/v4" \ | ||
GITLAB_BOT_TOKEN="your-personal-access-token" \ | ||
GITLAB_BOT_NAME="the-gitlab-handle-of-the-user" \ | ||
NGROK_DOMAIN="your-ngrok-domain for example: capsule.ngrok.dev" \ | ||
NGROK_AUTHTOKEN="your-ngrok-auth-token" \ | ||
./capsule-http \ | ||
--wasm=./glwebhook.wasm --httpPort=8090 | ||
``` | ||
|
||
If you use the free plan of **Ngrok** (but you will need to change the url of the webhook at every tests), start the webhook like this (without the `NGROK_DOMAIN`): | ||
|
||
```bash | ||
WEBHOOK_TOKEN="ilovepanda" \ | ||
GITLAB_API_URL="https://gitlab.com/api/v4" \ | ||
GITLAB_BOT_TOKEN="your-personal-access-token" \ | ||
GITLAB_BOT_NAME="the-gitlab-handle-of-the-user" \ | ||
NGROK_AUTHTOKEN="your-ngrok-auth-token" \ | ||
./capsule-http \ | ||
--wasm=./glwebhook.wasm --httpPort=8090 | ||
``` | ||
|
||
> **Remarks**: | ||
> - For the both cases, Capsule HTTP will generate a file (`ngrok.url`), so you can easyly retrieve the URL of the ngrok endpoint. | ||
> - You need `WEBHOOK_TOKEN` only if you provided a **Secret token** when you created the webhook, then you will be able to check the token from the header of the query. | ||
## Create the webhook | ||
|
||
In your GitLab project, go to **Settings/Webhooks** and create a webhook with the relevant data: | ||
|
||
![alt settings](webhook-settings.png "Webhook Settings") | ||
|
||
## Use the webhook | ||
|
||
### Create an issue | ||
|
||
Got to your project and create an issue and notify your bot with its handle into the body of the issue: | ||
|
||
![alt create](create-issue.png "Create Issue") | ||
|
||
Then you can read the answer from the bot: | ||
|
||
![alt answer](issue-bot-answer.png "Bot Answer") | ||
|
||
### Add a comment to the issue | ||
|
||
Add a comment to the issue and notify your bot with its handle into the body of the comment: | ||
|
||
![alt answer](comment-bot-answer.png "Bot Answer") | ||
|
||
> **Don't be surprised**: The delay of the comment answer is longer than the one of the issue creation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[HTTP] v0.4.0 🌶️ [chili pepper] | ||
[HTTP] v0.4.1 🫑 [pepper] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.