From d1d97c1b424073985c31b6e28c62b11494b0a547 Mon Sep 17 00:00:00 2001 From: zerolab Date: Sun, 24 Sep 2023 12:04:17 +0100 Subject: [PATCH 1/2] Try to speed up tests on postgres --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e12ace73..9f356c09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,12 +36,15 @@ jobs: services: postgres: - image: postgres:14 + image: bitnami/postgresql:14 env: POSTGRES_PASSWORD: postgres + POSTGRESQL_PASSWORD: postgres + POSTGRESQL_FSYNC: "off" + POSTGRESQL_DATA_DIR: /dev/shm/pgdata ports: - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + options: --health-cmd "pg_isready -d postgres -U postgres -p 5432" --health-interval 10s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v3 From af7c064637e34849ab57a50f1756ccbcd7f7a724 Mon Sep 17 00:00:00 2001 From: zerolab Date: Sun, 24 Sep 2023 12:18:53 +0100 Subject: [PATCH 2/2] Split up test to sqlite and postgres --- .github/workflows/ci.yml | 46 ++++++++++++++++++++++++++++++++++------ tox.ini | 5 +++++ 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f356c09..b747e97e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,17 +22,48 @@ env: PYTHON_LATEST: "3.11" jobs: - tests: + tests-sqlite: runs-on: ubuntu-latest strategy: fail-fast: false - max-parallel: 4 matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] - DATABASE_URL: ['sqlite:///db.sqlite3', 'postgres://postgres:postgres@localhost/postgres'] - env: - DATABASE_URL: ${{matrix.DATABASE_URL}} + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: ⬇️ Install dependencies + run: | + python -Im pip install --upgrade pip + python -Im pip install flit tox tox-gh-actions + python -Im flit install --symlink + + - name: 🏗️ Build wheel + run: python -Im flit build --format wheel + + - name: 🧪 Run tox targets for Python ${{ matrix.python-version }} + env: + DB: sqlite + run: tox --installpkg ./dist/*.whl + + - name: ⬆️ Upload coverage data + uses: actions/upload-artifact@v3 + with: + name: coverage-data + path: tests/.coverage* + if-no-files-found: ignore + retention-days: 1 + + tests-postgres: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11'] services: postgres: @@ -63,6 +94,9 @@ jobs: run: python -Im flit build --format wheel - name: 🧪 Run tox targets for Python ${{ matrix.python-version }} + env: + DB: sqlite + DATABASE_URL: 'postgres://postgres:postgres@localhost:5432/postgres' run: tox --installpkg ./dist/*.whl - name: ⬆️ Upload coverage data @@ -75,7 +109,7 @@ jobs: coverage: runs-on: ubuntu-latest - needs: tests + needs: [tests-sqlite, tests-postgres] steps: - uses: actions/checkout@v3 diff --git a/tox.ini b/tox.ini index 651e389c..d8c21dc7 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,11 @@ python = 3.10: py310 3.11: py311 +[gh-actions:env] +DB = + sqlite: sqlite + postgres: postgres + [testenv] package = wheel wheel_build_env = .pkg