Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 11 additions & 38 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ permissions:
contents: read

jobs:
# --------------------------------------------------
# Job 1: Linting and Testing (Runs on push and PR)
# --------------------------------------------------
# --------------------------------------------------
# Job 1: Linting and Testing (Runs on push and PR)
# --------------------------------------------------
Expand All @@ -35,38 +32,21 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13' # Specify your desired Python version
python-version: '3.13'

# Install uv
- name: Install uv
uses: astral-sh/setup-uv@v5

# Add uv to the PATH
- name: Add uv to PATH
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
shell: bash
- name: Create virtual environment
run: uv venv
- name: Activate virtual environment
run: |
echo "PATH=$PATH:$PWD/.venv/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV
- name: Install dependencies with uv
run: |
# Install packages from requirements.txt and additional tools
uv pip install -r core_requirements.txt
uv pip install -r dev_requirements.txt
uv sync --group dev

- name: Run pre-commit hooks
uses: pre-commit/action@v3.0.1
# pre-commit might internally use pip/virtualenv, uv installation
# primarily affects the main dependency installation step.

- name: Run tests with coverage
run: |
uv pip install pytest-cov

uv run pytest --cov=sqlmodel_crud_utils --cov-report=xml --cov-report=term # Generate XML and terminal reports
uv run pytest --cov=sqlmodel_crud_utils --cov-report=xml --cov-report=term

