@@ -3,56 +3,82 @@ name: CI
33on : [push]
44
55jobs :
6- static-checks :
6+ lint-and-format :
77 runs-on : ubuntu-latest
8- strategy : &python-matrix
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
21- with :
22- python-version : ${{ matrix.python-version }}
23-
24- - name : Install uv
25- uses : astral-sh/setup-uv@v6
9+ - uses : actions/checkout@v4
10+ - uses : astral-sh/setup-uv@v6
2611 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
15+ run : uv sync --locked --all-extras --all-packages
3216
33- - name : Format
17+ - name : Format Check
3418 run : uv run format_check
3519
3620 - name : Lint
3721 run : uv run lint
3822
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 --all-packages
37+
3938 - name : Type check
4039 run : uv run pyright
4140
4241 test :
4342 runs-on : ubuntu-latest
44- strategy : *python-matrix
45- env :
46- PYTHON_VERSION : ${{ matrix.python-version }}
47- name : test
43+ needs : [lint-and-format]
44+ strategy : *strategy
4845 steps :
4946 - uses : actions/checkout@v4
47+ - uses : astral-sh/setup-uv@v6
48+ with :
49+ python-version : ${{ matrix.python-version }}
50+ enable-cache : true
5051
51- - name : Log in to GitHub Container Registry
52- run : echo "${{ secrets.PACKAGE_ACCESS_TOKEN }}" | docker login ghcr.io -u USERNAME --password-stdin
52+ - name : Install project dependencies
53+ run : uv sync --locked --all-extras --all-packages
5354
54- - name : Run tests
55- run : docker compose -f docker-compose-test.yaml up test --exit-code-from test
55+ - name : Initialize Localtunnel
56+ id : tunnel
57+ run : |
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"
5678
57- - name : Tear down test containers
58- run : docker compose -f docker-compose-test.yaml down
79+ - name : Run tests
80+ run : uv run pytest
81+ env :
82+ WEBHOOK_SERVER_URL : ${{ steps.tunnel.outputs.url }}
83+ FISHJAM_ID : ${{ secrets.CI_FISHJAM_ID }}
84+ FISHJAM_MANAGEMENT_TOKEN : ${{ secrets.CI_FISHJAM_MANAGEMENT_TOKEN }}
0 commit comments