Skip to content

Commit 826ed39

Browse files
Add webhook tunnel
1 parent 391e7bf commit 826ed39

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ jobs:
3030
- name: Install project dependencies
3131
run: uv sync --locked --all-extras --dev --all-packages
3232

33+
- name: Start localtunnel
34+
run: npx localtunnel --port 5000 > tunnel.log 2>&1 &
35+
3336
- name: Format
3437
run: uv run format_check
3538

@@ -40,8 +43,12 @@ jobs:
4043
run: uv run pyright
4144

4245
- name: Run tests
43-
run: uv run pytest
46+
run: |
47+
WEBHOOK_SERVER_URL="$(grep -o 'https://[^ ]*' tunnel.log | head -n 1)"
48+
if [ -z "$WEBHOOK_SERVER_URL" ]; then
49+
echo "Failed to setup localtunnel!"
50+
fi
51+
uv run pytest
4452
env:
4553
FISHJAM_ID: ${{ secrets.CI_FISHJAM_ID }}
4654
FISHJAM_MANAGEMENT_TOKEN: ${{ secrets.CI_FISHJAM_MANAGEMENT_TOKEN }}
47-

tests/support/env.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
FISHJAM_ID = os.environ["FISHJAM_ID"]
44
FISHJAM_MANAGEMENT_TOKEN = os.environ["FISHJAM_MANAGEMENT_TOKEN"]
5+
WEBHOOK_SERVER_URL = os.getenv("WEBHOOK_SERVER_URL", "http://localhost:5000/")
6+
WEBHOOK_URL = f"{WEBHOOK_SERVER_URL}webhook"

tests/support/webhook_notifier.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,3 @@ def run_server(queue):
2626
global DATA_QUEUE
2727
DATA_QUEUE = queue
2828
app.run(port=5000, host="0.0.0.0", use_reloader=False, debug=False, threaded=True)
29-
30-
31-
WEBHOOK_SERVER_URL = "http://localhost:5000/"
32-
WEBHOOK_URL = f"{WEBHOOK_SERVER_URL}webhook"

tests/test_notifier.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@
1919
ServerMessageRoomDeleted,
2020
)
2121
from tests.support.asyncio_utils import assert_events, cancel
22-
from tests.support.env import FISHJAM_ID, FISHJAM_MANAGEMENT_TOKEN
22+
from tests.support.env import (
23+
FISHJAM_ID,
24+
FISHJAM_MANAGEMENT_TOKEN,
25+
WEBHOOK_SERVER_URL,
26+
WEBHOOK_URL,
27+
)
2328
from tests.support.peer_socket import PeerSocket
24-
from tests.support.webhook_notifier import WEBHOOK_SERVER_URL, WEBHOOK_URL, run_server
29+
from tests.support.webhook_notifier import run_server
2530

2631
queue = Queue()
2732

0 commit comments

Comments
 (0)