Skip to content

Commit

Permalink
Chore(#39): Optimize github action workflow for tests
Browse files Browse the repository at this point in the history
Seperate jobs based on DB type.
This avoid initializing all the services in every job.

This also makes it more stable, because sometimes mysql does not start.
Earlier, mysql not starting in other-DB tests cause the test to fail.
Now, Only the mysql test will be affected if mysql service doesnt start
  • Loading branch information
indiVar0508 authored and AbdealiLoKo committed Nov 17, 2022
1 parent f3cae13 commit 1e7e561
Showing 1 changed file with 40 additions and 9 deletions.
49 changes: 40 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,31 @@ on:


jobs:
test:
name: test-python${{ matrix.python-version }}-${{ matrix.db-engine }}
test-sqlite:
name: test-python${{ matrix.python-version }}-sqlite
strategy:
matrix:
python-version:
- "3.6"
- "3.8"
- "3.10"
db-engine:
- sqlite
- postgres
- mysql
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: psf/black@stable
- name: Build
run: pip3 install -e . -r requirements/test.txt
- name: Run tests
run: pytest
env:
DB: sqlite

test-mysql:
name: test-python${{ matrix.python-version }}-mysql
strategy:
matrix:
python-version:
- "3.6"
- "3.10"
services:
mysql:
image: mysql
Expand All @@ -40,6 +52,25 @@ jobs:
--health-interval 5s
--health-timeout 2s
--health-retries 3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: psf/black@stable
- name: Build
run: pip3 install -e . -r requirements/test.txt
- name: Run tests
run: pytest
env:
DB: mysql

test-postgres:
name: test-python${{ matrix.python-version }}-postgres
strategy:
matrix:
python-version:
- "3.6"
- "3.10"
services:
postgres:
image: postgres
ports:
Expand All @@ -52,6 +83,7 @@ jobs:
--health-interval 5s
--health-timeout 2s
--health-retries 3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: psf/black@stable
Expand All @@ -60,5 +92,4 @@ jobs:
- name: Run tests
run: pytest
env:
DB: ${{ matrix.db-engine }}

DB: postgres

0 comments on commit 1e7e561

Please sign in to comment.