-
Notifications
You must be signed in to change notification settings - Fork 113
141 lines (124 loc) · 4.36 KB
/
tests.yml
File metadata and controls
141 lines (124 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Tests
on:
workflow_call:
inputs:
os:
description: "Runner OS (e.g., ubuntu-latest, macos-latest, windows-latest)"
required: true
type: string
python-version:
description: "Python version to test"
required: true
type: string
artifact-name:
description: "Name of the wheel artifact to download"
required: true
type: string
run-id:
description: "Workflow run ID to download artifacts from (optional, uses current run if not specified)"
required: false
type: string
secrets:
LIVEKIT_URL:
required: true
LIVEKIT_API_KEY:
required: true
LIVEKIT_API_SECRET:
required: true
jobs:
test:
name: Test (${{ inputs.os }}, Python ${{ inputs.python-version }})
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
lfs: true
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
allow-prereleases: true
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Download livekit-rtc wheel (current run)
if: ${{ inputs.run-id == '' }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: rtc-wheel
- name: Download livekit-rtc wheel (from specific run)
if: ${{ inputs.run-id != '' }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: rtc-wheel
run-id: ${{ inputs.run-id }}
github-token: ${{ github.token }}
- name: Select compatible wheel (macOS)
if: runner.os == 'macOS'
id: select-wheel-macos
run: |
# macOS artifacts contain both x86_64 and arm64 wheels, select the right one
WHEEL=$(python3 -c "
import glob
import platform
import sys
wheels = glob.glob('rtc-wheel/*.whl')
machine = platform.machine().lower()
arch_map = {
'x86_64': ['x86_64'],
'arm64': ['arm64'],
}
patterns = arch_map.get(machine, [machine])
for wheel in wheels:
wheel_lower = wheel.lower()
if any(p in wheel_lower for p in patterns):
print(wheel)
sys.exit(0)
print(f'No matching wheel found for {machine}', file=sys.stderr)
sys.exit(1)
")
echo "wheel=$WHEEL" >> $GITHUB_OUTPUT
- name: Create venv and install dependencies (Unix)
if: runner.os == 'Linux'
run: |
uv venv .test-venv
source .test-venv/bin/activate
uv pip install rtc-wheel/*.whl ./livekit-api ./livekit-protocol
uv pip install pytest pytest-asyncio numpy matplotlib
- name: Create venv and install dependencies (macOS)
if: runner.os == 'macOS'
run: |
uv venv .test-venv
source .test-venv/bin/activate
uv pip install "${{ steps.select-wheel-macos.outputs.wheel }}"
uv pip install ./livekit-api ./livekit-protocol
uv pip install pytest pytest-asyncio numpy matplotlib
- name: Create venv and install dependencies (Windows)
if: runner.os == 'Windows'
run: |
uv venv .test-venv
$wheel = (Get-ChildItem rtc-wheel\*.whl)[0].FullName
uv pip install --python .test-venv $wheel .\livekit-api .\livekit-protocol
uv pip install --python .test-venv pytest pytest-asyncio numpy matplotlib
shell: pwsh
- name: Run tests (Unix)
if: runner.os != 'Windows'
env:
LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }}
LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}
run: |
source .test-venv/bin/activate
pytest tests/
- name: Run tests (Windows)
if: runner.os == 'Windows'
env:
LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }}
LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}
run: .test-venv\Scripts\python.exe -m pytest tests/
shell: pwsh