Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support motor 3.0 #224

Merged
merged 9 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Switch to flit for the build system
  • Loading branch information
art049 committed Jun 1, 2022
commit d2374d568c4e69a8a7854bb115d197010a8a9773
123 changes: 57 additions & 66 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,77 +49,68 @@ jobs:
.tox
poetry.lock
key: env-compatibility-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
- name: Install dependencies
run: |
pip install poetry tox
poetry config virtualenvs.in-project true
poetry config experimental.new-installer false
poetry lock
- name: Install tox
run: pip install tox flit
- name: Run compatibility checks.
run: |
export VERSION_STR=$(echo ${{ matrix.python-version }} | sed -e "s/\.//g")
export TOX_SKIP_ENV=$(printf '^(?!py%s-)' $VERSION_STR)
tox auto

# tests:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# python-version:
# - 3.6
# - 3.7
# - 3.8
# - 3.9
# mongo-version:
# - 4.0
# - 4.2
# - 4.4
# mongo-mode:
# - standalone
# include:
# - python-version: 3.8
# mongo-version: 4.0
# mongo-mode: replicaSet
# - python-version: 3.8
# mongo-version: 4.2
# mongo-mode: sharded
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- 3.6
- 3.7
- 3.8
- 3.9
mongo-version:
- 4.0
- 4.2
- 4.4
mongo-mode:
- standalone
include:
- python-version: 3.8
mongo-version: 4.0
mongo-mode: replicaSet
- python-version: 3.8
mongo-version: 4.2
mongo-mode: sharded

# steps:
# - uses: actions/checkout@v2
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v2
# with:
# python-version: ${{ matrix.python-version }}
# - name: Mongo Service
# id: mongo-service
# uses: ./.github/actions/mongo-service
# with:
# version: ${{ matrix.mongo-version }}
# mode: ${{ matrix.mongo-mode }}
# - name: Cache environment
# uses: actions/cache@v2
# with:
# path: .venv
# key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
# - name: Install dependencies
# run: |
# pip install poetry
# poetry config virtualenvs.in-project true
# poetry config experimental.new-installer false
# poetry install
# - name: Run all tests
# run: |
# set -e
# poetry run coverage run -m pytest -v
# poetry run coverage report -m
# poetry run coverage xml
# env:
# TEST_MONGO_URI: ${{ steps.mongo-service.outputs.connection-string }}
# TEST_MONGO_MODE: ${{ matrix.mongo-mode }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: "pyproject.toml"
- name: Mongo Service
id: mongo-service
uses: ./.github/actions/mongo-service
with:
version: ${{ matrix.mongo-version }}
mode: ${{ matrix.mongo-mode }}
- name: Install dependencies
run: |
pip install flit
pip install ".[test]"
- name: Run all tests
run: |
set -e
coverage run -m pytest -v
coverage report -m
coverage xml
env:
TEST_MONGO_URI: ${{ steps.mongo-service.outputs.connection-string }}
TEST_MONGO_MODE: ${{ matrix.mongo-mode }}

# - uses: codecov/codecov-action@v1
# if: github.event_name != 'schedule' # Don't report coverage for nightly builds
# with:
# file: ./coverage.xml
# flags: tests-${{ matrix.python-version }}-${{ matrix.mongo-version }}-${{ matrix.mongo-mode }}
# fail_ci_if_error: true
- uses: codecov/codecov-action@v1
if: github.event_name != 'schedule' # Don't report coverage for nightly builds
with:
file: ./coverage.xml
flags: tests-${{ matrix.python-version }}-${{ matrix.mongo-version }}-${{ matrix.mongo-mode }}
fail_ci_if_error: true
18 changes: 9 additions & 9 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,32 @@ tasks:
deps:
- task: "mongodb:check"
cmds:
- poetry run pytest -rs
- pytest -rs

default:
desc: |
Run the tests related to changes with the current version.
deps:
- task: mongodb
cmds:
- poetry run pytest -rs --testmon
- pytest -rs --testmon

coverage:
desc: Get the test coverage (xml and html) with the current version.
deps:
- task: "mongodb:check"
cmds:
- poetry run coverage run -m pytest -rs
- poetry run coverage report -m
- poetry run coverage xml
- coverage run -m pytest -rs
- coverage report -m
- coverage xml
- 'echo "Generated XML report: ./coverage.xml"'
- poetry run coverage html
- coverage html
- 'echo "Generated HTML report: ./htmlcov/index.html"'

docs:
desc: Start the local documentation server.
cmds:
- poetry run mkdocs serve -f ./docs/mkdocs.yml
- mkdocs serve -f ./docs/mkdocs.yml

lint:
desc: Run the linting checks.
Expand All @@ -57,8 +57,8 @@ tasks:
format:
desc: Format the code (and imports).
cmds:
- poetry run isort -y
- poetry run black ./
- isort odmantic tests
- black odmantic tests

