From 0a37d45eb6530ca434eea45287c9d13856c9e15e Mon Sep 17 00:00:00 2001 From: hasslesstech Date: Tue, 31 Mar 2026 11:36:28 +0300 Subject: [PATCH] [P] Integrate MapView testing into CI pipeline --- .gitea/workflows/tests.yaml | 20 ++++++++++++++++++++ MapView/Dockerfile-test | 14 ++++++++++++++ MapView/test-entry.sh | 3 +++ MapView/tests/test_mp.py | 6 +++--- 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 MapView/Dockerfile-test create mode 100755 MapView/test-entry.sh diff --git a/.gitea/workflows/tests.yaml b/.gitea/workflows/tests.yaml index 3f07f9e..0b6e023 100644 --- a/.gitea/workflows/tests.yaml +++ b/.gitea/workflows/tests.yaml @@ -49,12 +49,32 @@ jobs: working-directory: IoT-Systems run: docker-compose down -v --remove-orphans + mapview-test: + name: MapView testing + runs-on: host-arch-x86_64 + steps: + - name: Clone repository + run: git clone --revision ${{ gitea.sha }} --depth 1 ${{ gitea.server_url }}/${{ gitea.repository }} + + - name: Build MapView testing container + working-directory: IoT-Systems + run: docker build -t local/mapview/${{gitea.sha}} -f MapView/Dockerfile-test . + + - name: Run MapView tests + working-directory: IoT-Systems + run: docker run --rm -it local/mapview/${{gitea.sha}} + + - name: Clean up containers + if: ${{always()}} + run: docker image rm local/mapview/${{gitea.sha}} + integration-smoke-test: name: Integration smoke testing runs-on: host-arch-x86_64 needs: - hub-test - store-test + - mapview-test steps: - name: Clone repository run: git clone --revision ${{ gitea.sha }} --depth 1 ${{ gitea.server_url }}/${{ gitea.repository }} diff --git a/MapView/Dockerfile-test b/MapView/Dockerfile-test new file mode 100644 index 0000000..b85d89a --- /dev/null +++ b/MapView/Dockerfile-test @@ -0,0 +1,14 @@ +# Use the official Python image as the base image +FROM python:latest +# Set the working directory inside the container +WORKDIR /app +# Copy the requirements.txt file and install dependencies +COPY MapView/requirements.txt . + +RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --root-user-action ignore --no-cache-dir unittest +# Copy the entire application into the container +COPY MapView/. . +# Run the main.py script inside the container when it starts +#CMD ["uvicorn", "main:app", "--host", "0.0.0.0"] +CMD ["./test-entry.sh"] diff --git a/MapView/test-entry.sh b/MapView/test-entry.sh new file mode 100755 index 0000000..1f26b56 --- /dev/null +++ b/MapView/test-entry.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +PYTHONPATH=$PWD python3 -m unittest tests.test_mp diff --git a/MapView/tests/test_mp.py b/MapView/tests/test_mp.py index fab62f5..e901925 100644 --- a/MapView/tests/test_mp.py +++ b/MapView/tests/test_mp.py @@ -6,8 +6,8 @@ sys.modules['lineMapLayer'] = Mock() sys.modules['datasource'] = Mock() sys.modules['config'] = Mock() -from MapView.main import get_lat_lon, MapViewApp -from MapView.datasource import Datasource as DataSourceClass +from main import get_lat_lon, MapViewApp +from datasource import Datasource as DataSourceClass # ----------------------- @@ -89,4 +89,4 @@ class TestMapLatLonToProcessedAgentData(unittest.TestCase): if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main()