Skip to content

Commit

Permalink
Merge branch 'main' into fix-database-link
Browse files Browse the repository at this point in the history
  • Loading branch information
alejsdev authored Jun 21, 2024
2 parents ac7f716 + 96bfd85 commit 9bf76ab
Show file tree
Hide file tree
Showing 43 changed files with 877 additions and 935 deletions.
5 changes: 0 additions & 5 deletions .flake8

This file was deleted.

24 changes: 10 additions & 14 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- README.md
- docs/**
- docs_src/**
- requirements-docs.txt
- pyproject.toml
- mkdocs.yml
- mkdocs.insiders.yml
Expand All @@ -45,28 +46,23 @@ jobs:
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v01
- name: Install Poetry
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt') }}-v01
- name: Install docs extras
if: steps.cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
python -m pip install "poetry"
python -m poetry self add poetry-version-plugin
- name: Configure poetry
run: python -m poetry config virtualenvs.create false
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: python -m poetry install
run: pip install -r requirements-docs.txt
- name: Install Material for MkDocs Insiders
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' ) && steps.cache.outputs.cache-hit != 'true'
run: python -m poetry run pip install git+https://${{ secrets.SQLMODEL_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
run: |
pip install git+https://${{ secrets.SQLMODEL_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
pip install git+https://${{ secrets.SQLMODEL_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/griffe-typing-deprecated.git
pip install git+https://${{ secrets.SQLMODEL_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/mkdocstrings-python.git
- uses: actions/cache@v3
with:
key: mkdocs-cards-${{ github.ref }}
Expand All @@ -75,7 +71,7 @@ jobs:
run: python ./scripts/docs.py verify-readme
- name: Build Docs
run: python ./scripts/docs.py build
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: docs-site
path: ./site/**
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ jobs:
run: |
rm -rf ./site
mkdir ./site
- name: Download Artifact Docs
id: download
uses: dawidd6/action-download-artifact@v2.28.0
- uses: actions/download-artifact@v4
with:
if_no_artifact_found: ignore
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-docs.yml
run_id: ${{ github.event.workflow_run.id }}
name: docs-site
path: ./site/
pattern: docs-site
merge-multiple: true
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Deploy to Cloudflare Pages
if: steps.download.outputs.found_artifact == 'true'
# hashFiles returns an empty string if there are no files
if: hashFiles('./site/*')
id: deploy
uses: cloudflare/pages-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
issue-manager:
runs-on: ubuntu-latest
steps:
- uses: tiangolo/issue-manager@0.4.1
- uses: tiangolo/issue-manager@0.5.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
config: >
Expand Down
45 changes: 16 additions & 29 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,24 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
strategy:
matrix:
package:
- sqlmodel
- sqlmodel-slim
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.7"
# Allow debugging with tmate
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
with:
limit-access-to-actor: true
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root-v2
- name: Install poetry
if: steps.cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
python -m pip install "poetry"
python -m poetry self add poetry-version-plugin
- name: Configure poetry
run: python -m poetry config virtualenvs.create false
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: python -m poetry install
- name: Publish
python-version: "3.11"
- name: Install build dependencies
run: pip install build
- name: Build distribution
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
python -m poetry config pypi-token.pypi $PYPI_TOKEN
bash scripts/publish.sh
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
run: python -m build
- name: Publish
uses: pypa/gh-action-pypi-publish@v1.8.11
12 changes: 7 additions & 5 deletions .github/workflows/smokeshow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'

- run: pip install smokeshow

- uses: dawidd6/action-download-artifact@v2.28.0
- uses: actions/download-artifact@v4
with:
workflow: test.yml
commit: ${{ github.event.workflow_run.head_sha }}
name: coverage-html
path: htmlcov
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}

- run: smokeshow upload coverage-html
- run: smokeshow upload htmlcov
env:
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 95
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/test-redistribute.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Test Redistribute

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize

jobs:
test-redistribute:
runs-on: ubuntu-latest
strategy:
matrix:
package:
- sqlmodel
- sqlmodel-slim
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install build dependencies
run: pip install build
- name: Build source distribution
env:
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
run: python -m build --sdist
- name: Decompress source distribution
run: |
cd dist
tar xvf sqlmodel*.tar.gz
- name: Install test dependencies
run: |
cd dist/sqlmodel*/
pip install -r requirements-tests.txt
env:
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
- name: Run source distribution tests
run: |
cd dist/sqlmodel*/
bash scripts/test.sh
- name: Build wheel distribution
run: |
cd dist
pip wheel --no-deps sqlmodel*.tar.gz
33 changes: 13 additions & 20 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# Allow debugging with tmate
Expand All @@ -51,38 +51,30 @@ jobs:
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root-v2
- name: Install poetry
if: steps.cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
python -m pip install "poetry"
python -m poetry self add poetry-version-plugin
- name: Configure poetry
run: python -m poetry config virtualenvs.create false
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-v01
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: python -m poetry install
run: pip install -r requirements-tests.txt
- name: Install Pydantic v1
if: matrix.pydantic-version == 'pydantic-v1'
run: pip install --upgrade "pydantic>=1.10.0,<2.0.0"
- name: Install Pydantic v2
if: matrix.pydantic-version == 'pydantic-v2'
run: pip install --upgrade "pydantic>=2.0.2,<3.0.0"
run: pip install --upgrade "pydantic>=2.0.2,<3.0.0" "typing-extensions==4.6.1"
- name: Lint
# Do not run on Python 3.7 as mypy behaves differently
if: matrix.python-version != '3.7' && matrix.pydantic-version == 'pydantic-v2'
run: python -m poetry run bash scripts/lint.sh
run: bash scripts/lint.sh
- run: mkdir coverage
- name: Test
run: python -m poetry run bash scripts/test.sh
run: bash scripts/test.sh
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
- name: Store coverage files
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage
name: coverage-${{ matrix.python-version }}-${{ matrix.pydantic-version }}
path: coverage
coverage-combine:
needs:
Expand All @@ -92,15 +84,16 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.8'

