Skip to content

Commit

Permalink
Add hatch config for build
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim020 committed Mar 22, 2024
1 parent 67bf681 commit 1404838
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 11 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Python Unit Tests
on: [push, pull_request]

concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:
run:
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Hatch
run: pip install --upgrade hatch
- name: Run tests and track code coverage
run: hatch run cov
run-container-matrix:
name: Container matrix on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Hatch
run: pip install --upgrade hatch hatch-containers
- name: Run tests in container matrix
run: hatch run all:test
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Repo specifc ignore
/src/couch_potato/_version.py
dist/
.python-version
couch-potato/__pycache__/
tests/local_test.py
**/__pycache__/
local_test.py

# Generic ignore
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
Expand Down
2 changes: 1 addition & 1 deletion .idea/couch-potato.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions hatch.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[envs.default]
dependencies = [
"coverage[toml]>=6.5",
"pytest",
]

[envs.default.scripts]
test = "pytest {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
cov-report = [
"- coverage combine",
"coverage report --show-missing",
]
cov = [
"test-cov",
"cov-report",
]

[envs.all]
type = "container"

[[envs.all.matrix]]
python = ["3.7", "3.8", "3.9", "3.10", "3.11"]
46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[build-system]
requires = ["hatchling", "hatch-vcs", "hatch-requirements-txt"]
build-backend = "hatchling.build"

[project]
name="couch_potato"
dynamic = ["version", "dependencies"]
readme = "README.md"
requires-python = ">=3.7"
license-files = { paths = ["LICENSE.md"] }
authors = [
{ name = "Tim Bradgate", email = "timbradgate@hotmail.co.uk" },
]
keywords=["couchbase", "odm", "orm"]
classifiers=[
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Database",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules"
]

[project.urls]
Documentation = "https://github.com/Tim020/couch-potato"
"Source code" = "https://github.com/Tim020/couch-potato"
Issues = "https://github.com/Tim020/couch-potato/issues"

[tool.hatch.metadata.hooks.requirements_txt]
files = ["requirements.txt"]

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "src/couch_potato/_version.py"

[tool.hatch.build.targets.sdist]
exclude = [
"/.github",
"dist"
]
File renamed without changes.
6 changes: 3 additions & 3 deletions couch-potato/_model.py → src/couch_potato/_model.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import TYPE_CHECKING, Dict

from _types import BucketBind, ScopeBind, Field
from model import BaseModel, KeyGenerator
from src.couch_potato._types import BucketBind, ScopeBind, Field
from src.couch_potato.model import BaseModel, KeyGenerator

if TYPE_CHECKING:
from couch_potato import CouchPotato
from src.couch_potato.couch_potato import CouchPotato


def make_meta_model(cp: "CouchPotato"):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from couchbase.cluster import Cluster
from couchbase.collection import Collection

from _types import BucketBind
from _model import make_meta_model
from model import BaseModel
from src.couch_potato._types import BucketBind
from src.couch_potato._model import make_meta_model
from src.couch_potato.model import BaseModel


class CouchPotato:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion couch-potato/fields.py → src/couch_potato/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _types import Field
from src.couch_potato._types import Field


class Integer(Field):
Expand Down
2 changes: 1 addition & 1 deletion couch-potato/model.py → src/couch_potato/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from couchbase.options import InsertOptions, ReplaceOptions
from couchbase.scope import Scope

from errors import ModelAttributeError, FieldNotFound, ReadOnlyError
from src.couch_potato.errors import ModelAttributeError, FieldNotFound, ReadOnlyError

T = TypeVar('T', bound='BaseModel')

Expand Down
3 changes: 3 additions & 0 deletions tests/test_dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_dummy():
print("Hello world")
assert True

0 comments on commit 1404838

Please sign in to comment.