diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 34e613aa6e..131863e972 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -44,3 +44,27 @@ jobs: - name: Test run: npm run test working-directory: ./web + + docker_tests_on_aarch64: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Build and run tests + run: make run_tests PLATFORM="linux/arm64/v8" ARCH="aarch64" + + docker_tests_on_amd64: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Build and run tests + run: make run_tests PLATFORM="linux/amd64" ARCH="amd64" diff --git a/Makefile b/Makefile index fb1a1447f6..73729b2257 100644 --- a/Makefile +++ b/Makefile @@ -59,4 +59,16 @@ armv7_frigate: version web armv7_all: armv7_wheels armv7_ffmpeg armv7_frigate -.PHONY: web +run_tests: + # PLATFORM: linux/arm64/v8 linux/amd64 or linux/arm/v7 + # ARCH: aarch64 amd64 or armv7 + @cat docker/Dockerfile.base docker/Dockerfile.$(ARCH) > docker/Dockerfile.test + @sed -i "s/FROM frigate-web as web/#/g" docker/Dockerfile.test + @sed -i "s/COPY --from=web \/opt\/frigate\/build web\//#/g" docker/Dockerfile.test + @sed -i "s/FROM frigate-base/#/g" docker/Dockerfile.test + @echo "" >> docker/Dockerfile.test + @echo "RUN python3 -m unittest" >> docker/Dockerfile.test + @docker buildx build --platform=$(PLATFORM) --tag frigate-base --build-arg NGINX_VERSION=1.0.2 --build-arg FFMPEG_VERSION=1.0.0 --build-arg ARCH=$(ARCH) --build-arg WHEELS_VERSION=1.0.3 --file docker/Dockerfile.test . + @rm docker/Dockerfile.test + +.PHONY: web run_tests diff --git a/frigate/app.py b/frigate/app.py index 792b1c7121..a5f577b533 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -77,9 +77,6 @@ def init_config(self): self.config = user_config.runtime_config for camera_name in self.config.cameras.keys(): - # generage the ffmpeg commands - self.config.cameras[camera_name].create_ffmpeg_cmds() - # create camera_metrics self.camera_metrics[camera_name] = { "camera_fps": mp.Value("d", 0.0), diff --git a/frigate/config.py b/frigate/config.py index 1973913c95..a78c0f3a59 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -537,6 +537,8 @@ def ffmpeg_cmds(self) -> List[Dict[str, List[str]]]: return self._ffmpeg_cmds def create_ffmpeg_cmds(self): + if "_ffmpeg_cmds" in self: + return ffmpeg_cmds = [] for ffmpeg_input in self.ffmpeg.inputs: ffmpeg_cmd = self._get_ffmpeg_cmd(ffmpeg_input) @@ -845,7 +847,8 @@ def runtime_config(self) -> FrigateConfig: logger.warning( f"Recording retention is configured for {camera_config.record.retain.mode} and event retention is configured for {camera_config.record.events.retain.mode}. The more restrictive retention policy will be applied." ) - + # generage the ffmpeg commands + camera_config.create_ffmpeg_cmds() config.cameras[name] = camera_config return config diff --git a/frigate/test/test_config.py b/frigate/test/test_config.py index d1f2416e6b..76325385ff 100644 --- a/frigate/test/test_config.py +++ b/frigate/test/test_config.py @@ -572,7 +572,7 @@ def test_motion_frame_height_wont_go_below_120(self): assert config == frigate_config.dict(exclude_unset=True) runtime_config = frigate_config.runtime_config - assert runtime_config.cameras["back"].motion.frame_height >= 120 + assert runtime_config.cameras["back"].motion.frame_height == 50 def test_motion_contour_area_dynamic(self): @@ -601,7 +601,7 @@ def test_motion_contour_area_dynamic(self): assert config == frigate_config.dict(exclude_unset=True) runtime_config = frigate_config.runtime_config - assert round(runtime_config.cameras["back"].motion.contour_area) == 99 + assert round(runtime_config.cameras["back"].motion.contour_area) == 30 def test_merge_labelmap(self): diff --git a/frigate/test/test_reduce_boxes.py b/frigate/test/test_reduce_boxes.py index db3803162e..69d6f71773 100644 --- a/frigate/test/test_reduce_boxes.py +++ b/frigate/test/test_reduce_boxes.py @@ -1,4 +1,3 @@ -import cv2 import numpy as np from unittest import TestCase, main from frigate.video import box_overlaps, reduce_boxes