From 90b7242b899579a9d79f6bbf09246bad3b6fced9 Mon Sep 17 00:00:00 2001 From: Ramimashkouk Date: Tue, 23 Apr 2024 01:16:49 +0300 Subject: [PATCH] ci: Add tests to workflow --- .github/workflows/backend_check.yml | 33 +++++++++++++++++++ Dockerfile | 2 +- .../app/tests/services/test_process.py | 6 ++-- .../tests/services/test_websocket_manager.py | 2 +- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/.github/workflows/backend_check.yml b/.github/workflows/backend_check.yml index 28cefd90..36754bf6 100644 --- a/.github/workflows/backend_check.yml +++ b/.github/workflows/backend_check.yml @@ -41,3 +41,36 @@ jobs: run: | python -m poetry run isort --line-length=120 --diff . working-directory: backend/df_designer + + test_backend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: set up python 3.10 + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: setup poetry and install dependencies + run: | + python -m pip install --upgrade pip poetry + python -m poetry lock --no-update + python -m poetry install --with lint --no-interaction + working-directory: backend/df_designer + + - name: build wheel + run: | + python -m poetry build + working-directory: backend/df_designer + + - name: Create new project + run: | + python -m poetry run dflowd init --destination ../../ --no-input --overwrite-if-exists + working-directory: backend/df_designer + + - name: run tests + run: | + python -m poetry install + python -m poetry run pytest ../backend/df_designer/app/tests/ + working-directory: df_designer_project diff --git a/Dockerfile b/Dockerfile index 3376828d..f54b29f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,7 +57,7 @@ COPY --from=backend-builder /poetry-venv /poetry-venv ENV PATH="/poetry-venv/bin:$PATH" # Copy only the necessary files -COPY --from=backend-builder /temp/backend/df_designer /src2/df_designer +COPY --from=backend-builder /temp/backend/df_designer /src2/backend/df_designer COPY ./${PROJECT_DIR} /src2/${PROJECT_DIR} # Install the wheel diff --git a/backend/df_designer/app/tests/services/test_process.py b/backend/df_designer/app/tests/services/test_process.py index 9fcb28aa..71af2e82 100644 --- a/backend/df_designer/app/tests/services/test_process.py +++ b/backend/df_designer/app/tests/services/test_process.py @@ -55,10 +55,10 @@ async def test_read_stdout(self, run_process): @pytest.mark.asyncio async def test_write_stdout(self, run_process): process = await run_process("cat") - process.write_stdin(b"DF_Designer team welcome you.\n") + await process.write_stdin(b"DF_Designer team welcome you.\n") output = await process.process.stdout.readline() assert output.decode().strip() == "DF_Designer team welcome you." -class TestBuildProcess: - pass +# class TestBuildProcess: +# pass diff --git a/backend/df_designer/app/tests/services/test_websocket_manager.py b/backend/df_designer/app/tests/services/test_websocket_manager.py index 3bfeb0e9..2b79a98d 100644 --- a/backend/df_designer/app/tests/services/test_websocket_manager.py +++ b/backend/df_designer/app/tests/services/test_websocket_manager.py @@ -56,7 +56,7 @@ async def test_forward_websocket_messages_to_process(self, mocker, websocket_man websocket.receive_text = mocker.AsyncMock(side_effect=[awaited_message, None]) run_manager = mocker.MagicMock(spec=RunManager()) run_process = mocker.MagicMock(spec=RunProcess(run_id)) - run_process.write_stdin = mocker.MagicMock() + run_process.write_stdin = mocker.AsyncMock() run_manager.processes = {run_id: run_process} await websocket_manager.forward_websocket_messages_to_process(run_id, run_manager, websocket)