setup:
desc: Configure the development environment.
Expand Down
88 changes: 45 additions & 43 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[tool.poetry]
name = "ODMantic"
[project]
name = "odmantic"
version = "0.4.0"
description = "ODMantic, an AsyncIO MongoDB Object Document Mapper for Python using type hints "
authors = ["Arthur Pastel <arthur.pastel@gmail.com>"]
license = "ISC License"
authors = [{ name = "Arthur Pastel", email = "arthur.pastel@gmail.com" }]
license = { file = "LICENSE" }
readme = "README.md"
repository = "https://github.com/art049/odmantic"
documentation = "https://art049.github.io/odmantic"
keywords = ["mongodb", "asyncio", "types", "pydantic", "motor"]
classifiers = [
"Intended Audience :: Information Technology",
Expand Down Expand Up @@ -34,47 +32,51 @@ classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python",
]
include = ["LICENSE", "README.md"]

[tool.poetry.dependencies]
python = ">=3.6.1,<4.0"
importlib-metadata = { version = ">=1,<5", python = "<3.8" }
typing-extensions = { version = "^3.7.4.3", python = "<3.8" }
pydantic = ">=1.6.2,!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<1.10.0"
motor = ">=2.1.0,<3.1.0"
fastapi = { version = ">=0.61.1,<1.0.0", optional = true }

[tool.poetry.extras]
fastapi = ["fastapi"]
requires-python = ">=3.6.1"
dependencies = [
"pydantic >=1.6.2,!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<1.10.0",
"motor >=2.1.0,<3.1.0",
"importlib-metadata >=1,<5; python_version<'3.8'",
"typing-extensions >= 3.7.4.3; python_version<'3.8'",
]
[project.optional-dependencies]
fastapi = ["fastapi >=0.61.1,<0.69.0"]
test = [
"black ~= 22.3.0",
"isort ~=5.8.0",
"flake8 ~= 4.0.1",
"mypy ~= 0.942",
"pytest ~= 7.0",
"pytest-xdist ~= 2.1.0",
"pytest-asyncio ~= 0.16.0",
# "pytest-testmon ~= 1.3.1",
"async-asgi-testclient ~= 1.4.4",
"asyncmock ~= 0.4.2",
"coverage[toml] ~= 6.2",
"pytz ~= 2022.1",
"darglint ~= 1.5.4",
"ipython ~= 7.16.1",
"uvicorn ~= 0.17.0",
"fastapi >=0.61.1,<0.69.0",
"requests ~= 2.24.0",
"typer ~= 0.4.1",
"semver ~= 2.13.0",
]
doc = [
"pydocstyle ~= 6.0.0",
"mkdocs ~= 1.2.0",
"mkdocs-material ~= 7.0.3",
"mkdocstrings ~= 0.16.2",
]

[tool.poetry.dev-dependencies]
pytest = "~=7.0"
isort = "~=5.8.0"
black = { version = "*", allow-prereleases = true }
flake8 = "~=4.0.1"
mypy = "^0.942"
coverage = { extras = ["toml"], version = "^6.2" }
pytest-xdist = "^2.1.0"
pytz = "^2022.1"
asyncmock = "^0.4.2"
mkdocstrings = "^0.16.2"
pydocstyle = "^6.0.0"
darglint = "^1.5.4"
ipython = "^7.16.1"
pytest-asyncio = "^0.16.0"
mkdocs = "^1.2.0"
mkdocs-material = "^7.0.3"
uvicorn = "^0.17.0"
fastapi = ">=0.61.1,<0.69.0"
requests = "^2.24.0"
typer = "^0.4.1"
semver = "^2.13.0"
pytest-testmon = "^1.0.3"
async-asgi-testclient = "^1.4.4"
[project.urls]
Documentation = "https://art049.github.io/odmantic"
Source = "https://github.com/art049/odmantic"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[tool.isort]
line_length = 88
Expand Down
6 changes: 2 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ envlist =
py{37,38,39}-motor{21,22,23,24,25,30}-pydantic{17,18,19}
skip_missing_interpreters=false
[testenv]
extras = test
deps =
motor21: motor ~= 2.1.0
motor22: motor ~= 2.2.0
Expand All @@ -17,11 +18,8 @@ deps =
pydantic18: pydantic ~= 1.8.2
pydantic19: pydantic ~= 1.9.0
whitelist_externals =
poetry
bash
pytest
commands =
bash -c 'poetry export --dev --without-hashes -f requirements.txt | grep -v "^motor==\|^pydantic==" | pip install -r /dev/stdin'
python -c "import motor; print(motor.version)" 1>&2
python -c "import pydantic; print(pydantic.VERSION)" 1>&2
pytest -q -rs
python -m pytest -q -rs