- name: Upload coverage report
uses: actions/upload-artifact@v4
Expand All @@ -91,15 +71,13 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11' # Match the version used for testing
python-version: '3.13'

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Build source distribution and wheel
run: python -m build
run: uv build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -140,13 +118,9 @@ jobs:
with:
tag_name: ${{ steps.get_version.outputs.TAG_NAME }}
name: Release ${{ steps.get_version.outputs.TAG_NAME }}
# body: | # Optional: Add release notes here
# Release notes for version ${{ steps.get_version.outputs.TAG_NAME }}
# - Feature A
# - Bugfix B
draft: false
prerelease: false # Set to true if it's a pre-release
files: dist/* # Upload all files from the dist directory
prerelease: false
files: dist/*

# --------------------------------------------------
# Job 4: Publish to PyPI (Runs only on push to release/*)
Expand All @@ -157,9 +131,9 @@ jobs:
# Only run this job on direct pushes to release/* branches
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/')
runs-on: ubuntu-latest
environment: # Optional: Define environment for PyPI publishing rules/secrets
environment:
name: pypi
url: https://pypi.org/p/sqlmodel-crud-utils # Replace with your actual PyPI package URL
url: https://pypi.org/p/sqlmodel-crud-utils
permissions:
id-token: write # Required for trusted publishing
steps:
Expand All @@ -171,7 +145,6 @@ jobs:

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# No need for secrets.PYPI_API_TOKEN if using trusted publishing
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
4 changes: 0 additions & 4 deletions core_requirements.in

This file was deleted.

34 changes: 0 additions & 34 deletions core_requirements.txt

This file was deleted.

14 changes: 0 additions & 14 deletions dev_requirements.in

This file was deleted.

91 changes: 0 additions & 91 deletions dev_requirements.txt

This file was deleted.

6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ line_length = 80

[project]
name = "sqlmodel_crud_utilities"
version = "0.1.0"
version = "0.2.0"
authors = [
{ name="Francis Secada", email = "francis.secada@gmail.com" }
]
Expand Down Expand Up @@ -91,6 +91,7 @@ dev = [
"build>=1.2.2.post1",
"factory-boy>=3.3.3",
"isort>=6.0.1",
"loguru>=0.7.3",
"pre-commit>=4.2.0",
"pytest>=8.3.5",
"pytest-asyncio>=0.26.0",
Expand All @@ -100,6 +101,9 @@ dev = [
"ruff>=0.11.10",
]

doc = [
"pdoc>=15.0.1",
]

doc = [
"pdoc>=15.0.1",
Expand Down
8 changes: 2 additions & 6 deletions sqlmodel_crud_utils/a_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@
from sqlmodel.ext.asyncio.session import AsyncSession
from sqlmodel.sql.expression import SelectOfScalar

from sqlmodel_crud_utils.utils import (
get_sql_dialect_import,
get_val,
is_date,
logger,
)
from sqlmodel_crud_utils.utils import (get_sql_dialect_import, get_val,
is_date, logger)

load_dotenv() # take environment variables from .env.

Expand Down
8 changes: 2 additions & 6 deletions sqlmodel_crud_utils/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
from sqlmodel import Session, SQLModel, select
from sqlmodel.sql.expression import SelectOfScalar

from sqlmodel_crud_utils.utils import (
get_sql_dialect_import,
get_val,
is_date,
logger,
)
from sqlmodel_crud_utils.utils import (get_sql_dialect_import, get_val,
is_date, logger)

load_dotenv() # take environment variables from .env.

Expand Down
12 changes: 4 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@
import pytest
import pytest_asyncio
from sqlalchemy import Engine, create_engine
from sqlalchemy.ext.asyncio import (
AsyncEngine,
async_sessionmaker,
create_async_engine,
)
from sqlalchemy.ext.asyncio import (AsyncEngine, async_sessionmaker,
create_async_engine)
from sqlalchemy.orm import sessionmaker
from sqlmodel import Session as SQLModelSession # Import SQLModel Session
from sqlmodel import SQLModel
from sqlmodel import create_engine as create_sqlmodel_engine
from sqlmodel.ext.asyncio.session import (
AsyncSession as SQLModelAsyncSession, # Import SQLModel AsyncSession
)
from sqlmodel.ext.asyncio.session import \
AsyncSession as SQLModelAsyncSession # Import SQLModel AsyncSession

from .models import MockModel, MockRelatedModel

Expand Down
35 changes: 14 additions & 21 deletions tests/test_async_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,29 @@
from unittest.mock import AsyncMock, MagicMock, call, patch

import pytest
from sqlmodel import ( # Import Relationship if needed for model definition
select,
)
from sqlmodel import \
select # Import Relationship if needed for model definition
from sqlmodel.ext.asyncio.session import AsyncSession

from sqlmodel_crud_utils.a_sync import (
bulk_upsert_mappings as async_bulk_upsert_mappings,
)
from sqlmodel_crud_utils.a_sync import \
bulk_upsert_mappings as async_bulk_upsert_mappings
from sqlmodel_crud_utils.a_sync import delete_row as async_delete_row
from sqlmodel_crud_utils.a_sync import (
get_one_or_create as async_get_one_or_create,
)
from sqlmodel_crud_utils.a_sync import (
get_result_from_query as async_get_result_from_query,
)
from sqlmodel_crud_utils.a_sync import \
get_one_or_create as async_get_one_or_create
from sqlmodel_crud_utils.a_sync import \
get_result_from_query as async_get_result_from_query
from sqlmodel_crud_utils.a_sync import get_row as async_get_row
from sqlmodel_crud_utils.a_sync import get_rows as async_get_rows
from sqlmodel_crud_utils.a_sync import (
get_rows_within_id_list as async_get_rows_within_id_list,
)
from sqlmodel_crud_utils.a_sync import (
insert_data_rows as async_insert_data_rows,
)
from sqlmodel_crud_utils.a_sync import \
get_rows_within_id_list as async_get_rows_within_id_list
from sqlmodel_crud_utils.a_sync import \
insert_data_rows as async_insert_data_rows
from sqlmodel_crud_utils.a_sync import update_row as async_update_row
from sqlmodel_crud_utils.a_sync import write_row as async_write_row

from .conftest import MockModelFactory, MockRelatedModelFactory
from .models import ( # Assuming MockRelatedModel is needed for relationship
MockModel,
)
from .models import \
MockModel # Assuming MockRelatedModel is needed for relationship

# --- Tests for get_result_from_query ---
# (No changes needed for these tests - they use real sessions)
Expand Down
Loading