Skip to content
Draft

wip #263

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
run: |
docker compose up -d
sleep 10
STATUS_CODE=$(curl -o /dev/null -s -w "%{http_code}" http://localhost:8080)
STATUS_CODE=$(curl -o /dev/null -s -w "%{http_code}" http://localhost:9601)
if [ "$STATUS_CODE" -ne 200 ]; then
echo "API failed with status code $STATUS_CODE"
exit 1
Expand Down
72 changes: 47 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Test

permissions:
contents: read

on:
pull_request:
paths-ignore:
Expand All @@ -13,59 +16,78 @@ on:
- '**/*.gif'

jobs:
unit-tests:
tests-unit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: run tests
run: make test-coverage

- name: upload coverage reselt to Codecov
- name: runs tests
run: |
make test-unit FLAGS=-coverprofile=coverage.txt
cat coverage.txt
- name: uploads coverage reselt
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
flags: unit

services:
httpbin:
image: kennethreitz/httpbin
ports:
- 9999:80

integration-tests:
tests-integration-main:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: start dependencies
- name: starts dependencies
run: |
mkdir -p test/output/otel
sudo chmod 777 -R test/output/otel
make test-deps
sleep 3
docker compose -f test/docker-compose.yml logs

- name: install
- name: installs webhookx
run: make install

- name: installs ginkgo
run: go install github.com/onsi/ginkgo/v2/ginkgo
- name: run tests
run: make test-integration-coverage

- name: upload coverage reselt to Codecov
run: |
make test-main FLAGS="-coverpkg=github.com/webhookx-io/webhookx/... --cover --coverprofile=coverage.txt"
cat coverage.txt
- name: upload coverage reselt
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
flags: integration

tests-integration-o11:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: starts dependencies
run: |
mkdir -p test/output/otel
sudo chmod 777 -R test/output/otel
make test-deps
sleep 3
docker compose -f test/docker-compose.yml logs
- name: installs webhookx
run: make install
- name: install ginkgo
run: go install github.com/onsi/ginkgo/v2/ginkgo
- name: run tests
run: |
make test-o11 FLAGS="-coverpkg=github.com/webhookx-io/webhookx/... --cover --coverprofile=coverage.txt"
cat coverage.txt
- name: upload coverage reselt
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
flags: integration-o11
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ FROM alpine:3.15

COPY --from=build-env /go/src/webhookx-io/webhookx/webhookx /usr/local/bin

EXPOSE 8080
EXPOSE 9600


CMD ["webhookx", "start"]
15 changes: 6 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ test-deps:
mkdir -p test/output/otel
docker compose -f test/docker-compose.yml up -d

test: clean
go test $$(go list ./... | grep -v /test/ | grep -v /examples/ )
test-unit: clean
go test $$(go list ./... | grep -v /test/ | grep -v /examples/ ) $(FLAGS)

test-coverage: clean
go test $$(go list ./... | grep -v /test/ | grep -v /examples/ ) -coverprofile=coverage.txt
test-o11: clean
ginkgo -r $(FLAGS) ./test/metrics ./test/tracing

test-integration: clean
go test -p 1 -v ./test/...

test-integration-coverage: clean
go test -p 1 -v ./test/... --coverpkg ./... -coverprofile=coverage.txt
test-main: clean
ginkgo -r --skip-package=metrics,tracing $(FLAGS) ./test

goreleaser:
goreleaser release --snapshot --clean
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ WebhookX is an open-source webhooks gateway for message receiving, processing, a

## Features

- **Admin API:** Expose a RESTful API on port `:8080` for managing WebhookX entities.
- **Admin API:** Expose a RESTful API on port `:9601` for managing WebhookX entities.
- **Retries:** Automatically retry unsuccessful deliveries with configurable delays.
- **Fan out:** Route events to multiple endpoints based on the event type.
- **Rate Limiting:** Protect the gateway ingestion and delivery endpoints from overload.
Expand Down Expand Up @@ -67,7 +67,7 @@ curl -O https://raw.githubusercontent.com/webhookx-io/webhookx/main/docker-compo
Once it's running, you will see HTTP 200 response

```
curl http://localhost:8080
curl http://localhost:9601
```

```http
Expand Down Expand Up @@ -102,10 +102,10 @@ Once it is set up, you're ready to send events to WebhookX.

### 3. Send events to WebhookX

> The Ingestion is exposed on port `:8081`
> The Ingestion is exposed on port `:9600`

```
curl -X POST http://localhost:8081 \
curl -X POST http://localhost:9600 \
--header 'Content-Type: application/json' \
--data '{
"event_type": "charge.succeeded",
Expand All @@ -125,12 +125,12 @@ We sent a `charge.succeeded` event including `data` to WebhookX, and it will be
>
> Attempt object represents the delivery result of an event, and contains inspection information.

> The Admin is exposed on port `:8080`
> The Admin is exposed on port `:9601`

Let's make a request to retrieve the attempt list

```
curl http://localhost:8080/workspaces/default/attempts
curl http://localhost:9601/workspaces/default/attempts
```

<details>
Expand Down Expand Up @@ -174,7 +174,7 @@ curl http://localhost:8080/workspaces/default/attempts
To inspect the data such as `request.headers`, `request.body`, `response.headers`, and `response.body`, try

```
http://localhost:8080/workspaces/default/attempts/338lax8Xe774EhimzBukip37Zne
http://localhost:9601/workspaces/default/attempts/338lax8Xe774EhimzBukip37Zne
```

<details>
Expand Down Expand Up @@ -243,8 +243,8 @@ Usage:
Available Commands:
admin Admin commands
completion Generate the autocompletion script for the specified shell
db Database commands
help Help about any command
migrations
start Start server
version Print the version

Expand Down
7 changes: 3 additions & 4 deletions cmd/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ func newDatabaseResetCmd() *cobra.Command {
func newDatabaseCmd() *cobra.Command {

database := &cobra.Command{
Use: "db",
Aliases: []string{"migrations"},
Short: "Database commands",
Long: ``,
Use: "db",
Short: "Database commands",
Long: ``,
}

database.PersistentFlags().StringVarP(&configurationFile, "config", "", "", "The configuration filename")
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

const (
defaultAdminURL = "http://localhost:8080"
defaultAdminURL = "http://localhost:9601"
)

var (
Expand Down
Loading