Skip to content

Commit 7f8a1a5

Browse files
authored
💚 Fix CI installs and tests (#2)
1 parent ed0d670 commit 7f8a1a5

File tree

9 files changed

+87
-33
lines changed

9 files changed

+87
-33
lines changed

.github/workflows/build-docs.yml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ on:
33
push:
44
pull_request:
55
types: [opened, synchronize]
6+
workflow_dispatch:
7+
inputs:
8+
debug_enabled:
9+
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
10+
required: false
11+
default: false
612
jobs:
713
build-docs:
814
runs-on: ubuntu-20.04
@@ -16,32 +22,39 @@ jobs:
1622
uses: actions/setup-python@v2
1723
with:
1824
python-version: "3.7"
25+
# Allow debugging with tmate
26+
- name: Setup tmate session
27+
uses: mxschmitt/action-tmate@v3
28+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
29+
with:
30+
limit-access-to-actor: true
1931
- uses: actions/cache@v2
2032
id: cache
2133
with:
2234
path: ${{ env.pythonLocation }}
23-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-docs
35+
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root-docs
2436
- name: Install poetry
2537
if: steps.cache.outputs.cache-hit != 'true'
38+
# TODO: remove python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2
39+
# once there's a release of Poetry 1.2.x including poetry-core > 1.1.0a6
40+
# Ref: https://github.com/python-poetry/poetry-core/pull/188
2641
run: |
2742
python -m pip install --upgrade pip
28-
python -m pip install "poetry>=1.2.0a1"
29-
python -m poetry plugin add poetry-version-plugin
43+
python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2
44+
python -m pip install "poetry==1.2.0a2"
45+
python -m poetry plugin add poetry-version-plugin
3046
- name: Configure poetry
31-
run: python -m poetry config virtualenvs.in-project true
32-
- name: Ensure cache is healthy
33-
if: steps.cache.outputs.cache-hit == 'true'
34-
run: python -m poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
47+
run: python -m poetry config virtualenvs.create false
3548
- name: Install Dependencies
3649
if: steps.cache.outputs.cache-hit != 'true'
3750
run: python -m poetry install
3851
- name: Install Material for MkDocs Insiders
3952
if: github.event.pull_request.head.repo.fork == false && steps.cache.outputs.cache-hit != 'true'
40-
run: pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
53+
run: python -m poetry run pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
4154
- name: Build Docs
42-
run: python3.7 -m mkdocs build
55+
run: python -m poetry run mkdocs build
4356
- name: Zip docs
44-
run: bash ./scripts/zip-docs.sh
57+
run: python -m poetry run bash ./scripts/zip-docs.sh
4558
- uses: actions/upload-artifact@v2
4659
with:
4760
name: docs-zip

.github/workflows/publish.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on:
44
release:
55
types:
66
- created
7+
workflow_dispatch:
8+
inputs:
9+
debug_enabled:
10+
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
11+
required: false
12+
default: false
713

814
jobs:
915
publish:
@@ -14,22 +20,29 @@ jobs:
1420
uses: actions/setup-python@v2
1521
with:
1622
python-version: "3.7"
23+
# Allow debugging with tmate
24+
- name: Setup tmate session
25+
uses: mxschmitt/action-tmate@v3
26+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
27+
with:
28+
limit-access-to-actor: true
1729
- uses: actions/cache@v2
1830
id: cache
1931
with:
2032
path: ${{ env.pythonLocation }}
21-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test
33+
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root
2234
- name: Install poetry
2335
if: steps.cache.outputs.cache-hit != 'true'
36+
# TODO: remove python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2
37+
# once there's a release of Poetry 1.2.x including poetry-core > 1.1.0a6
38+
# Ref: https://github.com/python-poetry/poetry-core/pull/188
2439
run: |
2540
python -m pip install --upgrade pip
26-
python -m pip install "poetry>=1.2.0a1"
27-
python -m poetry plugin add poetry-version-plugin
41+
python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2
42+
python -m pip install "poetry==1.2.0a2"
43+
python -m poetry plugin add poetry-version-plugin
2844
- name: Configure poetry
29-
run: python -m poetry config virtualenvs.in-project true
30-
- name: Ensure cache is healthy
31-
if: steps.cache.outputs.cache-hit == 'true'
32-
run: python -m poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
45+
run: python -m poetry config virtualenvs.create false
3346
- name: Install Dependencies
3447
if: steps.cache.outputs.cache-hit != 'true'
3548
run: python -m poetry install

.github/workflows/test.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on:
44
push:
55
pull_request:
66
types: [opened, synchronize]
7+
workflow_dispatch:
8+
inputs:
9+
debug_enabled:
10+
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
11+
required: false
12+
default: false
713

814
jobs:
915
test:
@@ -19,26 +25,36 @@ jobs:
1925
uses: actions/setup-python@v2
2026
with:
2127
python-version: ${{ matrix.python-version }}
28+
# Allow debugging with tmate
29+
- name: Setup tmate session
30+
uses: mxschmitt/action-tmate@v3
31+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
32+
with:
33+
limit-access-to-actor: true
2234
- uses: actions/cache@v2
2335
id: cache
2436
with:
2537
path: ${{ env.pythonLocation }}
26-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test
38+
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root
2739
- name: Install poetry
2840
if: steps.cache.outputs.cache-hit != 'true'
41+
# TODO: remove python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2
42+
# once there's a release of Poetry 1.2.x including poetry-core > 1.1.0a6
43+
# Ref: https://github.com/python-poetry/poetry-core/pull/188
2944
run: |
3045
python -m pip install --upgrade pip
31-
python -m pip install "poetry>=1.2.0a1"
32-
python -m poetry plugin add poetry-version-plugin
46+
python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2
47+
python -m pip install "poetry==1.2.0a2"
48+
python -m poetry plugin add poetry-version-plugin
3349
- name: Configure poetry
34-
run: python -m poetry config virtualenvs.in-project true
35-
- name: Ensure cache is healthy
36-
if: steps.cache.outputs.cache-hit == 'true'
37-
run: python -m poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
50+
run: python -m poetry config virtualenvs.create false
3851
- name: Install Dependencies
3952
if: steps.cache.outputs.cache-hit != 'true'
4053
run: python -m poetry install
54+
- name: Lint
55+
if: ${{ matrix.python-version != '3.6' }}
56+
run: python -m poetry run bash scripts/lint.sh
4157
- name: Test
42-
run: bash scripts/test.sh
58+
run: python -m poetry run bash scripts/test.sh
4359
- name: Upload coverage
4460
uses: codecov/codecov-action@v1

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ coverage = {extras = ["toml"], version = "^5.5"}
4747
fastapi = "^0.68.0"
4848
requests = "^2.26.0"
4949
autoflake = "^1.4"
50+
isort = "^5.9.3"
51+
async_generator = {version = "*", python = "~3.6"}
52+
async-exit-stack = {version = "*", python = "~3.6"}
5053

5154
[build-system]
5255
requires = ["poetry-core"]

scripts/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ set -x
66
coverage run -m pytest tests
77
coverage combine
88
coverage report --show-missing
9+
coverage xml

scripts/zip-docs.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#! /usr/bin/env bash
2+
3+
set -x
4+
set -e
5+
6+
if [ -f docs.zip ]; then
7+
rm -rf docs.zip
8+
fi
9+
zip -r docs.zip ./site

sqlmodel/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
Callable,
1313
ClassVar,
1414
Dict,
15-
ForwardRef,
1615
List,
1716
Mapping,
1817
Optional,
@@ -30,7 +29,7 @@
3029
from pydantic.fields import FieldInfo as PydanticFieldInfo
3130
from pydantic.fields import ModelField, Undefined, UndefinedType
3231
from pydantic.main import BaseConfig, ModelMetaclass, validate_model
33-
from pydantic.typing import NoArgAnyCallable, resolve_annotations
32+
from pydantic.typing import ForwardRef, NoArgAnyCallable, resolve_annotations
3433
from pydantic.utils import ROOT_KEY, Representation
3534
from sqlalchemy import (
3635
Boolean,
@@ -343,7 +342,7 @@ def __init__(
343342
)
344343
relationship_to = temp_field.type_
345344
if isinstance(temp_field.type_, ForwardRef):
346-
relationship_to = temp_field.type_.__forward_arg__
345+
relationship_to = temp_field.type_.__forward_arg__ # type: ignore
347346
rel_kwargs: Dict[str, Any] = {}
348347
if rel_info.back_populates:
349348
rel_kwargs["back_populates"] = rel_info.back_populates

sqlmodel/orm/session.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Mapping, Optional, Sequence, TypeVar, Union, overload
1+
from typing import Any, Mapping, Optional, Sequence, Type, TypeVar, Union, overload
22

33
from sqlalchemy import util
44
from sqlalchemy.orm import Query as _Query
@@ -118,13 +118,13 @@ def query(self, *entities: Any, **kwargs: Any) -> "_Query[Any]":
118118

119119
def get(
120120
self,
121-
entity: _T,
121+
entity: Type[_T],
122122
ident: Any,
123123
options: Optional[Sequence[Any]] = None,
124124
populate_existing: bool = False,
125125
with_for_update: Optional[Union[Literal[True], Mapping[str, Any]]] = None,
126126
identity_token: Optional[Any] = None,
127-
) -> _T:
127+
) -> Optional[_T]:
128128
return super().get(
129129
entity,
130130
ident,

sqlmodel/sql/expression.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ class SelectOfScalar(_Select, Generic[_TSelect]):
4545
class GenericSelectMeta(GenericMeta, _Select.__class__): # type: ignore
4646
pass
4747

48-
class _Py36Select(_Select, Generic[_TSelect], metaclass=GenericSelectMeta):
48+
class _Py36Select(_Select, Generic[_TSelect], metaclass=GenericSelectMeta): # type: ignore
4949
pass
5050

51-
class _Py36SelectOfScalar(_Select, Generic[_TSelect], metaclass=GenericSelectMeta):
51+
class _Py36SelectOfScalar(_Select, Generic[_TSelect], metaclass=GenericSelectMeta): # type: ignore
5252
pass
5353

5454
# Cast them for editors to work correctly, from several tricks tried, this works

0 commit comments

Comments
 (0)