@@ -3,55 +3,82 @@ name: CI
33on : [push]
44
55jobs :
6- static-checks :
6+ lint-and-format :
77 runs-on : ubuntu-latest
8- strategy :
9- matrix :
10- python-version :
11- - " 3.11"
12- - " 3.12"
13- - " 3.13"
14- name : static-checks
158 steps :
16- - name : Checkout code
17- uses : actions/checkout@v4
18-
19- - name : Set up Python
20- uses : actions/setup-python@v5
9+ - uses : actions/checkout@v4
10+ - uses : astral-sh/setup-uv@v6
2111 with :
22- python-version : ${{ matrix.python-version }}
23-
24- - name : Install uv
25- uses : astral-sh/setup-uv@v6
26- with :
27- python-version : ${{ matrix.python-version }}
2812 enable-cache : true
2913
3014 - name : Install project dependencies
31- run : uv sync --locked --all-extras --dev --all-packages
32-
33- - name : Start localtunnel
34- run : npx localtunnel --port 5000 2>&1 | tee tunnel.log &
15+ run : uv sync --locked --all-extras --dev
3516
36- - name : Format
17+ - name : Format Check
3718 run : uv run format_check
3819
3920 - name : Lint
4021 run : uv run lint
4122
23+ type-check :
24+ runs-on : ubuntu-latest
25+ strategy : &strategy
26+ matrix :
27+ python-version : ["3.11", "3.12", "3.13"]
28+ steps :
29+ - uses : actions/checkout@v4
30+ - uses : astral-sh/setup-uv@v5
31+ with :
32+ python-version : ${{ matrix.python-version }}
33+ enable-cache : true
34+
35+ - name : Install project dependencies
36+ run : uv sync --locked --all-extras --dev
37+
4238 - name : Type check
4339 run : uv run pyright
44-
45- - name : Run tests
40+
41+ test :
42+ runs-on : ubuntu-latest
43+ needs : [lint-and-format]
44+ strategy : *strategy
45+ steps :
46+ - uses : actions/checkout@v4
47+ - uses : astral-sh/setup-uv@v6
48+ with :
49+ python-version : ${{ matrix.python-version }}
50+ enable-cache : true
51+
52+ - name : Install project dependencies
53+ run : uv sync --locked --all-extras --dev
54+
55+ - name : Initialize Localtunnel
56+ id : tunnel
4657 run : |
47- PUBLIC_URL="$(grep -o 'https://[^ ]*' tunnel.log | head -n 1)"
48- if [ -z "$PUBLIC_URL" ]; then
49- echo "Failed to setup localtunnel!"
50- cat tunnel.log
51- exit 1
52- fi
53- echo "Webhook URL: $PUBLIC_URL"
54- WEBHOOK_SERVER_URL="$PUBLIC_URL" uv run pytest
58+ npx localtunnel --port 5000 > tunnel.log 2>&1 &
59+
60+ # Poll for the URL
61+ TIMEOUT=10
62+ ELAPSED=0
63+ echo "Waiting for localtunnel to generate URL..."
64+
65+ while ! grep -q "https://" tunnel.log; do
66+ if [ $ELAPSED -ge $TIMEOUT ]; then
67+ echo "Error: Localtunnel timed out after ${TIMEOUT}s"
68+ cat tunnel.log
69+ exit 1
70+ fi
71+ sleep 1
72+ ELAPSED=$((ELAPSED + 1))
73+ done
74+
75+ TUNNEL_URL=$(grep -o 'https://[^ ]*' tunnel.log | head -n 1)
76+ echo "url=$TUNNEL_URL" >> $GITHUB_OUTPUT
77+ echo "Localtunnel is live at: $TUNNEL_URL"
78+
79+ - name : Run tests
80+ run : uv run pytest
5581 env :
82+ WEBHOOK_SERVER_URL : ${{ steps.tunnel.outputs.url }}
5683 FISHJAM_ID : ${{ secrets.CI_FISHJAM_ID }}
5784 FISHJAM_MANAGEMENT_TOKEN : ${{ secrets.CI_FISHJAM_MANAGEMENT_TOKEN }}
0 commit comments