11name : Tests
22
33on :
4- push :
5- branches :
6- - main
7- pull_request :
8- branches :
9- - main
10- workflow_dispatch :
4+ workflow_call :
5+ inputs :
6+ os :
7+ description : " Runner OS (e.g., ubuntu-latest, macos-latest, windows-latest)"
8+ required : true
9+ type : string
10+ python-version :
11+ description : " Python version to test"
12+ required : true
13+ type : string
14+ artifact-name :
15+ description : " Name of the wheel artifact to download"
16+ required : true
17+ type : string
18+ run-id :
19+ description : " Workflow run ID to download artifacts from (optional, uses current run if not specified)"
20+ required : false
21+ type : string
22+ secrets :
23+ LIVEKIT_URL :
24+ required : true
25+ LIVEKIT_API_KEY :
26+ required : true
27+ LIVEKIT_API_SECRET :
28+ required : true
1129
1230jobs :
13- tests :
14- name : Run tests
15- runs-on : ubuntu-latest
31+ test :
32+ name : Test (${{ inputs.os }}, Python ${{ inputs.python-version }})
33+ runs-on : ${{ inputs.os }}
1634 steps :
17- - uses : actions/checkout@v6
35+ - uses : actions/checkout@v4
1836 with :
1937 submodules : true
2038 lfs : true
21- - name : Install uv
2239
40+ - uses : actions/setup-python@v4
41+ with :
42+ python-version : ${{ inputs.python-version }}
43+
44+ - name : Install uv
2345 uses : astral-sh/setup-uv@v5
2446 with :
2547 enable-cache : true
2648 cache-dependency-glob : " uv.lock"
2749
28- - name : Install the project
29- run : uv sync --all-extras --dev
50+ - name : Download livekit-rtc wheel (current run)
51+ if : ${{ inputs.run-id == '' }}
52+ uses : actions/download-artifact@v4
53+ with :
54+ name : ${{ inputs.artifact-name }}
55+ path : rtc-wheel
3056
31- - uses : actions/setup-python@v6
57+ - name : Download livekit-rtc wheel (from specific run)
58+ if : ${{ inputs.run-id != '' }}
59+ uses : actions/download-artifact@v4
3260 with :
33- python-version : ' 3.13'
61+ name : ${{ inputs.artifact-name }}
62+ path : rtc-wheel
63+ run-id : ${{ inputs.run-id }}
64+ github-token : ${{ github.token }}
65+
66+ - name : Select compatible wheel (macOS)
67+ if : runner.os == 'macOS'
68+ id : select-wheel-macos
69+ run : |
70+ # macOS artifacts contain both x86_64 and arm64 wheels, select the right one
71+ WHEEL=$(python3 -c "
72+ import glob
73+ import platform
74+ import sys
75+
76+ wheels = glob.glob('rtc-wheel/*.whl')
77+ machine = platform.machine().lower()
78+
79+ arch_map = {
80+ 'x86_64': ['x86_64'],
81+ 'arm64': ['arm64'],
82+ }
83+ patterns = arch_map.get(machine, [machine])
84+
85+ for wheel in wheels:
86+ wheel_lower = wheel.lower()
87+ if any(p in wheel_lower for p in patterns):
88+ print(wheel)
89+ sys.exit(0)
90+
91+ print(f'No matching wheel found for {machine}', file=sys.stderr)
92+ sys.exit(1)
93+ ")
94+ echo "wheel=$WHEEL" >> $GITHUB_OUTPUT
3495
35- - name : Run tests
96+ - name : Create venv and install dependencies (Unix)
97+ if : runner.os == 'Linux'
98+ run : |
99+ uv venv .test-venv
100+ source .test-venv/bin/activate
101+ uv pip install rtc-wheel/*.whl ./livekit-api ./livekit-protocol
102+ uv pip install pytest pytest-asyncio numpy matplotlib
103+
104+ - name : Create venv and install dependencies (macOS)
105+ if : runner.os == 'macOS'
106+ run : |
107+ uv venv .test-venv
108+ source .test-venv/bin/activate
109+ uv pip install "${{ steps.select-wheel-macos.outputs.wheel }}"
110+ uv pip install ./livekit-api ./livekit-protocol
111+ uv pip install pytest pytest-asyncio numpy matplotlib
112+
113+ - name : Create venv and install dependencies (Windows)
114+ if : runner.os == 'Windows'
115+ run : |
116+ uv venv .test-venv
117+ $wheel = (Get-ChildItem rtc-wheel\*.whl)[0].FullName
118+ uv pip install --python .test-venv $wheel .\livekit-api .\livekit-protocol
119+ uv pip install --python .test-venv pytest pytest-asyncio numpy matplotlib
120+ shell : pwsh
121+
122+ - name : Run tests (Unix)
123+ if : runner.os != 'Windows'
36124 env :
37125 LIVEKIT_URL : ${{ secrets.LIVEKIT_URL }}
38126 LIVEKIT_API_KEY : ${{ secrets.LIVEKIT_API_KEY }}
39127 LIVEKIT_API_SECRET : ${{ secrets.LIVEKIT_API_SECRET }}
40128 run : |
41-
42- uv run python ./livekit-rtc/rust-sdks/download_ffi.py --output livekit-rtc/livekit/rtc/resources
43- uv add ./livekit-rtc ./livekit-api ./livekit-protocol
44- uv run pytest . --ignore=livekit-rtc/rust-sdks
129+ source .test-venv/bin/activate
130+ pytest tests/
131+
132+ - name : Run tests (Windows)
133+ if : runner.os == 'Windows'
134+ env :
135+ LIVEKIT_URL : ${{ secrets.LIVEKIT_URL }}
136+ LIVEKIT_API_KEY : ${{ secrets.LIVEKIT_API_KEY }}
137+ LIVEKIT_API_SECRET : ${{ secrets.LIVEKIT_API_SECRET }}
138+ run : .test-venv\Scripts\python.exe -m pytest tests/
139+ shell : pwsh
45140
0 commit comments