From 530ab002c7bd3285661b89e4b2b3f4f02aac5aff Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Wed, 3 Jul 2024 09:42:33 -0700 Subject: [PATCH] More closely mirror tox workflow for morango integration tests. --- .github/workflows/morango_integration.yml | 78 ++++++++++------------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/.github/workflows/morango_integration.yml b/.github/workflows/morango_integration.yml index ca21fe9a178..3cf02a09aae 100644 --- a/.github/workflows/morango_integration.yml +++ b/.github/workflows/morango_integration.yml @@ -27,7 +27,7 @@ jobs: if: needs.pre_job.outputs.should_skip != 'true' runs-on: ubuntu-20.04 env: - INTEGRATION_TESTS: 'true' + INTEGRATION_TEST: 'true' strategy: matrix: python-version: [3.6, 3.7, 3.8, 3.9, '3.10', '3.11'] @@ -41,27 +41,17 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Cache SQLite3 - id: cache + - name: Install tox + run: | + python -m pip install --upgrade pip + pip install "tox<4" + - name: tox env cache uses: actions/cache@v4 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 - 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 + path: ${{ github.workspace }}/.tox/py${{ matrix.python-version }} + key: ${{ runner.os }}-tox-py${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt') }} + - name: Test with tox + run: tox -e py${{ matrix.python-version }} -- kolibri/core/auth/test/test_morango_integration.py morango_integration_tests_postgres: @@ -70,44 +60,44 @@ jobs: if: needs.pre_job.outputs.should_skip != 'true' runs-on: ubuntu-latest env: - INTEGRATION_TESTS: 'true' + INTEGRATION_TEST: 'true' services: + # Label used to access the service container postgres: - image: postgres:latest + # Docker Hub image + image: postgres:12 + # Provide the password for postgres env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: test + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 ports: + # Maps tcp port 5432 on service container to the host - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Set up Python + - name: Set up Python 3.9 for Postgres uses: actions/setup-python@v5 with: - python-version: '3.9' - - - name: Install dependencies + python-version: 3.9 + - name: Install tox run: | - 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 pre-test script - 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 + python -m pip install --upgrade pip + pip install "tox<4" + - name: tox env cache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.tox/py3.9 + key: ${{ runner.os }}-tox-py3.9-${{ hashFiles('requirements/*.txt') }} + - name: Test with tox + run: tox -e postgres -- kolibri/core/auth/test/test_morango_integration.py