From 6b3560c8d350c9ad1e3c847eb7e47eefcf73fb48 Mon Sep 17 00:00:00 2001 From: omri zaher Date: Mon, 11 Aug 2025 11:29:44 +0300 Subject: [PATCH 1/6] Add GitHub Actions workflow for running tests with coverage and update pytest options for verbose output --- .github/workflows/api-testing.yml | 25 +++++++++++++++++++++++++ pytest.ini | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/api-testing.yml diff --git a/.github/workflows/api-testing.yml b/.github/workflows/api-testing.yml new file mode 100644 index 000000000..ab674b803 --- /dev/null +++ b/.github/workflows/api-testing.yml @@ -0,0 +1,25 @@ +name: Run Tests with coverage + +on: + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: "3.12" + + - name: Install dependencies + run: | + pip install -r requirements.txt + + - name: Run tests + run: pytest diff --git a/pytest.ini b/pytest.ini index 04ec5a3a7..3a1f42ecf 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,3 @@ [pytest] testpaths = tests -addopts = -s +addopts = -s -v From 97fb01f3bc73d70a7e16a8750a9ed4febd2a79bd Mon Sep 17 00:00:00 2001 From: omri zaher Date: Mon, 11 Aug 2025 11:44:56 +0300 Subject: [PATCH 2/6] Refactor API and UI test workflows to improve readability and consistency; update base URL retrieval to use environment variable for flexibility --- .github/workflows/api-testing.yml | 18 ++++++++++++++---- .github/workflows/ui-testing.yml | 2 +- tests/auth/test_login.py | 3 ++- tests/board/test_board.py | 3 ++- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/api-testing.yml b/.github/workflows/api-testing.yml index ab674b803..dec328f17 100644 --- a/.github/workflows/api-testing.yml +++ b/.github/workflows/api-testing.yml @@ -1,25 +1,35 @@ -name: Run Tests with coverage +name: Run API Tests on: pull_request: branches: - main + workflow_dispatch: # Allows manual triggering of the workflow jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + # Step 1: Checkout the code + - name: Checkout code + uses: actions/checkout@v4 + # Step 2: Set up Python - name: Set up Python 3.12 uses: actions/setup-python@v4 with: python-version: "3.12" + # Step 3: Install dependencies - name: Install dependencies run: | + python -m pip install --upgrade pip pip install -r requirements.txt - - name: Run tests - run: pytest + # Step 4: Run API tests + - name: Run API tests + env: + BASE_URL: ${{ secrets.BASE_URL }} # Example: Pass API base URL as a secret + run: | + pytest --maxfail=5 --disable-warnings -v diff --git a/.github/workflows/ui-testing.yml b/.github/workflows/ui-testing.yml index cd8797fb2..b37250759 100644 --- a/.github/workflows/ui-testing.yml +++ b/.github/workflows/ui-testing.yml @@ -1,4 +1,4 @@ -name: Selenium UI Tests +name: Run UI Tests on: pull_request: diff --git a/tests/auth/test_login.py b/tests/auth/test_login.py index d38876555..20747f84a 100644 --- a/tests/auth/test_login.py +++ b/tests/auth/test_login.py @@ -1,6 +1,7 @@ +import os import requests -base_url = "http://10.0.0.17" +base_url = os.environ.get("WEKAN_URL", "http://localhost") class TestLogin: def test_health_check(self): diff --git a/tests/board/test_board.py b/tests/board/test_board.py index 45c22fba9..81762f5d2 100644 --- a/tests/board/test_board.py +++ b/tests/board/test_board.py @@ -1,7 +1,8 @@ import pytest import requests +import os -base_url = "http://10.0.0.17" +base_url = os.environ.get("WEKAN_URL", "http://localhost") class TestBoard: @pytest.fixture(scope="class", autouse=True) From 7c7e60c22f966af4b91f0ededd5252b2babd3096 Mon Sep 17 00:00:00 2001 From: omri zaher Date: Mon, 11 Aug 2025 11:45:32 +0300 Subject: [PATCH 3/6] Update API tests workflow to use WEKAN_URL secret for BASE_URL --- .github/workflows/api-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api-testing.yml b/.github/workflows/api-testing.yml index dec328f17..952cc71ac 100644 --- a/.github/workflows/api-testing.yml +++ b/.github/workflows/api-testing.yml @@ -30,6 +30,6 @@ jobs: # Step 4: Run API tests - name: Run API tests env: - BASE_URL: ${{ secrets.BASE_URL }} # Example: Pass API base URL as a secret + BASE_URL: ${{ secrets.WEKAN_URL }} # Example: Pass API base URL as a secret run: | pytest --maxfail=5 --disable-warnings -v From 9da7005a6629465464fc0541044872e5120917af Mon Sep 17 00:00:00 2001 From: omri zaher Date: Mon, 11 Aug 2025 11:53:22 +0300 Subject: [PATCH 4/6] Refactor API testing workflow to include Docker startup and MongoDB user setup steps --- .github/workflows/api-testing.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/api-testing.yml b/.github/workflows/api-testing.yml index 952cc71ac..35988b05d 100644 --- a/.github/workflows/api-testing.yml +++ b/.github/workflows/api-testing.yml @@ -4,30 +4,40 @@ on: pull_request: branches: - main - workflow_dispatch: # Allows manual triggering of the workflow + workflow_dispatch: jobs: test: runs-on: ubuntu-latest steps: - # Step 1: Checkout the code - name: Checkout code uses: actions/checkout@v4 - # Step 2: Set up Python - name: Set up Python 3.12 uses: actions/setup-python@v4 with: python-version: "3.12" - - # Step 3: Install dependencies - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - # Step 4: Run API tests + - name: App Startup with Docker + run: | + docker compose up -d + + - name: Add test user to MongoDB + run: | + docker exec wekan-db mongosh wekan --eval ' + db.users.insertOne({ + username: "omriza5", + password: "123456", + email: "omriza5@gmail.com", + isAdmin: false + }) + ' + - name: Run API tests env: BASE_URL: ${{ secrets.WEKAN_URL }} # Example: Pass API base URL as a secret From fd3c866c532fc052c9095a782ff2098d594b96c1 Mon Sep 17 00:00:00 2001 From: omri zaher Date: Mon, 11 Aug 2025 11:56:39 +0300 Subject: [PATCH 5/6] Update base URL retrieval in tests to use BASE_URL environment variable for consistency --- tests/auth/test_login.py | 2 +- tests/board/test_board.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auth/test_login.py b/tests/auth/test_login.py index 20747f84a..294875ed6 100644 --- a/tests/auth/test_login.py +++ b/tests/auth/test_login.py @@ -1,7 +1,7 @@ import os import requests -base_url = os.environ.get("WEKAN_URL", "http://localhost") +base_url = os.environ.get("BASE_URL", "http://localhost") class TestLogin: def test_health_check(self): diff --git a/tests/board/test_board.py b/tests/board/test_board.py index 81762f5d2..062721eaf 100644 --- a/tests/board/test_board.py +++ b/tests/board/test_board.py @@ -2,7 +2,7 @@ import pytest import requests import os -base_url = os.environ.get("WEKAN_URL", "http://localhost") +base_url = os.environ.get("BASE_URL", "http://localhost") class TestBoard: @pytest.fixture(scope="class", autouse=True) From 45f26c92eb57fcb97cec92cb2c114948bb6698ca Mon Sep 17 00:00:00 2001 From: omri zaher Date: Mon, 11 Aug 2025 12:28:22 +0300 Subject: [PATCH 6/6] Fix WEKAN_URL environment variable retrieval in UI tests for consistency --- .github/workflows/ui-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ui-testing.yml b/.github/workflows/ui-testing.yml index b37250759..8d27407a4 100644 --- a/.github/workflows/ui-testing.yml +++ b/.github/workflows/ui-testing.yml @@ -36,6 +36,6 @@ jobs: - name: Run Selenium tests env: HEADLESS: true - WEKAN_URL: http://${{ secrets.WEKAN_URL }}:80 + WEKAN_URL: ${{ secrets.WEKAN_URL }} run: | pytest tests/ -v -s