diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 946f2358c0..cd972a0ba4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,8 +5,12 @@ updates: directory: "/" schedule: interval: "daily" + commit-message: + prefix: ⬆ # Python - package-ecosystem: "pip" directory: "/" schedule: interval: "daily" + commit-message: + prefix: ⬆ diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 18e35b308e..6400691533 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -19,9 +19,9 @@ jobs: env: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" - - uses: actions/checkout@v2 + - uses: actions/checkout@v3.1.0 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: "3.7" # Allow debugging with tmate @@ -30,7 +30,7 @@ jobs: if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} with: limit-access-to-actor: true - - uses: actions/cache@v2 + - uses: actions/cache@v3 id: cache with: path: ${{ env.pythonLocation }} @@ -53,7 +53,7 @@ jobs: - name: Install Material for MkDocs Insiders if: github.event.pull_request.head.repo.fork == false && steps.cache.outputs.cache-hit != 'true' run: python -m poetry run pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: key: mkdocs-cards-${{ github.ref }} path: .cache @@ -65,10 +65,10 @@ jobs: run: python -m poetry run mkdocs build --config-file mkdocs.insiders.yml - name: Zip docs run: python -m poetry run bash ./scripts/zip-docs.sh - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: docs-zip - path: ./docs.zip + path: ./site/docs.zip - name: Deploy to Netlify uses: nwtgck/actions-netlify@v1.1.5 with: diff --git a/.github/workflows/latest-changes.yml b/.github/workflows/latest-changes.yml index 48fb6dc833..9c3edccbf3 100644 --- a/.github/workflows/latest-changes.yml +++ b/.github/workflows/latest-changes.yml @@ -20,7 +20,7 @@ jobs: latest-changes: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3.1.0 with: # To allow latest-changes to commit to the main branch token: ${{ secrets.ACTIONS_TOKEN }} diff --git a/.github/workflows/preview-docs.yml b/.github/workflows/preview-docs.yml index e335e81f91..3550a9b441 100644 --- a/.github/workflows/preview-docs.yml +++ b/.github/workflows/preview-docs.yml @@ -10,17 +10,22 @@ jobs: preview-docs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3.1.0 + - name: Clean site + run: | + rm -rf ./site + mkdir ./site - name: Download Artifact Docs - uses: dawidd6/action-download-artifact@v2.9.0 + uses: dawidd6/action-download-artifact@v2.24.2 with: github_token: ${{ secrets.GITHUB_TOKEN }} workflow: build-docs.yml run_id: ${{ github.event.workflow_run.id }} name: docs-zip + path: ./site/ - name: Unzip docs run: | - rm -rf ./site + cd ./site unzip docs.zip rm -f docs.zip - name: Deploy to Netlify diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 105dbdd4cc..f3c1e980a6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,9 +15,9 @@ jobs: publish: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3.1.0 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: "3.7" # Allow debugging with tmate @@ -26,7 +26,7 @@ jobs: if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} with: limit-access-to-actor: true - - uses: actions/cache@v2 + - uses: actions/cache@v3 id: cache with: path: ${{ env.pythonLocation }} diff --git a/.github/workflows/smokeshow.yml b/.github/workflows/smokeshow.yml new file mode 100644 index 0000000000..7ee17cac55 --- /dev/null +++ b/.github/workflows/smokeshow.yml @@ -0,0 +1,35 @@ +name: Smokeshow + +on: + workflow_run: + workflows: [Test] + types: [completed] + +permissions: + statuses: write + +jobs: + smokeshow: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + + steps: + - uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - run: pip install smokeshow + + - uses: dawidd6/action-download-artifact@v2.24.2 + with: + workflow: test.yml + commit: ${{ github.event.workflow_run.head_sha }} + + - run: smokeshow upload coverage-html + env: + SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage} + SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 95 + SMOKESHOW_GITHUB_CONTEXT: coverage + SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.workflow_run.head_sha }} + SMOKESHOW_AUTH_KEY: ${{ secrets.SMOKESHOW_AUTH_KEY }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d32926218..585ffc0455 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,9 +22,9 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3.1.0 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} # Allow debugging with tmate @@ -33,7 +33,7 @@ jobs: if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} with: limit-access-to-actor: true - - uses: actions/cache@v2 + - uses: actions/cache@v3 id: cache with: path: ${{ env.pythonLocation }} @@ -56,7 +56,43 @@ jobs: - name: Lint if: ${{ matrix.python-version != '3.6.15' }} run: python -m poetry run bash scripts/lint.sh + - run: mkdir coverage - name: Test run: python -m poetry run bash scripts/test.sh - - name: Upload coverage - uses: codecov/codecov-action@v2 + 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 + with: + name: coverage + path: coverage + coverage-combine: + needs: [test] + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: '3.8' + + - name: Get coverage files + uses: actions/download-artifact@v3 + with: + name: coverage + path: coverage + + - run: pip install coverage[toml] + + - run: ls -la coverage + - run: coverage combine coverage + - run: coverage report + - run: coverage html --show-contexts --title "Coverage for ${{ github.sha }}" + + - name: Store coverage HTML + uses: actions/upload-artifact@v3 + with: + name: coverage-html + path: htmlcov diff --git a/README.md b/README.md index 5a63c9da44..5721f1cdb0 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,8 @@ Publish - - Coverage - + + Coverage Package version diff --git a/docs/db-to-code.md b/docs/db-to-code.md index ce9ffac251..2e0fb1babc 100644 --- a/docs/db-to-code.md +++ b/docs/db-to-code.md @@ -62,7 +62,7 @@ The user is probably, in some way, telling your application: 2 ``` -And the would be this table (with a single row): +And the result would be this table (with a single row): diff --git a/docs/index.md b/docs/index.md index 5a63c9da44..5721f1cdb0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -11,9 +11,8 @@ Publish - - Coverage - + + Coverage Package version diff --git a/docs/release-notes.md b/docs/release-notes.md index 3338520b35..4a4788f3bd 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,27 @@ ## Latest Changes +* 👷 Refactor CI artifact upload/download for docs previews. PR [#514](https://github.com/tiangolo/sqlmodel/pull/514) by [@tiangolo](https://github.com/tiangolo). +* ✏️ Fix typo in internal function name `get_sqlachemy_type()`. PR [#496](https://github.com/tiangolo/sqlmodel/pull/496) by [@cmarqu](https://github.com/cmarqu). +* ⬆ Bump actions/cache from 2 to 3. PR [#497](https://github.com/tiangolo/sqlmodel/pull/497) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ✏️ Fix typo in docs. PR [#446](https://github.com/tiangolo/sqlmodel/pull/446) by [@davidbrochart](https://github.com/davidbrochart). +* ⬆ Bump dawidd6/action-download-artifact from 2.24.0 to 2.24.2. PR [#493](https://github.com/tiangolo/sqlmodel/pull/493) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ✏️ Fix typo in `docs/tutorial/create-db-and-table.md`. PR [#477](https://github.com/tiangolo/sqlmodel/pull/477) by [@FluffyDietEngine](https://github.com/FluffyDietEngine). +* ✏️ Fix small typos in docs. PR [#481](https://github.com/tiangolo/sqlmodel/pull/481) by [@micuffaro](https://github.com/micuffaro). +* 🔧 Update Smokeshow coverage threshold. PR [#487](https://github.com/tiangolo/sqlmodel/pull/487) by [@tiangolo](https://github.com/tiangolo). +* 👷 Move from Codecov to Smokeshow. PR [#486](https://github.com/tiangolo/sqlmodel/pull/486) by [@tiangolo](https://github.com/tiangolo). +* ⬆ Bump actions/setup-python from 2 to 4. PR [#411](https://github.com/tiangolo/sqlmodel/pull/411) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ⬆ Update black requirement from ^21.5-beta.1 to ^22.10.0. PR [#460](https://github.com/tiangolo/sqlmodel/pull/460) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ➕ Add extra dev dependencies for MkDocs Material. PR [#485](https://github.com/tiangolo/sqlmodel/pull/485) by [@tiangolo](https://github.com/tiangolo). +* ⬆ Update mypy requirement from 0.930 to 0.971. PR [#380](https://github.com/tiangolo/sqlmodel/pull/380) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ⬆ Update coverage requirement from ^5.5 to ^6.2. PR [#171](https://github.com/tiangolo/sqlmodel/pull/171) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ⬆ Bump codecov/codecov-action from 2 to 3. PR [#415](https://github.com/tiangolo/sqlmodel/pull/415) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ⬆ Bump actions/upload-artifact from 2 to 3. PR [#412](https://github.com/tiangolo/sqlmodel/pull/412) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ⬆ Update flake8 requirement from ^3.9.2 to ^5.0.4. PR [#396](https://github.com/tiangolo/sqlmodel/pull/396) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ⬆ Update pytest requirement from ^6.2.4 to ^7.0.1. PR [#242](https://github.com/tiangolo/sqlmodel/pull/242) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ⬆ Bump actions/checkout from 2 to 3.1.0. PR [#458](https://github.com/tiangolo/sqlmodel/pull/458) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ⬆ Bump dawidd6/action-download-artifact from 2.9.0 to 2.24.0. PR [#470](https://github.com/tiangolo/sqlmodel/pull/470) by [@dependabot[bot]](https://github.com/apps/dependabot). +* 👷 Update Dependabot config. PR [#484](https://github.com/tiangolo/sqlmodel/pull/484) by [@tiangolo](https://github.com/tiangolo). ## 0.0.8 diff --git a/docs/tutorial/create-db-and-table.md b/docs/tutorial/create-db-and-table.md index b81d309284..abd73cb797 100644 --- a/docs/tutorial/create-db-and-table.md +++ b/docs/tutorial/create-db-and-table.md @@ -415,7 +415,7 @@ Now run the program with Python: // We set echo=True, so this will show the SQL code $ python app.py -// First, some boilerplate SQL that we are not that intereted in +// First, some boilerplate SQL that we are not that interested in INFO Engine BEGIN (implicit) INFO Engine PRAGMA main.table_info("hero") diff --git a/docs/tutorial/where.md b/docs/tutorial/where.md index d4e4639dba..ca85a4dd00 100644 --- a/docs/tutorial/where.md +++ b/docs/tutorial/where.md @@ -311,7 +311,7 @@ Instead, it results in a special type of object. If you tried that in an interac ``` -So, that result value is an **expession** object. 💡 +So, that result value is an **expression** object. 💡 And `.where()` takes one (or more) of these **expression** objects to update the SQL statement. @@ -421,7 +421,7 @@ Of course, the keyword arguments would have been a bit shorter. But with the **expressions** your editor can help you a lot with autocompletion and inline error checks. ✨ -Let me give you an example. Let's imagine that keword arguments were supported in SQLModel and you wanted to filter using the secret identity of Spider-Boy. +Let me give you an example. Let's imagine that keyword arguments were supported in SQLModel and you wanted to filter using the secret identity of Spider-Boy. You could write: @@ -436,7 +436,7 @@ Maybe your code could even run and seem like it's all fine, and then some months And maybe finally you would realize that we wrote the code using `secret_identity` which is not a column in the table. We should have written `secret_name` instead. -Now, with the the expressions, your editor would show you an error right away if you tried this: +Now, with the expressions, your editor would show you an error right away if you tried this: ```Python # Expression ✨ @@ -694,7 +694,7 @@ age=35 id=5 name='Black Lion' secret_name='Trevor Challa' !!! tip We get `Black Lion` here too because although the age is not *strictly* less than `35` it is *equal* to `35`. -### Benefits of Expresions +### Benefits of Expressions Here's a good moment to see that being able to use these pure Python expressions instead of keyword arguments can help a lot. ✨ diff --git a/pyproject.toml b/pyproject.toml index 7f5e7f8037..e3b1d3c279 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,14 +36,16 @@ pydantic = "^1.8.2" sqlalchemy2-stubs = {version = "*", allow-prereleases = true} [tool.poetry.dev-dependencies] -pytest = "^6.2.4" -mypy = "0.930" -flake8 = "^3.9.2" -black = {version = "^21.5-beta.1", python = "^3.7"} +pytest = "^7.0.1" +mypy = "0.971" +flake8 = "^5.0.4" +black = {version = "^22.10.0", python = "^3.7"} mkdocs = "^1.2.1" mkdocs-material = "^8.1.4" +pillow = {version = "^9.3.0", python = "^3.7"} +cairosvg = {version = "^2.5.2", python = "^3.7"} mdx-include = "^1.4.1" -coverage = {extras = ["toml"], version = "^5.5"} +coverage = {extras = ["toml"], version = "^6.2"} fastapi = "^0.68.1" requests = "^2.26.0" autoflake = "^1.4" @@ -65,6 +67,7 @@ source = [ "tests", "sqlmodel" ] +context = '${CONTEXT}' [tool.coverage.report] exclude_lines = [ diff --git a/scripts/test-cov-html.sh b/scripts/test-cov-html.sh deleted file mode 100755 index b15445faaa..0000000000 --- a/scripts/test-cov-html.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -x - -bash ./scripts/test.sh -coverage html diff --git a/scripts/test.sh b/scripts/test.sh index 7fce865bd6..9b758bdbdf 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -6,4 +6,4 @@ set -x coverage run -m pytest tests coverage combine coverage report --show-missing -coverage xml +coverage html diff --git a/scripts/zip-docs.sh b/scripts/zip-docs.sh index f2b7ba3be3..69315f5ddd 100644 --- a/scripts/zip-docs.sh +++ b/scripts/zip-docs.sh @@ -3,7 +3,9 @@ set -x set -e +cd ./site + if [ -f docs.zip ]; then rm -rf docs.zip fi -zip -r docs.zip ./site +zip -r docs.zip ./ diff --git a/sqlmodel/main.py b/sqlmodel/main.py index b82d9065f3..ecfd1d93d5 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -385,7 +385,7 @@ def __init__( ModelMetaclass.__init__(cls, classname, bases, dict_, **kw) -def get_sqlachemy_type(field: ModelField) -> Any: +def get_sqlalchemy_type(field: ModelField) -> Any: if issubclass(field.type_, str): if field.field_info.max_length: return AutoString(length=field.field_info.max_length) @@ -432,7 +432,7 @@ def get_column_from_field(field: ModelField) -> Column: # type: ignore sa_column = getattr(field.field_info, "sa_column", Undefined) if isinstance(sa_column, Column): return sa_column - sa_type = get_sqlachemy_type(field) + sa_type = get_sqlalchemy_type(field) primary_key = getattr(field.field_info, "primary_key", False) index = getattr(field.field_info, "index", Undefined) if index is Undefined: