Skip to content

Commit

Permalink
Merge pull request #4 from numberly/chore/hatch
Browse files Browse the repository at this point in the history
chore(hatch): hatch builder + ci + lint
  • Loading branch information
Lowaiz committed Sep 6, 2023
2 parents ecdfc5d + 7e6f66c commit 0104ca6
Show file tree
Hide file tree
Showing 17 changed files with 407 additions and 92 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CI

on: [ push, pull_request ]

jobs:
test:
strategy:
fail-fast: false
matrix:
python-version: [ '3.10', '3.11' ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade hatch
- name: Run tests
run: |
hatch run +py=${{ matrix.py || matrix.python-version }} test:with-coverage
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Python dependencies
run: |
python -m pip install --upgrade hatch
- name: Check with black + isort
if: always()
run: hatch run style:format && git diff --exit-code
- name: Check with ruff
if: always()
run: hatch run style:lint
- name: Check with mypy
if: always()
run: hatch run types:check

package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Hatch
run: |
python -m pip install -U hatch
- name: Build package
run: |
hatch build
28 changes: 28 additions & 0 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: deploy-release

on:
push:
tags:
- '*'

jobs:
pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Hatch
run: |
python -m pip install -U hatch
- name: Build package
run: |
hatch build
- name: Publish
run: |
hatch publish
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_PASSWORD }}
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# python-vaultwarden

[![PyPI Version][pypi-v-image]][pypi-v-link]
[![Build Status][GHAction-image]][GHAction-link]

A python library for vaultwarden

## Clients
Expand All @@ -17,6 +20,23 @@ target user.
The cryptographic part is handled by the [bitwardentools library](https://github.com/corpusops/bitwardentools).


<!-- Badges -->

[pypi-v-image]: https://img.shields.io/pypi/v/python-vaultwarden.svg

[pypi-v-link]: https://pypi.org/project/python-vaultwarden/

[GHAction-image]: https://github.com/numberly/python-vaultwarden/workflows/CI/badge.svg?branch=main&event=push

[GHAction-link]: https://github.com/numberly/python-vaultwarden/actions?query=event%3Apush+branch%3Amain
<!-- Links -->

[Issue]: https://github.com/numberly/python-vaultwarden/issues

[Discussions]: https://github.com/numberly/python-vaultwarden/discussions

[PyPA Code of Conduct]: https://www.pypa.io/en/latest/code-of-conduct/

## License

Python-vaultwarden is distributed under the terms of the [Apache](https://spdx.org/licenses/Apache-2.0.html) license.
134 changes: 127 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,148 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "python-vaultwarden"
version = "0.7.0"
description = "The Vautlwarden Python Client"
requires-python = ">=3.11"
description = "Admin Vaultwarden and Simple Bitwarden Python Client"
authors = [
{ name = "Lyonel Martinez", email = "lyonel.martinez@numberly.com" },
{ name = "Mathis Ribet", email = "mathis.ribet@numberly.com" },
]
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/numberly/python-vaultwarden"
documentation = "https://numberly.github.io/python-vaultwarden/"
packages = [
{ include = "vaultwarden", from = "src" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"Environment :: Web Environment",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Typing :: Typed",
"Topic :: Internet :: WWW/HTTP",
# Include this classifier to prevent accidently publishing private code to PyPI.
# https://pypi.org/classifiers/
"Private :: Do Not Upload",
]
requires-python = ">=3.10"
dependencies = [
"bitwardentools >=1.0.55",
"httpx >=0.24.1",
]

[tool.hatch.version]
path = "src/vaultwarden/__version__.py"

[tool.hatch.build]
packages = [
"src/vaultwarden",
]
include = [
"/tests",
]

[tool.hatch.build.targets.sdist]
include = ["/src/vaultwarden/**/*.py"]
[tool.hatch.build.targets.wheel]
packages = [
"src/vaultwarden",
]

[tool.hatch.envs.test]
dependencies = [
"coverage",
]

[tool.hatch.envs.test.scripts]
test = "coverage run --source=src/vaultwarden -m unittest discover -p 'test_*.py' tests --top-level-directory ."
_coverage = ["test", "coverage xml", "coverage report --show-missing"]
with-coverage = "test"
[[tool.hatch.envs.test.matrix]]
python = ["3.10", "3.11"]
type = ["default"]
[tool.hatch.envs.test.overrides]
matrix.type.scripts = [
{ key = "with-coverage", value = "_coverage", if = ["default"] },
]

[tool.hatch.envs.types]
dependencies = [
"mypy",
"types-PyYAML",
"types-setuptools",
"typing-extensions",
]
[tool.hatch.envs.types.scripts]
check = "mypy src/vaultwarden"

[tool.hatch.envs.style]
detached = true
dependencies = [
"bitwardentools==1.0.55",
"httpx==0.24.1",
"black",
"isort",
"ruff",
]
[tool.hatch.envs.style.scripts]
lint = [
"ruff check --fix src/vaultwarden",
]
check = [
"isort --check-only --diff src/vaultwarden",
"black -q --check --diff src/vaultwarden",
"ruff check src/vaultwarden",
]
format = [
"isort -q src/vaultwarden",
"black -q src/vaultwarden",
"lint"
]

[tool.ruff]
# Add "Q" to the list of enabled codes.
select = ["B", "E", "F", "I", "N", "Q", "RUF", "SIM", "TCH"]
fixable = ["ALL"]
src = ["src/vaultwarden", "tests"]
target-version = "py310"
line-length = 79

[tool.ruff.flake8-quotes]
docstring-quotes = "double"

[tool.ruff.flake8-bugbear]
extend-immutable-calls = ["typer.Argument"]

[tool.ruff.isort]
force-sort-within-sections = true

[tool.black]
line-length = 79
target-version = ["py310", "py311"]

[tool.isort]
profile = "black"
line_length = 80

[tool.mypy]
ignore_missing_imports = true
warn_unreachable = true
no_implicit_optional = true
show_error_codes = true

[tool.commitizen]
version = "0.7.0"
tag_format = "$version"
update_changelog_on_bump = true
version_files = [
"pyproject.toml:version",
"vaultwarden/__version__.py",
"src/vaultwarden/__version__.py",
]
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 0104ca6

Please sign in to comment.