- name: Get coverage files
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: coverage
pattern: coverage-*
path: coverage
merge-multiple: true

- run: pip install coverage[toml]

Expand All @@ -110,7 +103,7 @@ jobs:
- run: coverage html --show-contexts --title "Coverage for ${{ github.sha }}"

- name: Store coverage HTML
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: htmlcov
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
rev: v0.4.7
hooks:
- id: ruff
args:
Expand Down
12 changes: 1 addition & 11 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,10 @@ You will get completion for everything while writing the **minimum** amount of c

You won't need to keep guessing the types of different attributes in your models, if they could be `None`, etc. Your editor will be able to help you with everything because **SQLModel** is based on **standard Python type annotations**.

**SQLModel** even adopts currently <a href="https://github.com/microsoft/pyright/blob/main/specs/dataclass_transforms.md" class="external-link" target="_blank">in development standards</a> for Python type annotations to ensure the **best developer experience**, so you will get inline errors and autocompletion even while creating new model instances.
**SQLModel** adopts <a href="https://peps.python.org/pep-0681/" class="external-link" target="_blank">PEP 681</a> for Python type annotations to ensure the **best developer experience**, so you will get inline errors and autocompletion even while creating new model instances.

<img class="shadow" src="/img/index/autocompletion01.png">

/// info

Don't worry, adopting this in-development standard only affects/improves editor support.

It doesn't affect performance or correctness. And if the in-progress standard was deprecated your code won't be affected.

Meanwhile, you will get inline errors (like type checks) and autocompletion on places you wouldn't get with any other library. 🎉

///

## Short

**SQLModel** has **sensible defaults** for everything, with **optional configurations** everywhere.
Expand Down
Loading

0 comments on commit 9bf76ab

Please sign in to comment.