Add SQLAlchemy 2.0 support (issue #49) #129
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests Pipeline | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| flake8_py3: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install flake8 pytest | |
| - name: Run flake8 | |
| run: | | |
| flake8 omymodels/ --count --show-source --statistics | |
| # Unit and functional tests | |
| tests: | |
| runs-on: ubuntu-latest | |
| needs: [flake8_py3] | |
| strategy: | |
| matrix: | |
| python: ['3.9', '3.10', '3.11', '3.12', '3.13'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install poetry | |
| poetry install | |
| env: | |
| POETRY_VIRTUALENVS_CREATE: false | |
| - name: Run unit and functional tests | |
| run: | | |
| pytest tests/unit tests/functional -vv --cov=omymodels --cov-report=term-missing --cov-report=xml | |
| - name: Upload coverage to Codecov | |
| if: matrix.python == '3.11' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./coverage.xml | |
| fail_ci_if_error: false | |
| verbose: true | |
| # Integration tests with SQLAlchemy 2.0 (pydantic, pydantic_v2, dataclass, sqlalchemy, sqlalchemy_v2, openapi3) | |
| integration-sqlalchemy: | |
| runs-on: ubuntu-latest | |
| needs: [flake8_py3] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pytest simple-ddl-parser Jinja2 py-models-parser 'pydantic>=1.8.2,<2.0.0' table-meta 'sqlalchemy>=2.0' | |
| pip install -e . | |
| - name: Run SQLAlchemy integration tests | |
| run: | | |
| pytest tests/integration/pydantic tests/integration/pydantic_v2 tests/integration/dataclass tests/integration/sqlalchemy tests/integration/sqlalchemy_v2 tests/integration/openapi3 -vv | |
| # Integration tests with Gino (requires SQLAlchemy<1.4) | |
| integration-gino: | |
| runs-on: ubuntu-latest | |
| needs: [flake8_py3] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pytest simple-ddl-parser Jinja2 py-models-parser 'pydantic>=1.8.2,<2.0.0' table-meta 'gino>=1.0.0' | |
| pip install -e . | |
| - name: Run Gino integration tests | |
| run: | | |
| pytest tests/integration/gino -vv | |
| # Integration tests for SQLModel - DISABLED | |
| # SQLModel requires pydantic>=2.0, but table-meta (used by omymodels) requires pydantic<2.0 | |
| # This is an unresolvable conflict until table-meta adds pydantic 2.x support | |
| deploy-pages: | |
| runs-on: ubuntu-latest | |
| needs: [tests] | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: './docs' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |