Skip to content

Commit

Permalink
Execute integration tests concurrently
Browse files Browse the repository at this point in the history
  • Loading branch information
hunyadi committed Jan 11, 2024
1 parent 377c21f commit 0959f3d
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 26 deletions.
55 changes: 55 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
name: Test PyPI package
description: Run Python `unittest` on a pre-packaged Python wheel uploaded as an artifact

inputs:
python-version:
description: Python version to run tests with
required: true
default: '3.12'
options-extras:
description: Extras to pass to `pip install`
required: false
default: ''

runs:
using: composite
steps:
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Fetch PyPI package
uses: actions/download-artifact@v4
with:
merge-multiple: true

- name: Install PyPI package without extras
if: ${{ ! inputs.options-extras }}
run: |
for FILE in `ls *.whl`; do python -m pip install $FILE; done
shell: bash

- name: Install PyPI package with extras
if: ${{ inputs.options-extras }}
run: |
for FILE in `ls *.whl`; do python -m pip install $FILE'[${{ inputs.options-extras }}]'; done
shell: bash

- name: Fetch unit and/or integration tests
uses: actions/checkout@v4
with:
sparse-checkout: |
.
tests
- name: Install test requirements
run: |
python -m pip --disable-pip-version-check install -r requirements-test.txt
shell: bash

- name: Run unit and/or integration tests
run: |
python -m unittest discover
shell: bash
111 changes: 88 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ defaults:
run:
shell: bash

env:
TEST_INTEGRATION: 1

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -24,7 +27,7 @@ jobs:
- name: Set up build dependencies
run: |
python -m pip install --upgrade pip
python -m pip --disable-pip-version-check install -r requirements.txt
python -m pip --disable-pip-version-check install -r requirements-dev.txt
- name: Run sanity checks
run: |
Expand All @@ -42,7 +45,7 @@ jobs:
if-no-files-found: error
compression-level: 0

test:
test-postgresql:
runs-on: ubuntu-latest
needs: build

Expand All @@ -64,6 +67,30 @@ jobs:
--health-retries 5
--health-start-period 10s
env:
TEST_POSTGRESQL: 1

strategy:
matrix:
python-version: ["3.9", "3.12"]

steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
.github
- name: Test PyPI package
uses: ./.github/actions/test
with:
python-version: ${{ matrix.python-version }}
options-extras: postgresql

test-oracle:
runs-on: ubuntu-latest
needs: build

services:
oracle:
image: container-registry.oracle.com/database/free:latest
env:
Expand All @@ -77,6 +104,30 @@ jobs:
--health-retries 10
--health-start-period 30s
env:
TEST_ORACLE: 1

strategy:
matrix:
python-version: ["3.12"]

steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
.github
- name: Test PyPI package
uses: ./.github/actions/test
with:
python-version: ${{ matrix.python-version }}
options-extras: oracle

test-mysql:
runs-on: ubuntu-latest
needs: build

services:
mysql:
image: mysql:8.0
env:
Expand All @@ -92,6 +143,30 @@ jobs:
--health-retries 5
--health-start-period 10s
env:
TEST_MYSQL: 1

strategy:
matrix:
python-version: ["3.9", "3.12"]

steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
.github
- name: Test PyPI package
uses: ./.github/actions/test
with:
python-version: ${{ matrix.python-version }}
options-extras: mysql

test-mssql:
runs-on: ubuntu-latest
needs: build

services:
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
Expand All @@ -108,34 +183,24 @@ jobs:
--health-retries 5
--health-start-period 10s
env:
TEST_MSSQL: 1

strategy:
matrix:
python-version: ["3.9", "3.12"]
python-version: ["3.12"]

steps:
- name: Install Microsoft ODBC
run: sudo ACCEPT_EULA=Y apt-get install msodbcsql18 -y

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Fetch PyPI package
uses: actions/download-artifact@v4
with:
name: pysqlsync-dist

- name: Install PyPI package
run: |
for FILE in `ls *.whl`; do python -m pip install $FILE'[tsv,postgresql,oracle,mysql,mssql]'; done
- name: Fetch integration tests
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
sparse-checkout: |
tests
.github
- name: Run integration tests
run: |
TEST_INTEGRATION=1 TEST_POSTGRESQL=1 TEST_ORACLE=1 TEST_MYSQL=1 TEST_MSSQL=1 python -m unittest discover
- name: Test PyPI package
uses: ./.github/actions/test
with:
python-version: ${{ matrix.python-version }}
options-extras: mssql
3 changes: 0 additions & 3 deletions requirements.txt → requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ build >= 1.0
mypy >= 1.8
flake8 >= 7.0

# data export/import
tsv2py >= 0.5.2

# PostgreSQL
asyncpg >= 0.29
asyncpg-stubs >= 0.29
Expand Down
2 changes: 2 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# data export/import
tsv2py >= 0.5.2

0 comments on commit 0959f3d

Please sign in to comment.