mirror of https://github.com/commaai/teleoprtc.git
Add pre-commit and CI
This commit is contained in:
parent
4db967e4e2
commit
0df2915477
|
@ -0,0 +1,33 @@
|
||||||
|
name: tests
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: '3.11'
|
||||||
|
- name: Install aiortc dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install libavdevice-dev libavfilter-dev libopus-dev libvpx-dev libsrtp2-dev pkg-config
|
||||||
|
- name: Install package
|
||||||
|
run: pip install -e .[dev]
|
||||||
|
- name: Unit Tests
|
||||||
|
run: |
|
||||||
|
cd tests/; python -m unittest discover
|
||||||
|
static_analysis:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: '3.11'
|
||||||
|
- name: Install pre-commit
|
||||||
|
run: pip install pre-commit
|
||||||
|
- name: Static analysis
|
||||||
|
run: |
|
||||||
|
pre-commit run --all
|
|
@ -0,0 +1,20 @@
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.5.0
|
||||||
|
hooks:
|
||||||
|
- id: check-ast
|
||||||
|
- id: check-json
|
||||||
|
- id: check-xml
|
||||||
|
- id: check-yaml
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- id: check-symlinks
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
|
- id: check-shebang-scripts-are-executable
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
|
rev: v1.7.1
|
||||||
|
hooks:
|
||||||
|
- id: mypy
|
||||||
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
|
rev: v0.1.6
|
||||||
|
hooks:
|
||||||
|
- id: ruff
|
|
@ -71,11 +71,9 @@ async def run_offer(args):
|
||||||
print("Connection established and all tracks are ready")
|
print("Connection established and all tracks are ready")
|
||||||
|
|
||||||
video_tracks = [stream.get_incoming_video_track(cam, False) for cam in args.cameras]
|
video_tracks = [stream.get_incoming_video_track(cam, False) for cam in args.cameras]
|
||||||
audio_track, channel = None, None
|
audio_track = None
|
||||||
if stream.has_incoming_audio_track():
|
if stream.has_incoming_audio_track():
|
||||||
audio_track = stream.get_incoming_audio_track(False)
|
audio_track = stream.get_incoming_audio_track(False)
|
||||||
if stream.has_messaging_channel():
|
|
||||||
channel = stream.get_messaging_channel()
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
frames = await asyncio.gather(*[track.recv() for track in video_tracks])
|
frames = await asyncio.gather(*[track.recv() for track in video_tracks])
|
||||||
|
|
|
@ -24,7 +24,8 @@ dependencies = [
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
dev = [
|
dev = [
|
||||||
"parameterized>=0.8"
|
"parameterized>=0.8",
|
||||||
|
"pre-commit"
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import aiortc
|
|
||||||
from aiortc.mediastreams import AudioStreamTrack, VideoStreamTrack
|
from aiortc.mediastreams import AudioStreamTrack, VideoStreamTrack
|
||||||
from parameterized import parameterized
|
from parameterized import parameterized
|
||||||
|
|
||||||
|
@ -54,13 +53,13 @@ class TestStreamIntegration(unittest.IsolatedAsyncioTestCase):
|
||||||
offer_builder.add_messaging()
|
offer_builder.add_messaging()
|
||||||
stream = offer_builder.stream()
|
stream = offer_builder.stream()
|
||||||
|
|
||||||
offer = await stream.start()
|
_ = await stream.start()
|
||||||
self.assertTrue(stream.is_started)
|
self.assertTrue(stream.is_started)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with asyncio.timeout(2):
|
async with asyncio.timeout(2):
|
||||||
await stream.wait_for_connection()
|
await stream.wait_for_connection()
|
||||||
except asyncio.TimeoutError as e:
|
except asyncio.TimeoutError:
|
||||||
self.fail("Timed out waiting for connection")
|
self.fail("Timed out waiting for connection")
|
||||||
self.assertTrue(stream.is_connected_and_ready)
|
self.assertTrue(stream.is_connected_and_ready)
|
||||||
|
|
||||||
|
@ -80,7 +79,7 @@ class TestStreamIntegration(unittest.IsolatedAsyncioTestCase):
|
||||||
try:
|
try:
|
||||||
async with asyncio.timeout(1):
|
async with asyncio.timeout(1):
|
||||||
await track.recv()
|
await track.recv()
|
||||||
except asyncio.TimeoutError as e:
|
except asyncio.TimeoutError:
|
||||||
self.fail("Timed out waiting for audio frame")
|
self.fail("Timed out waiting for audio frame")
|
||||||
|
|
||||||
for cam in cameras:
|
for cam in cameras:
|
||||||
|
@ -94,7 +93,7 @@ class TestStreamIntegration(unittest.IsolatedAsyncioTestCase):
|
||||||
try:
|
try:
|
||||||
async with asyncio.timeout(1):
|
async with asyncio.timeout(1):
|
||||||
await stream.get_incoming_video_track(cam, False).recv()
|
await stream.get_incoming_video_track(cam, False).recv()
|
||||||
except asyncio.TimeoutError as e:
|
except asyncio.TimeoutError:
|
||||||
self.fail("Timed out waiting for video frame")
|
self.fail("Timed out waiting for video frame")
|
||||||
|
|
||||||
await stream.stop()
|
await stream.stop()
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import aiortc
|
import aiortc
|
||||||
from aiortc.mediastreams import AudioStreamTrack, VideoStreamTrack
|
from aiortc.mediastreams import AudioStreamTrack
|
||||||
from parameterized import parameterized
|
|
||||||
|
|
||||||
from teleoprtc.builder import WebRTCOfferBuilder, WebRTCAnswerBuilder
|
from teleoprtc.builder import WebRTCOfferBuilder, WebRTCAnswerBuilder
|
||||||
from teleoprtc.stream import StreamingOffer
|
|
||||||
from teleoprtc.info import parse_info_from_offer
|
from teleoprtc.info import parse_info_from_offer
|
||||||
from teleoprtc.tracks import TiciVideoStreamTrack
|
from teleoprtc.tracks import TiciVideoStreamTrack
|
||||||
|
|
||||||
|
@ -40,7 +38,7 @@ class TestOfferStream(unittest.IsolatedAsyncioTestCase):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_ = await stream.start()
|
_ = await stream.start()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
info = parse_info_from_offer(capture.offer.sdp)
|
info = parse_info_from_offer(capture.offer.sdp)
|
||||||
|
@ -55,7 +53,7 @@ class TestOfferStream(unittest.IsolatedAsyncioTestCase):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_ = await stream.start()
|
_ = await stream.start()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
info = parse_info_from_offer(capture.offer.sdp)
|
info = parse_info_from_offer(capture.offer.sdp)
|
||||||
|
@ -70,7 +68,7 @@ class TestOfferStream(unittest.IsolatedAsyncioTestCase):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_ = await stream.start()
|
_ = await stream.start()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
info = parse_info_from_offer(capture.offer.sdp)
|
info = parse_info_from_offer(capture.offer.sdp)
|
||||||
|
|
Loading…
Reference in New Issue