From 014f98b69beab0b2297b56c5bb1fa10e54144f8f Mon Sep 17 00:00:00 2001 From: Garvit Singhal Date: Fri, 1 Mar 2024 21:50:45 +0530 Subject: [PATCH 1/4] feat: Add GitHub Actions workflow for scheduled Morango Integration Tests --- .github/workflows/morongo_integration.yml | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/morongo_integration.yml diff --git a/.github/workflows/morongo_integration.yml b/.github/workflows/morongo_integration.yml new file mode 100644 index 00000000000..a6bab46ded6 --- /dev/null +++ b/.github/workflows/morongo_integration.yml @@ -0,0 +1,38 @@ +name: Morango Integration Tests + +on: + schedule: + - cron: '0 0 * * 0' + +jobs: + morango_integration_tests: + name: Morango Integration Tests + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install dependencies + run: | + pip install -r requirements/dev.txt --upgrade + pip install -r requirements/test.txt --upgrade + pip install -r requirements/base.txt --upgrade + pip install -r requirements/cext.txt --upgrade + + - name: Run tests + run: python -O -m pytest kolibri/core/auth/test/test_morango_integration.py + + - name: Run tests with PostgreSQL + run: | + export KOLIBRI_DATABASE_ENGINE=postgres; \ + export KOLIBRI_DATABASE_NAME=default; \ + export KOLIBRI_DATABASE_USER=postgres; \ + export KOLIBRI_DATABASE_PASSWORD=postgres; \ + export KOLIBRI_DATABASE_HOST=127.0.0.1; \ + export KOLIBRI_DATABASE_PORT=15432; \ + python -O -m pytest kolibri/core/auth/test/test_morango_integration.py From e7d1608e6b3a44452798909aa147259d89ea06bf Mon Sep 17 00:00:00 2001 From: Garvit Singhal Date: Sat, 2 Mar 2024 11:06:06 +0530 Subject: [PATCH 2/4] Separate Postgres and SQLite configurations for clearer reports. Introduce Python version matrix for SQLite testing --- .github/workflows/morongo_integration.yml | 59 ++++++++++++++++++----- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/.github/workflows/morongo_integration.yml b/.github/workflows/morongo_integration.yml index a6bab46ded6..1e46e7d750e 100644 --- a/.github/workflows/morongo_integration.yml +++ b/.github/workflows/morongo_integration.yml @@ -1,13 +1,53 @@ name: Morango Integration Tests on: - schedule: + schedule: - cron: '0 0 * * 0' jobs: - morango_integration_tests: + morango_integration_tests_sqlite: name: Morango Integration Tests runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8, 3.9, 3.10, 3.11] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install -r requirements/test.txt --upgrade + pip install -r requirements/base.txt --upgrade + pip install -r requirements/cext.txt --upgrade + + - name: Run pre-test script + run: python test/patch_pytest.py + + - name: Run tests with SQLite + run: python -O -m pytest kolibri/core/auth/test/test_morango_integration.py + + morango_integration_tests_postgres: + name: Morango Integration Tests with PostgreSQL + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:latest + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: test + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + steps: - name: Checkout repository uses: actions/checkout@v4 @@ -19,20 +59,13 @@ jobs: - name: Install dependencies run: | - pip install -r requirements/dev.txt --upgrade pip install -r requirements/test.txt --upgrade pip install -r requirements/base.txt --upgrade pip install -r requirements/cext.txt --upgrade + pip install -r requirements/postgres.txt --upgrade - - name: Run tests - run: python -O -m pytest kolibri/core/auth/test/test_morango_integration.py + - name: Run pre-test script + run: python test/patch_pytest.py - name: Run tests with PostgreSQL - run: | - export KOLIBRI_DATABASE_ENGINE=postgres; \ - export KOLIBRI_DATABASE_NAME=default; \ - export KOLIBRI_DATABASE_USER=postgres; \ - export KOLIBRI_DATABASE_PASSWORD=postgres; \ - export KOLIBRI_DATABASE_HOST=127.0.0.1; \ - export KOLIBRI_DATABASE_PORT=15432; \ - python -O -m pytest kolibri/core/auth/test/test_morango_integration.py + run: python -O -m pytest kolibri/core/auth/test/test_morango_integration.py From a2f4b23ba0aba4409c2f3e246c9cf811747e1605 Mon Sep 17 00:00:00 2001 From: Garvit Singhal Date: Sun, 3 Mar 2024 11:38:21 +0530 Subject: [PATCH 3/4] added caching of dependencies --- .github/workflows/morongo_integration.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/morongo_integration.yml b/.github/workflows/morongo_integration.yml index 1e46e7d750e..43041bbff4b 100644 --- a/.github/workflows/morongo_integration.yml +++ b/.github/workflows/morongo_integration.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9, 3.10, 3.11] + python-version: [3.6, 3.7, 3.8, 3.9, '3.10', '3.11'] steps: - name: Checkout repository @@ -21,7 +21,18 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Cache SQLite3 + id: cache + uses: actions/cache@v3 + with: + path: | + ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('requirements/test.txt', 'requirements/base.txt', 'requirements/cext.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies + if: steps.cache.outputs.cache-hit != 'true' run: | pip install -r requirements/test.txt --upgrade pip install -r requirements/base.txt --upgrade @@ -33,6 +44,7 @@ jobs: - name: Run tests with SQLite run: python -O -m pytest kolibri/core/auth/test/test_morango_integration.py + morango_integration_tests_postgres: name: Morango Integration Tests with PostgreSQL runs-on: ubuntu-latest From bd459d61713974072f650ddcceb06cb77a2d869b Mon Sep 17 00:00:00 2001 From: Garvit Singhal Date: Wed, 6 Mar 2024 09:49:22 +0530 Subject: [PATCH 4/4] postgres environment variable added --- .github/workflows/morongo_integration.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/morongo_integration.yml b/.github/workflows/morongo_integration.yml index 43041bbff4b..1f077e34063 100644 --- a/.github/workflows/morongo_integration.yml +++ b/.github/workflows/morongo_integration.yml @@ -80,4 +80,11 @@ jobs: run: python test/patch_pytest.py - name: Run tests with PostgreSQL + env: + KOLIBRI_DATABASE_ENGINE: postgres + KOLIBRI_DATABASE_NAME: test + KOLIBRI_DATABASE_USER: postgres + KOLIBRI_DATABASE_PASSWORD: postgres + KOLIBRI_DATABASE_HOST: localhost + KOLIBRI_DATABASE_PORT: 5432 run: python -O -m pytest kolibri/core/auth/test/test_morango_integration.py